@ledvance/ui-biz-bundle 1.1.55 → 1.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTime/Router.ts +26 -0
- package/src/modules/flags/FlagActions.ts +12 -4
- package/src/modules/flags/FlagPage.tsx +31 -11
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/history/Router.ts +16 -0
- package/src/modules/mood/FantasyRouter.ts +35 -0
- package/src/modules/mood/MixMood/Router.ts +44 -0
- package/src/modules/mood/Router.ts +53 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/powerOnBehavior/Router.ts +16 -0
- package/src/modules/randomTime/Router.ts +25 -0
- package/src/modules/sleepWakeup/Router.ts +25 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.d.ts +0 -7
- package/src/navigation/Routers.ts +15 -304
- package/src/newModules/childLock/ChildLockPage.tsx +97 -0
- package/src/newModules/childLock/Router.ts +16 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
- package/src/newModules/energyConsumption/Router.ts +34 -0
- package/src/newModules/energyConsumption/co2Data.ts +23655 -0
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
- package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
- package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
- package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
- package/src/newModules/fixedTime/Router.ts +25 -0
- package/src/newModules/lightMode/LightModePage.tsx +204 -0
- package/src/newModules/lightMode/Router.ts +16 -0
- package/src/newModules/mood/AddMoodPage.tsx +178 -0
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
- package/src/newModules/mood/Interface.ts +219 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
- package/src/newModules/mood/MoodActions.ts +235 -0
- package/src/newModules/mood/MoodInfo.ts +2151 -0
- package/src/newModules/mood/MoodItem.tsx +148 -0
- package/src/newModules/mood/MoodPage.tsx +385 -0
- package/src/newModules/mood/MoodParse.ts +442 -0
- package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
- package/src/newModules/mood/Router.ts +53 -0
- package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
- package/src/newModules/mood/tools.ts +12 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
- package/src/newModules/overchargeSwitch/Router.ts +16 -0
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
- package/src/newModules/powerOnBehavior/Router.ts +16 -0
- package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
- package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
- package/src/newModules/randomTime/Router.ts +25 -0
- package/src/newModules/randomTime/Summary.tsx +116 -0
- package/src/newModules/swithInching/Router.ts +16 -0
- package/src/newModules/swithInching/SwithInching.tsx +231 -0
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
- package/src/newModules/swithInching/pickerView.tsx +91 -0
- package/src/newModules/timeSchedule/Interface.ts +111 -0
- package/src/newModules/timeSchedule/Router.ts +25 -0
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { cloneDeep, find, isEqual } from 'lodash';
|
|
4
|
+
import { useReactive } from 'ahooks';
|
|
5
|
+
import Page from '@ledvance/base/src/components/Page';
|
|
6
|
+
import I18n from '@ledvance/base/src/i18n';
|
|
7
|
+
import { useNavigation } from '@react-navigation/native';
|
|
8
|
+
import TextField from '@ledvance/base/src/components/TextField';
|
|
9
|
+
import { Utils } from 'tuya-panel-kit';
|
|
10
|
+
import Card from '@ledvance/base/src/components/Card';
|
|
11
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
12
|
+
import res from '@ledvance/base/src/res';
|
|
13
|
+
import TextButton from '@ledvance/base/src/components/TextButton';
|
|
14
|
+
import { useFanMaxSpeed } from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
15
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
|
|
16
|
+
import FanAdjustView from '@ledvance/base/src/components/FanAdjustView';
|
|
17
|
+
import { showDeleteMoodDialog } from './tools';
|
|
18
|
+
import { MoodNodeInfo, MoodPageParams, MoodUIInfo } from './Interface';
|
|
19
|
+
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
20
|
+
import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
|
|
21
|
+
import { cctToColor } from '@ledvance/base/src/utils/cctUtils';
|
|
22
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks';
|
|
23
|
+
import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
|
|
24
|
+
import { RouterKey } from 'navigation/Router';
|
|
25
|
+
import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
|
|
26
|
+
|
|
27
|
+
const cx = Utils.RatioUtils.convertX;
|
|
28
|
+
|
|
29
|
+
export interface StaticMoodEditorPageParams {
|
|
30
|
+
mode: 'add' | 'edit';
|
|
31
|
+
moods: MoodUIInfo[];
|
|
32
|
+
currentMood: MoodUIInfo;
|
|
33
|
+
onSave: () => void;
|
|
34
|
+
moduleParams: MoodPageParams;
|
|
35
|
+
modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface StaticMoodEditorPageState {
|
|
39
|
+
headline: string;
|
|
40
|
+
mood: MoodUIInfo;
|
|
41
|
+
mainNode: MoodNodeInfo;
|
|
42
|
+
secondaryNode: MoodNodeInfo;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const StaticMoodEditorPage = () => {
|
|
47
|
+
const navigation = useNavigation();
|
|
48
|
+
const routeParams = useParams<StaticMoodEditorPageParams>();
|
|
49
|
+
const params = cloneDeep(routeParams);
|
|
50
|
+
const moduleParams = params.moduleParams;
|
|
51
|
+
const isMix = !!(moduleParams.isCeilingLight || moduleParams.isMixLight);
|
|
52
|
+
const state = useReactive<StaticMoodEditorPageState>({
|
|
53
|
+
headline: '',
|
|
54
|
+
mood: params.currentMood,
|
|
55
|
+
mainNode: params.currentMood.mainLamp.nodes[0],
|
|
56
|
+
secondaryNode: params.currentMood?.secondaryLamp?.nodes[0],
|
|
57
|
+
loading: false,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
state.headline = I18n.getLang(
|
|
62
|
+
params.mode === 'add' ? 'add_new_static_mood_headline_text' : 'edit_static_mood_headline_text'
|
|
63
|
+
);
|
|
64
|
+
}, [params.mode]);
|
|
65
|
+
|
|
66
|
+
const getColorBlockColor = useCallback((node: MoodNodeInfo) => {
|
|
67
|
+
const s = Math.round(mapFloatToRange(node.s / 100, 30, 100));
|
|
68
|
+
if (node.isColorNode) {
|
|
69
|
+
return hsv2Hex(node.h, s, 100);
|
|
70
|
+
} else {
|
|
71
|
+
return cctToColor(node.colorTemp.toFixed());
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
const onRightClick = async () => {
|
|
76
|
+
if (state.loading) return;
|
|
77
|
+
state.loading = true;
|
|
78
|
+
const newMood: MoodUIInfo = {
|
|
79
|
+
...state.mood,
|
|
80
|
+
mainLamp: {
|
|
81
|
+
...state.mood.mainLamp,
|
|
82
|
+
nodes: [cloneDeep(state.mainNode)],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
if (isMix) {
|
|
86
|
+
newMood.secondaryLamp = {
|
|
87
|
+
...newMood.secondaryLamp,
|
|
88
|
+
nodes: [cloneDeep(state.secondaryNode)],
|
|
89
|
+
};
|
|
90
|
+
newMood.mainLamp.type = 2
|
|
91
|
+
if(moduleParams.isSupportBrightness && !moduleParams.isSupportTemperature){
|
|
92
|
+
newMood.mainLamp.type = 1
|
|
93
|
+
}
|
|
94
|
+
if(moduleParams.isSupportColor){
|
|
95
|
+
newMood.secondaryLamp.type = 3
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const res = await params.modDeleteMood(params.mode, newMood);
|
|
99
|
+
state.loading = false;
|
|
100
|
+
if (res.success) {
|
|
101
|
+
navigation.navigate(RouterKey.ui_biz_mood);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const getButtonStatus = () => {
|
|
106
|
+
return (
|
|
107
|
+
(params.mode === 'edit' && isEqual(state.mood, params.currentMood)) ||
|
|
108
|
+
!state.mood.name ||
|
|
109
|
+
nameRepeat ||
|
|
110
|
+
state.mood.name.length > 32
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const nameRepeat = useMemo(() => {
|
|
115
|
+
return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
|
|
116
|
+
}, [state.mood.name]);
|
|
117
|
+
|
|
118
|
+
useEffect(() =>{
|
|
119
|
+
console.log(state.mood, '< --- state mood --- >')
|
|
120
|
+
console.log(params.currentMood, '< --- currentMood --- >')
|
|
121
|
+
}, [JSON.stringify(state.mood)])
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Page
|
|
125
|
+
backText={I18n.getLang('mesh_device_detail_mode')}
|
|
126
|
+
showBackDialog={true}
|
|
127
|
+
backDialogTitle={I18n.getLang(
|
|
128
|
+
params.mode === 'add'
|
|
129
|
+
? 'string_light_pp_dialog_sm_add_headline_c'
|
|
130
|
+
: 'manage_user_unsaved_changes_dialog_headline'
|
|
131
|
+
)}
|
|
132
|
+
backDialogContent={I18n.getLang(
|
|
133
|
+
params.mode === 'add'
|
|
134
|
+
? 'strip_light_static_mood_add_step_2_dialog_text'
|
|
135
|
+
: 'strip_light_static_mood_editor_step_2_dialog_text'
|
|
136
|
+
)}
|
|
137
|
+
headlineText={state.headline}
|
|
138
|
+
rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
|
|
139
|
+
rightButtonDisabled={getButtonStatus()}
|
|
140
|
+
rightButtonIconClick={onRightClick}
|
|
141
|
+
loading={state.loading}
|
|
142
|
+
>
|
|
143
|
+
<ScrollView style={{ flex: 1 }} nestedScrollEnabled={true}>
|
|
144
|
+
<View style={styles.root}>
|
|
145
|
+
<TextField
|
|
146
|
+
style={styles.name}
|
|
147
|
+
value={state.mood.name}
|
|
148
|
+
placeholder={I18n.getLang('edit_static_mood_inputfield_topic_text')}
|
|
149
|
+
onChangeText={text => {
|
|
150
|
+
state.mood.name = text;
|
|
151
|
+
}}
|
|
152
|
+
maxLength={33}
|
|
153
|
+
showError={state.mood.name.length > 32 || nameRepeat}
|
|
154
|
+
tipColor={nameRepeat ? '#f00' : undefined}
|
|
155
|
+
tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
|
|
156
|
+
errorText={I18n.getLang(
|
|
157
|
+
nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text'
|
|
158
|
+
)}
|
|
159
|
+
/>
|
|
160
|
+
<Card style={styles.adjustCard}>
|
|
161
|
+
<LdvSwitch
|
|
162
|
+
title={I18n.getLang(
|
|
163
|
+
isMix
|
|
164
|
+
? 'light_sources_tile_main_lighting_headline'
|
|
165
|
+
: 'light_sources_tile_tw_lighting_headline'
|
|
166
|
+
)}
|
|
167
|
+
color={getColorBlockColor(state.mainNode)}
|
|
168
|
+
colorAlpha={1}
|
|
169
|
+
enable={!!state.mood.mainLamp.enable}
|
|
170
|
+
setEnable={v => {
|
|
171
|
+
state.mood.mainLamp.enable = v;
|
|
172
|
+
}}
|
|
173
|
+
showSwitch={!!moduleParams.isMixLight}
|
|
174
|
+
/>
|
|
175
|
+
{(!moduleParams.isMixLight || state.mood.mainLamp.enable) && (
|
|
176
|
+
<LampAdjustView
|
|
177
|
+
isSupportColor={isMix ? false : moduleParams.isSupportColor}
|
|
178
|
+
isSupportBrightness={moduleParams.isSupportBrightness}
|
|
179
|
+
isSupportTemperature={moduleParams.isSupportTemperature}
|
|
180
|
+
isColorMode={state.mainNode.isColorNode}
|
|
181
|
+
reserveSV={true}
|
|
182
|
+
setIsColorMode={isColorMode => {
|
|
183
|
+
state.mainNode.isColorNode = isColorMode;
|
|
184
|
+
}}
|
|
185
|
+
h={state.mainNode.h}
|
|
186
|
+
s={state.mainNode.s}
|
|
187
|
+
v={state.mainNode.v}
|
|
188
|
+
onHSVChange={(h, s, v) => {
|
|
189
|
+
state.mainNode.h = h
|
|
190
|
+
state.mainNode.s = s
|
|
191
|
+
state.mainNode.v = v
|
|
192
|
+
}}
|
|
193
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
194
|
+
state.mainNode.h = h
|
|
195
|
+
state.mainNode.s = s
|
|
196
|
+
state.mainNode.v = v
|
|
197
|
+
}}
|
|
198
|
+
colorTemp={state.mainNode.colorTemp}
|
|
199
|
+
brightness={state.mainNode.brightness}
|
|
200
|
+
onCCTChange={() => {}}
|
|
201
|
+
onCCTChangeComplete={cct => {
|
|
202
|
+
state.mainNode.colorTemp = cct;
|
|
203
|
+
}}
|
|
204
|
+
onBrightnessChange={() => {}}
|
|
205
|
+
onBrightnessChangeComplete={brightness => {
|
|
206
|
+
state.mainNode.brightness = brightness;
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
)}
|
|
210
|
+
</Card>
|
|
211
|
+
<Spacer />
|
|
212
|
+
{isMix && (
|
|
213
|
+
<Card style={styles.fanAdjustCard}>
|
|
214
|
+
<LdvSwitch
|
|
215
|
+
title={I18n.getLang('light_sources_tile_sec_lighting_headline')}
|
|
216
|
+
color={'#fff'}
|
|
217
|
+
colorAlpha={1}
|
|
218
|
+
enable={!!state.mood.secondaryLamp.enable}
|
|
219
|
+
setEnable={v => {
|
|
220
|
+
if(v && !state.mood.secondaryLamp.nodes.length){
|
|
221
|
+
state.mood.secondaryLamp.nodes.push(
|
|
222
|
+
{
|
|
223
|
+
h: 0,
|
|
224
|
+
s: 100,
|
|
225
|
+
v: 100,
|
|
226
|
+
brightness: 0,
|
|
227
|
+
colorTemp: 0,
|
|
228
|
+
isColorNode: true,
|
|
229
|
+
},
|
|
230
|
+
)
|
|
231
|
+
state.secondaryNode = state.mood.secondaryLamp.nodes[0]
|
|
232
|
+
}
|
|
233
|
+
state.mood.secondaryLamp.enable = v;
|
|
234
|
+
}}
|
|
235
|
+
showSwitch={!!moduleParams.isMixLight}
|
|
236
|
+
/>
|
|
237
|
+
{(!moduleParams.isMixLight || state.mood.secondaryLamp.enable) && (
|
|
238
|
+
<>
|
|
239
|
+
<ColorAdjustView
|
|
240
|
+
h={state.secondaryNode.h}
|
|
241
|
+
s={state.secondaryNode.s}
|
|
242
|
+
v={state.secondaryNode.v}
|
|
243
|
+
reserveSV={true}
|
|
244
|
+
onHSVChange={() => {}}
|
|
245
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
246
|
+
state.secondaryNode.h = h
|
|
247
|
+
state.secondaryNode.s = s
|
|
248
|
+
state.secondaryNode.v = v
|
|
249
|
+
}}
|
|
250
|
+
/>
|
|
251
|
+
<Spacer height={cx(16)}/>
|
|
252
|
+
</>
|
|
253
|
+
)}
|
|
254
|
+
</Card>
|
|
255
|
+
)}
|
|
256
|
+
{!!(moduleParams.isFanLight || moduleParams.isUVCFan) && (
|
|
257
|
+
<FanAdjustView
|
|
258
|
+
fanEnable={!!state.mood.mainLamp.fanEnable}
|
|
259
|
+
fanSpeed={state.mood.mainLamp.fanSpeed || 1}
|
|
260
|
+
maxFanSpeed={useFanMaxSpeed()}
|
|
261
|
+
onFanSwitch={fanEnable => {
|
|
262
|
+
state.mood.mainLamp.fanEnable = fanEnable;
|
|
263
|
+
}}
|
|
264
|
+
onFanSpeedChange={fanSpeed => {
|
|
265
|
+
state.mood.mainLamp.fanSpeed = fanSpeed;
|
|
266
|
+
}}
|
|
267
|
+
onFanSpeedChangeComplete={fanSpeed => {
|
|
268
|
+
state.mood.mainLamp.fanSpeed = fanSpeed;
|
|
269
|
+
}}
|
|
270
|
+
style={styles.fanAdjustCard}
|
|
271
|
+
/>
|
|
272
|
+
)}
|
|
273
|
+
{params.mode === 'edit' && (
|
|
274
|
+
<View style={{ marginTop: cx(20), marginHorizontal: cx(24) }}>
|
|
275
|
+
<TextButton
|
|
276
|
+
style={styles.deleteBtn}
|
|
277
|
+
textStyle={styles.deleteBtnText}
|
|
278
|
+
text={I18n.getLang('edit_static_mood_button_delete_text')}
|
|
279
|
+
onPress={() => {
|
|
280
|
+
showDeleteMoodDialog(async (_, { close }) => {
|
|
281
|
+
state.loading = true;
|
|
282
|
+
close();
|
|
283
|
+
const res = await params.modDeleteMood('del', state.mood);
|
|
284
|
+
if (res.success) {
|
|
285
|
+
navigation.navigate(RouterKey.ui_biz_mood);
|
|
286
|
+
}
|
|
287
|
+
state.loading = false;
|
|
288
|
+
});
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
291
|
+
</View>
|
|
292
|
+
)}
|
|
293
|
+
<Spacer />
|
|
294
|
+
</View>
|
|
295
|
+
</ScrollView>
|
|
296
|
+
</Page>
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const styles = StyleSheet.create({
|
|
301
|
+
root: {
|
|
302
|
+
flex: 1,
|
|
303
|
+
flexDirection: 'column',
|
|
304
|
+
},
|
|
305
|
+
name: {
|
|
306
|
+
marginHorizontal: cx(24),
|
|
307
|
+
},
|
|
308
|
+
adjustCard: {
|
|
309
|
+
marginTop: cx(12),
|
|
310
|
+
marginHorizontal: cx(24),
|
|
311
|
+
},
|
|
312
|
+
fanAdjustCard: {
|
|
313
|
+
marginHorizontal: cx(24),
|
|
314
|
+
},
|
|
315
|
+
lightLine: {
|
|
316
|
+
flexDirection: 'row',
|
|
317
|
+
marginHorizontal: cx(16),
|
|
318
|
+
},
|
|
319
|
+
light: {
|
|
320
|
+
color: '#000',
|
|
321
|
+
fontSize: cx(18),
|
|
322
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
323
|
+
},
|
|
324
|
+
preview: {
|
|
325
|
+
width: cx(20),
|
|
326
|
+
height: cx(20),
|
|
327
|
+
marginStart: cx(12),
|
|
328
|
+
borderRadius: cx(4),
|
|
329
|
+
},
|
|
330
|
+
deleteBtn: {
|
|
331
|
+
width: '100%',
|
|
332
|
+
height: cx(50),
|
|
333
|
+
backgroundColor: '#666',
|
|
334
|
+
borderRadius: cx(8),
|
|
335
|
+
},
|
|
336
|
+
deleteBtnText: {
|
|
337
|
+
color: '#fff',
|
|
338
|
+
fontSize: cx(16),
|
|
339
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
export default StaticMoodEditorPage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog } from 'tuya-panel-kit'
|
|
2
|
+
import Strings from '@ledvance/base/src/i18n'
|
|
3
|
+
|
|
4
|
+
export const showDeleteMoodDialog = (onConfirm: (data: any, args: { close: () => void }) => void) => {
|
|
5
|
+
Dialog.confirm({
|
|
6
|
+
title: Strings.getLang('string_light_pp_dialog_sm_ed_headline_d'),
|
|
7
|
+
subTitle: Strings.getLang(`strip_light_static_mood_edit_dialog_text`),
|
|
8
|
+
cancelText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
|
|
9
|
+
confirmText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
|
|
10
|
+
onConfirm: onConfirm,
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
3
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
4
|
+
import I18n from "@ledvance/base/src/i18n/index";
|
|
5
|
+
import {useDeviceInfo, useDp} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
6
|
+
import {useReactive} from "ahooks";
|
|
7
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
8
|
+
import {StyleSheet, Text, View} from "react-native";
|
|
9
|
+
import {Result} from "@ledvance/base/src/models/modules/Result";
|
|
10
|
+
import {useParams} from "@ledvance/base/src/hooks/Hooks";
|
|
11
|
+
|
|
12
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
13
|
+
|
|
14
|
+
export interface OverchargeSwitchPageParams {
|
|
15
|
+
overchargeSwitchCode: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useOverchargeSwitch(overchargeSwitchCode: string): [boolean, (v: boolean) => Promise<Result<any>>] {
|
|
19
|
+
return useDp(overchargeSwitchCode)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const OverchargeSwitchPage = () => {
|
|
23
|
+
const params = useParams<OverchargeSwitchPageParams>()
|
|
24
|
+
const devInfo = useDeviceInfo()
|
|
25
|
+
const [overchargeSwitch, setOverchargeSwitch] = useOverchargeSwitch(params.overchargeSwitchCode)
|
|
26
|
+
const state = useReactive({
|
|
27
|
+
loading: false
|
|
28
|
+
})
|
|
29
|
+
return (<Page
|
|
30
|
+
backText={devInfo.name}
|
|
31
|
+
loading={state.loading}>
|
|
32
|
+
<View style={[styles.titleBGView, styles.shadow]}>
|
|
33
|
+
<View style={{ flex: 7 }}>
|
|
34
|
+
<View>
|
|
35
|
+
<Text style={styles.title}>{I18n.getLang('switch_overcharge_headline_text')}</Text>
|
|
36
|
+
</View>
|
|
37
|
+
<View style={{ paddingBottom: cx(16) }}>
|
|
38
|
+
<Text>{I18n.getLang('switch_overcharge_headline_description')}</Text>
|
|
39
|
+
</View>
|
|
40
|
+
</View>
|
|
41
|
+
<Spacer style={{ flex: 1 }} height={0} width={0} />
|
|
42
|
+
<SwitchButton value={overchargeSwitch} onValueChange={async v => {
|
|
43
|
+
state.loading = true
|
|
44
|
+
await setOverchargeSwitch(v)
|
|
45
|
+
state.loading = false
|
|
46
|
+
} } />
|
|
47
|
+
</View>
|
|
48
|
+
</Page>)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
tipInfoContainer: {
|
|
53
|
+
flexDirection: 'row',
|
|
54
|
+
marginHorizontal: cx(24),
|
|
55
|
+
marginVertical: cx(10)
|
|
56
|
+
},
|
|
57
|
+
image: {
|
|
58
|
+
width: cx(16),
|
|
59
|
+
height: cx(16),
|
|
60
|
+
marginRight: cx(5),
|
|
61
|
+
tintColor: '#000'
|
|
62
|
+
},
|
|
63
|
+
titleBGView: {
|
|
64
|
+
flexDirection: 'row',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
paddingHorizontal: cx(16),
|
|
67
|
+
marginHorizontal: cx(24),
|
|
68
|
+
marginTop: cx(30)
|
|
69
|
+
},
|
|
70
|
+
colorBlock: {
|
|
71
|
+
width: cx(20),
|
|
72
|
+
height: cx(20),
|
|
73
|
+
marginStart: cx(12),
|
|
74
|
+
borderRadius: cx(4),
|
|
75
|
+
},
|
|
76
|
+
title: {
|
|
77
|
+
color: '#000',
|
|
78
|
+
fontSize: cx(14),
|
|
79
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
80
|
+
paddingVertical: cx(16),
|
|
81
|
+
},
|
|
82
|
+
shadow: {
|
|
83
|
+
shadowColor: '#000000',
|
|
84
|
+
shadowOpacity: 0.2,
|
|
85
|
+
shadowRadius: 8,
|
|
86
|
+
elevation:8,
|
|
87
|
+
shadowOffset: {
|
|
88
|
+
width: 0,
|
|
89
|
+
height: 4,
|
|
90
|
+
},
|
|
91
|
+
backgroundColor: '#fff',
|
|
92
|
+
borderRadius: 8,
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export default OverchargeSwitchPage
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import OverchargeSwitchPage from "./OverchargeSwitchPage";
|
|
3
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
4
|
+
|
|
5
|
+
const OverchargeSwitchPageRouters: NavigationRoute[] = [
|
|
6
|
+
{
|
|
7
|
+
name: ui_biz_routerKey.ui_biz_overcharge_switch,
|
|
8
|
+
component: OverchargeSwitchPage,
|
|
9
|
+
options:{
|
|
10
|
+
hideTopbar: true,
|
|
11
|
+
showOfflineView: false,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export default OverchargeSwitchPageRouters
|