@ledvance/ui-biz-bundle 1.1.56 → 1.1.58

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.
Files changed (70) hide show
  1. package/package.json +2 -1
  2. package/src/modules/biorhythm/Router.ts +34 -0
  3. package/src/modules/fixedTime/Router.ts +26 -0
  4. package/src/modules/flags/FlagInfo.tsx +25 -25
  5. package/src/modules/flags/FlagPage.tsx +1 -1
  6. package/src/modules/flags/Router.ts +25 -0
  7. package/src/modules/history/Router.ts +16 -0
  8. package/src/modules/mood/FantasyRouter.ts +35 -0
  9. package/src/modules/mood/MixMood/Router.ts +44 -0
  10. package/src/modules/mood/Router.ts +53 -0
  11. package/src/modules/music/Router.ts +16 -0
  12. package/src/modules/powerOnBehavior/Router.ts +16 -0
  13. package/src/modules/randomTime/Router.ts +25 -0
  14. package/src/modules/sleepWakeup/Router.ts +25 -0
  15. package/src/modules/timeSchedule/Router.ts +25 -0
  16. package/src/modules/timer/Router.ts +16 -0
  17. package/src/navigation/Routers.d.ts +0 -7
  18. package/src/navigation/Routers.ts +15 -304
  19. package/src/newModules/childLock/ChildLockPage.tsx +97 -0
  20. package/src/newModules/childLock/Router.ts +16 -0
  21. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
  22. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
  23. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
  24. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
  25. package/src/newModules/energyConsumption/Router.ts +34 -0
  26. package/src/newModules/energyConsumption/co2Data.ts +23655 -0
  27. package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
  28. package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
  29. package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
  30. package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
  31. package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
  32. package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
  33. package/src/newModules/fixedTime/Router.ts +25 -0
  34. package/src/newModules/lightMode/LightModePage.tsx +204 -0
  35. package/src/newModules/lightMode/Router.ts +16 -0
  36. package/src/newModules/mood/AddMoodPage.tsx +178 -0
  37. package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
  38. package/src/newModules/mood/Interface.ts +219 -0
  39. package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
  40. package/src/newModules/mood/MoodActions.ts +235 -0
  41. package/src/newModules/mood/MoodInfo.ts +2151 -0
  42. package/src/newModules/mood/MoodItem.tsx +148 -0
  43. package/src/newModules/mood/MoodPage.tsx +385 -0
  44. package/src/newModules/mood/MoodParse.ts +442 -0
  45. package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
  46. package/src/newModules/mood/Router.ts +53 -0
  47. package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
  48. package/src/newModules/mood/tools.ts +12 -0
  49. package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
  50. package/src/newModules/overchargeSwitch/Router.ts +16 -0
  51. package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
  52. package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
  53. package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
  54. package/src/newModules/powerOnBehavior/Router.ts +16 -0
  55. package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
  56. package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
  57. package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
  58. package/src/newModules/randomTime/Router.ts +25 -0
  59. package/src/newModules/randomTime/Summary.tsx +116 -0
  60. package/src/newModules/swithInching/Router.ts +16 -0
  61. package/src/newModules/swithInching/SwithInching.tsx +231 -0
  62. package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
  63. package/src/newModules/swithInching/pickerView.tsx +91 -0
  64. package/src/newModules/timeSchedule/Interface.ts +111 -0
  65. package/src/newModules/timeSchedule/Router.ts +25 -0
  66. package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
  67. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
  68. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
  69. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
  70. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
@@ -0,0 +1,662 @@
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
+ import {
3
+ FlatList,
4
+ Image,
5
+ ScrollView,
6
+ StyleSheet,
7
+ Text,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import { useNavigation } from '@react-navigation/core';
12
+ import Page from '@ledvance/base/src/components/Page';
13
+ import I18n from '@ledvance/base/src/i18n';
14
+ import TextField from '@ledvance/base/src/components/TextField';
15
+ import { cloneDeep, isEqual } from 'lodash';
16
+ import { useReactive } from 'ahooks';
17
+ import { SwitchButton, TimerPicker, Utils } from 'tuya-panel-kit';
18
+ import Spacer from '@ledvance/base/src/components/Spacer';
19
+ import LdvWeekView from '@ledvance/base/src/components/weekSelect';
20
+ import { convertTo12HourFormat, loopText, showDialog } from '@ledvance/base/src/utils/common';
21
+ import {
22
+ ApplyForItem,
23
+ ComponentConfig,
24
+ DeviceType,
25
+ TimeScheduleDetailState,
26
+ Timer,
27
+ TimerActions,
28
+ } from './Interface';
29
+ import res from '@ledvance/base/src/res';
30
+ import {
31
+ useDeviceId,
32
+ useMoods,
33
+ useSystemTimeFormate,
34
+ } from '@ledvance/base/src/models/modules/NativePropsSlice';
35
+ import { TimeSchedulePageParams } from './TimeSchedulePage';
36
+ import { Result } from '@ledvance/base/src/models/modules/Result';
37
+ import DeleteButton from '@ledvance/base/src/components/DeleteButton';
38
+ import InfoText from '@ledvance/base/src/components/InfoText';
39
+ import SegmentControl from '@ledvance/base/src/components/segmentControl';
40
+ // import { SceneMode } from "../mood/SceneInfo";
41
+ import { useParams } from '@ledvance/base/src/hooks/Hooks';
42
+ import ManualSettings from './components/ManuaSettings';
43
+ import { defDeviceData, defMixDeviceData, defStripDeviceData } from './TimeScheduleActions';
44
+ import MoodItem from '../mood/MoodItem';
45
+ import { getRemoteMoodList } from '../mood/MoodActions';
46
+ // import LoadingView from "@ledvance/base/src/components/LoadingView";
47
+
48
+ const { convertX: cx } = Utils.RatioUtils;
49
+ const { toFixedString } = Utils.NumberUtils;
50
+ interface TimeScheduleDetailPageParams extends TimeSchedulePageParams {
51
+ mode: 'add' | 'update';
52
+ timeSchedule: Timer;
53
+ modDeleteTimeSchedule: (mode: TimerActions, timeSchedule: Timer) => Promise<Result<any>>;
54
+ refreshFn: () => void;
55
+ }
56
+
57
+ const TimeScheduleDetailPage = () => {
58
+ const is24HourClock = useSystemTimeFormate();
59
+ const props = useParams<TimeScheduleDetailPageParams>();
60
+ const navigation = useNavigation();
61
+ const devId = useDeviceId();
62
+ const [moods, setMoods] = useMoods();
63
+ const state = useReactive<TimeScheduleDetailState>({
64
+ timeSchedule: props.mode === 'add' ? newTimeSchedule() : cloneDeep(props.timeSchedule),
65
+ dps: props.mode === 'add' ? {} : props.timeSchedule.dps,
66
+ isManual: true, // manual ,mood
67
+ initSelectedSkill: [] as ApplyForItem[],
68
+ selectedSkill: [] as ApplyForItem[],
69
+ unSelectedSkill: [] as ApplyForItem[],
70
+ loading: false,
71
+ moodLoading: false,
72
+ manualData:
73
+ props.mode === 'add'
74
+ ? getDefaultManual(props)
75
+ : props.manualDataDp2Obj(props.timeSchedule.dps).deviceData,
76
+ mood: undefined,
77
+ moods: cloneDeep(moods),
78
+ timerId: undefined,
79
+ moodName: '',
80
+ });
81
+
82
+ useEffect(() => {
83
+ const { applyForDisabled, timeSchedule, applyForList, mode } = props;
84
+ const cannotChoose = applyForDisabled || applyForList.length === 1;
85
+ const cloneApplyList =
86
+ mode === 'add'
87
+ ? cloneDeep(applyForList)
88
+ : cloneDeep(applyForList).map(item => {
89
+ if (props.isMixLight && state.manualData.type === DeviceType.MixLight) {
90
+ return {
91
+ ...item,
92
+ enable:
93
+ item.type === 'mainLight'
94
+ ? state.manualData.deviceData.whiteLightSwitch
95
+ : state.manualData.deviceData.colorLightSwitch,
96
+ };
97
+ }
98
+ if (timeSchedule?.dps?.hasOwnProperty(item.dp)) {
99
+ return {
100
+ ...item,
101
+ enable: timeSchedule?.dps[item.dp],
102
+ };
103
+ }
104
+ return item;
105
+ });
106
+
107
+ if (cannotChoose) {
108
+ state.selectedSkill = cloneApplyList;
109
+ state.unSelectedSkill = [];
110
+ } else {
111
+ const selectedList = cloneApplyList.filter(item =>
112
+ Object.keys(timeSchedule.dps).includes(item.dp)
113
+ );
114
+ const unSelectedList = cloneApplyList.filter(
115
+ item => !Object.keys(timeSchedule.dps).includes(item.dp)
116
+ );
117
+ state.selectedSkill = mode === 'add' ? [] : selectedList;
118
+ state.unSelectedSkill = mode === 'add' ? cloneApplyList : unSelectedList;
119
+ }
120
+ if (props.mode === 'update' && props.manualDataDp2Obj) {
121
+ const { isManual, mood } = props.manualDataDp2Obj(props.timeSchedule.dps);
122
+ state.isManual = isManual;
123
+ state.mood = mood;
124
+ }
125
+
126
+ state.initSelectedSkill = cloneDeep(state.selectedSkill)
127
+
128
+ if (!(Array.isArray(moods) && moods.length)) {
129
+ state.timerId = setTimeout(() => {
130
+ getRemoteMoodList(devId, props, props.featureId).then(res => {
131
+ if (res.success && Array.isArray(res.data)) {
132
+ state.moods = cloneDeep(res.data);
133
+ setMoods(cloneDeep(res.data));
134
+ if (!state.mood) state.mood = cloneDeep(res.data[0]);
135
+ }
136
+ });
137
+ }, 400);
138
+ return () => {
139
+ if (state.timerId) clearTimeout(state.timerId);
140
+ };
141
+ } else {
142
+ if (!state.mood) state.mood = cloneDeep(state.moods[0]);
143
+ }
144
+ }, []);
145
+
146
+ useEffect(() => {
147
+ if (state.moods?.length) {
148
+ state.moodName =
149
+ state.moods.find(m =>
150
+ props.isCeilingLight
151
+ ? m.mainLamp.id === state.mood?.mainLamp.id &&
152
+ m.secondaryLamp.id === state.mood?.secondaryLamp.id
153
+ : m.id === state.mood?.id
154
+ )?.name || '';
155
+ }
156
+ }, [state.mood, state.moods]);
157
+
158
+ const getFormateTime = useCallback((time: number | string) => {
159
+ if (typeof time === 'number') {
160
+ return `${toFixedString(Math.trunc(time / 60), 2)}:${toFixedString(time % 60, 2)}`;
161
+ }
162
+ if (typeof time === 'string') {
163
+ const t = time.split(':');
164
+ return Number(t[0]) * 60 + Number(t[1]);
165
+ }
166
+ return time;
167
+ }, []);
168
+
169
+ const isModify = useMemo(() => {
170
+ if (props.mode === 'add') {
171
+ return true
172
+ }
173
+
174
+ const schedule = props.timeSchedule;
175
+ const manual = props.manualDataDp2Obj(props.timeSchedule?.dps).deviceData;
176
+ const before = {
177
+ ...schedule,
178
+ selectedSkill: state.initSelectedSkill,
179
+ dps: manual,
180
+ isManual: props.manualDataDp2Obj(props.timeSchedule.dps).isManual,
181
+ mood: props.manualDataDp2Obj(props.timeSchedule?.dps).mood,
182
+ id: 1,
183
+ };
184
+
185
+ const now = {
186
+ ...state.timeSchedule,
187
+ selectedSkill: state.selectedSkill,
188
+ dps: state.manualData,
189
+ isManual: state.isManual,
190
+ mood: state.mood,
191
+ id: 1,
192
+ };
193
+ return !isEqual(before, now);
194
+ }, [JSON.stringify(state.timeSchedule), state.manualData, state.isManual, state.mood, JSON.stringify(state.selectedSkill)]);
195
+
196
+ const allowSubmit = useMemo(() => {
197
+ return (
198
+ !!(state.timeSchedule.name.length && state.timeSchedule.name.length < 33) &&
199
+ !!state.selectedSkill.length &&
200
+ (state.isManual ? true : state.mood) &&
201
+ isModify
202
+ );
203
+ }, [state.timeSchedule.name, state.selectedSkill, isModify, state.isManual, state.mood]);
204
+
205
+ const showSelectedIcon = useMemo(() => {
206
+ return state.selectedSkill.length !== 1 && !props.applyForDisabled;
207
+ }, [state.selectedSkill.length, props.applyForDisabled]);
208
+
209
+ return (
210
+ <Page
211
+ backText={I18n.getLang('motion_detection_add_time_schedule_system_back_text')}
212
+ headlineText={I18n.getLang(
213
+ props.mode === 'add'
214
+ ? 'motion_detection_add_time_schedule_headline_text'
215
+ : 'edit_timeschedule_headline_text'
216
+ )}
217
+ rightButtonIcon={allowSubmit ? res.ic_check : res.ic_uncheck}
218
+ rightButtonIconClick={async () => {
219
+ if (!allowSubmit || state.loading) return;
220
+ state.loading = true;
221
+ const res = await props.modDeleteTimeSchedule(props.mode, {
222
+ ...state.timeSchedule,
223
+ enable: true,
224
+ dps: props.manualDataObj2Dp(
225
+ {
226
+ deviceData: state.manualData,
227
+ isManual: state.isManual,
228
+ mood: state.mood,
229
+ },
230
+ state.selectedSkill
231
+ ),
232
+ });
233
+ console.log(res, '< ---- resss');
234
+ state.loading = false;
235
+ if (res.success) {
236
+ navigation.goBack();
237
+ }
238
+ }}
239
+ backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
240
+ backDialogContent={I18n.getLang('cancel_dialog_leave_unsaved_timeschedule_note')}
241
+ showBackDialog={!isModify}
242
+ loading={state.loading}
243
+ >
244
+ <ScrollView nestedScrollEnabled={true}>
245
+ <TextField
246
+ style={styles.cardContainer}
247
+ value={state.timeSchedule.name}
248
+ showError={state.timeSchedule.name?.length > 32}
249
+ maxLength={33}
250
+ errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
251
+ placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
252
+ onChangeText={(t: string) => {
253
+ state.timeSchedule.name = t;
254
+ }}
255
+ />
256
+
257
+ {/* pick */}
258
+ <TimerPicker
259
+ itemTextColor="#aeadb5"
260
+ style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
261
+ is12Hours={!is24HourClock}
262
+ singlePicker={true}
263
+ amText={I18n.getLang('manage_user_calendar_label_am')}
264
+ pmText={I18n.getLang('manage_user_calendar_label_pm')}
265
+ startTime={getFormateTime(state.timeSchedule.time) as number}
266
+ symbol={''}
267
+ onTimerChange={startTime => {
268
+ state.timeSchedule.time = getFormateTime(startTime) as string;
269
+ }}
270
+ />
271
+
272
+ <LdvWeekView
273
+ value={state.timeSchedule.loops.split('').map(Number)}
274
+ style={styles.cardContainer}
275
+ onSelect={(index: number) => {
276
+ const rawIndex = index - 1;
277
+ const weeks = state.timeSchedule.loops.split('');
278
+ weeks[rawIndex] = weeks[rawIndex] === '1' ? '0' : '1';
279
+ state.timeSchedule.loops = weeks.join('');
280
+ }}
281
+ />
282
+ <Spacer />
283
+ <Text style={styles.cardContainer}>{loopText(state.timeSchedule.loops.split(''))}</Text>
284
+ <Spacer height={cx(30)} />
285
+
286
+ {/* Apply for */}
287
+ <View style={styles.cardContainer}>
288
+ <Text style={styles.itemTitle}>
289
+ {I18n.getLang('timeschedule_add_schedule_subheadline_text')}
290
+ </Text>
291
+ <Spacer height={cx(10)} />
292
+ <View style={styles.applyContent}>
293
+ {props.applyForList.length === 0 ? (
294
+ <Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text>
295
+ ) : (
296
+ state.selectedSkill.map(skill => (
297
+ <View
298
+ style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}
299
+ key={skill.dp}
300
+ >
301
+ <Text style={{ color: '#000' }}>{skill.key}</Text>
302
+ {showSelectedIcon && (
303
+ <TouchableOpacity
304
+ onPress={() => {
305
+ state.selectedSkill = state.selectedSkill.filter(s => skill.dp !== s.dp);
306
+ state.unSelectedSkill = [...state.unSelectedSkill, skill];
307
+ }}
308
+ style={{ paddingHorizontal: cx(5) }}
309
+ >
310
+ <Image
311
+ style={{ width: cx(16), height: cx(16) }}
312
+ source={res.ic_arrows_nav_clear}
313
+ />
314
+ </TouchableOpacity>
315
+ )}
316
+ </View>
317
+ ))
318
+ )}
319
+ </View>
320
+ {state.unSelectedSkill.map((item: ApplyForItem) => {
321
+ return (
322
+ <TouchableOpacity
323
+ style={styles.applyItem}
324
+ key={item.dp}
325
+ onPress={() => {
326
+ state.selectedSkill = [...state.selectedSkill, item];
327
+ state.unSelectedSkill = state.unSelectedSkill.filter(s => item.dp !== s.dp);
328
+ }}
329
+ >
330
+ <Text style={{ color: '#000' }}>{item.key}</Text>
331
+ <Image
332
+ style={{ width: cx(16), height: cx(16) }}
333
+ source={res.device_panel_timer_add}
334
+ />
335
+ </TouchableOpacity>
336
+ );
337
+ })}
338
+ <Spacer />
339
+ </View>
340
+
341
+ {/* device state */}
342
+ <Text style={[styles.itemTitle, styles.cardContainer]}>
343
+ {I18n.getLang('timeschedule_add_schedule_subheadline2_text')}
344
+ </Text>
345
+ <Spacer height={cx(10)} />
346
+ {props.isSupportMood && (
347
+ <>
348
+ <SegmentControl
349
+ title1={I18n.getLang('timeschedule_add_schedule_switch_tab_manual_text')}
350
+ title2={I18n.getLang('timeschedule_add_schedule_switch_tab_mood_text')}
351
+ isFirst={state.isManual}
352
+ setIsFirst={(v: boolean) => (state.isManual = v)}
353
+ />
354
+ <Spacer height={cx(16)} />
355
+ </>
356
+ )}
357
+ <Spacer height={cx(10)} />
358
+ {state.isManual ? (
359
+ <ManualSettings
360
+ dps={state.dps}
361
+ applyForList={state.selectedSkill}
362
+ isSupportColor={props.isSupportColor}
363
+ isSupportBrightness={props.isSupportBrightness}
364
+ isSupportTemperature={props.isSupportTemperature}
365
+ isStripLight={props.isStripLight}
366
+ manualData={state.manualData}
367
+ onManualChange={manual => {
368
+ // @ts-ignore
369
+ state.manualData = {
370
+ ...state.manualData,
371
+ deviceData: cloneDeep(manual),
372
+ };
373
+ }}
374
+ onApplyChange={apply => {
375
+ state.selectedSkill = cloneDeep(apply);
376
+ }}
377
+ />
378
+ ) : (
379
+ <FlatList
380
+ data={state.moods}
381
+ renderItem={({ item }) => {
382
+ return (
383
+ <MoodItem
384
+ enable={state.mood?.id === item.id}
385
+ mood={item}
386
+ isMix={!!(props.isMixLight || props.isCeilingLight)}
387
+ onSwitch={_ => {
388
+ state.mood = item;
389
+ }}
390
+ />
391
+ );
392
+ }}
393
+ ListHeaderComponent={() => <Spacer height={cx(10)} />}
394
+ ItemSeparatorComponent={() => <Spacer />}
395
+ ListFooterComponent={() => <Spacer />}
396
+ keyExtractor={item => `${item.name}`}
397
+ />
398
+ // <ScrollView style={styles.moodScrollView} nestedScrollEnabled={true}>
399
+
400
+ // </ScrollView>
401
+ )}
402
+ <Spacer />
403
+
404
+ {/* settings */}
405
+ <Text style={[styles.itemTitle, styles.cardContainer]}>
406
+ {I18n.getLang('timeschedule_add_schedule_subheadline4_text')}
407
+ </Text>
408
+ <View style={[styles.switchButton, styles.cardContainer]}>
409
+ <Text style={styles.text}>{I18n.getLang('timeschedule_add_schedule_text2')}</Text>
410
+ <SwitchButton
411
+ value={state.timeSchedule.notification}
412
+ onValueChange={value => {
413
+ state.timeSchedule.notification = value;
414
+ }}
415
+ />
416
+ </View>
417
+ <Spacer />
418
+
419
+ {/* summary */}
420
+ <Text style={[styles.itemTitle, styles.cardContainer]}>
421
+ {I18n.getLang('add_sleepschedule_one_source_subheadline4_text')}
422
+ </Text>
423
+ <Spacer height={cx(10)} />
424
+ <View style={styles.summaryContainer}>
425
+ <InfoText
426
+ icon={res.summary_icon1}
427
+ text={I18n.getLang('feature_summary_frequency_headline')}
428
+ iconStyle={styles.summaryImg}
429
+ textStyle={styles.leftTitle}
430
+ style={styles.summaryLeft}
431
+ />
432
+ <View style={styles.summaryRight}>
433
+ <Text style={styles.rightItem}>
434
+ {loopText(state.timeSchedule.loops.split(''), state.timeSchedule.time)}
435
+ </Text>
436
+ </View>
437
+ </View>
438
+ <View style={styles.summaryContainer}>
439
+ <InfoText
440
+ icon={res.summary_icon2}
441
+ text={I18n.getLang('feature_summary_time_headline')}
442
+ iconStyle={styles.summaryImg}
443
+ textStyle={styles.leftTitle}
444
+ style={styles.summaryLeft}
445
+ />
446
+ <View style={styles.summaryRight}>
447
+ <Text style={styles.rightItem}>
448
+ {is24HourClock
449
+ ? state.timeSchedule.time
450
+ : convertTo12HourFormat(state.timeSchedule.time)}
451
+ </Text>
452
+ </View>
453
+ </View>
454
+ <View style={[styles.summaryContainer, { alignItems: 'flex-start' }]}>
455
+ <InfoText
456
+ icon={res.summary_icon3}
457
+ text={I18n.getLang('motion_detection_add_time_schedule_actions_text1')}
458
+ iconStyle={styles.summaryImg}
459
+ textStyle={styles.leftTitle}
460
+ style={styles.summaryLeft}
461
+ />
462
+ <View style={{ marginLeft: cx(16), flex: 1 }}>
463
+ {state.isManual
464
+ ? !!state.selectedSkill.length && (
465
+ <>
466
+ {!!state.selectedSkill.filter(skill => skill.enable).length && (
467
+ <>
468
+ <Text style={{ marginLeft: cx(5) }}>
469
+ {I18n.getLang('feature_summary_action_txt_1')}
470
+ </Text>
471
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
472
+ {state.selectedSkill
473
+ .filter(skill => skill.enable)
474
+ .map(item => (
475
+ <View
476
+ style={[
477
+ styles.summaryRight,
478
+ { marginLeft: cx(5), marginBottom: cx(5) },
479
+ ]}
480
+ key={item.dp}
481
+ >
482
+ <Text style={[styles.rightItem]}>{item.key}</Text>
483
+ </View>
484
+ ))}
485
+ </View>
486
+ </>
487
+ )}
488
+
489
+ {!!state.selectedSkill.filter(skill => !skill.enable).length && (
490
+ <>
491
+ <Text style={{ marginLeft: cx(5) }}>
492
+ {I18n.getLang('feature_summary_action_txt_2')}
493
+ </Text>
494
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
495
+ {state.selectedSkill
496
+ .filter(skill => !skill.enable)
497
+ .map(item => (
498
+ <View
499
+ style={[
500
+ styles.summaryRight,
501
+ { marginLeft: cx(5), marginBottom: cx(5) },
502
+ ]}
503
+ key={item.dp}
504
+ >
505
+ <Text style={[styles.rightItem]}>{item.key}</Text>
506
+ </View>
507
+ ))}
508
+ </View>
509
+ </>
510
+ )}
511
+ </>
512
+ )
513
+ : !!state.moodName && (
514
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
515
+ <View style={[styles.summaryRight, { marginLeft: cx(5) }]}>
516
+ <Text style={styles.rightItem}>{state.moodName}</Text>
517
+ </View>
518
+ </View>
519
+ )}
520
+ </View>
521
+ </View>
522
+ <Spacer height={cx(30)} />
523
+
524
+ {/* delete */}
525
+ {props.mode === 'update' && (
526
+ <View style={{ marginHorizontal: cx(24) }}>
527
+ <DeleteButton
528
+ text={I18n.getLang('edit_timeschedule_bttn_text')}
529
+ onPress={() => {
530
+ showDialog({
531
+ method: 'confirm',
532
+ title: I18n.getLang('cancel_dialog_delete_item_timeschedule_titel'),
533
+ subTitle: I18n.getLang('cancel_dialog_delete_item_timeschedule_description'),
534
+ onConfirm: async (_, { close }) => {
535
+ state.loading = true;
536
+ close();
537
+ const res = await props.modDeleteTimeSchedule('delete', state.timeSchedule);
538
+ state.loading = false;
539
+ if (res.success) {
540
+ navigation.goBack();
541
+ }
542
+ },
543
+ });
544
+ }}
545
+ />
546
+ <Spacer />
547
+ </View>
548
+ )}
549
+ </ScrollView>
550
+ </Page>
551
+ );
552
+ };
553
+
554
+ const newTimeSchedule = () => {
555
+ return {
556
+ enable: true,
557
+ loops: '0000000',
558
+ notification: false,
559
+ name: '',
560
+ time: `${toFixedString(new Date().getHours(), 2)}:${toFixedString(new Date().getMinutes(), 2)}`,
561
+ dps: {},
562
+ id: -1,
563
+ };
564
+ };
565
+
566
+ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig => {
567
+ const deviceType =
568
+ props.isStripLight || props.isCeilingLight
569
+ ? DeviceType.StripLight
570
+ : props.isMixLight
571
+ ? DeviceType.MixLight
572
+ : DeviceType.LightSource;
573
+ const deviceData =
574
+ deviceType === DeviceType.StripLight
575
+ ? defStripDeviceData
576
+ : deviceType === DeviceType.MixLight
577
+ ? defMixDeviceData
578
+ : defDeviceData;
579
+ // @ts-ignore
580
+ return {
581
+ type: deviceType,
582
+ deviceData: {
583
+ ...deviceData,
584
+ isColorMode: props.isSupportColor ? true : false,
585
+ },
586
+ };
587
+ };
588
+
589
+ const styles = StyleSheet.create({
590
+ cardContainer: {
591
+ marginHorizontal: cx(24),
592
+ },
593
+ itemTitle: {
594
+ color: '#000',
595
+ fontSize: cx(16),
596
+ fontWeight: 'bold',
597
+ fontFamily: 'helvetica_neue_lt_std_bd',
598
+ },
599
+ applyContent: {
600
+ backgroundColor: '#f6f6f6',
601
+ borderRadius: 4,
602
+ minHeight: cx(55),
603
+ flex: 1,
604
+ justifyContent: 'center',
605
+ paddingHorizontal: cx(10),
606
+ paddingTop: cx(10),
607
+ },
608
+ applyItem: {
609
+ paddingLeft: cx(5),
610
+ flexDirection: 'row',
611
+ justifyContent: 'space-between',
612
+ alignItems: 'center',
613
+ backgroundColor: '#fff',
614
+ height: cx(35),
615
+ },
616
+ moodScrollView: {
617
+ maxHeight: cx(500),
618
+ },
619
+ summaryContainer: {
620
+ flexDirection: 'row',
621
+ justifyContent: 'flex-start',
622
+ marginBottom: cx(10),
623
+ marginHorizontal: cx(24),
624
+ },
625
+ summaryImg: {
626
+ height: cx(12),
627
+ width: cx(12),
628
+ tintColor: '#000',
629
+ },
630
+ summaryLeft: {
631
+ flexDirection: 'row',
632
+ alignItems: 'center',
633
+ minWidth: cx(90),
634
+ },
635
+ leftTitle: {
636
+ fontSize: cx(14),
637
+ color: '#000',
638
+ marginTop: 0,
639
+ },
640
+ summaryRight: {
641
+ flexDirection: 'column',
642
+ marginLeft: cx(21),
643
+ backgroundColor: '#cbcbcb',
644
+ borderRadius: cx(16),
645
+ alignItems: 'center'
646
+ },
647
+ rightItem: {
648
+ paddingHorizontal: cx(12),
649
+ color: '#000',
650
+ },
651
+ switchButton: {
652
+ flexDirection: 'row',
653
+ alignItems: 'center',
654
+ justifyContent: 'space-between',
655
+ marginBottom: cx(10),
656
+ },
657
+ text: {
658
+ color: '#000',
659
+ },
660
+ });
661
+
662
+ export default TimeScheduleDetailPage;