@ledvance/ui-biz-bundle 1.1.62 → 1.1.64
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 +1 -1
- package/src/modules/timer/TimerPage.tsx +1 -1
- package/src/newModules/fixedTime/FixedTimeActions.ts +50 -44
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +40 -35
- package/src/newModules/fixedTime/FixedTimePage.tsx +158 -85
- package/src/newModules/powerOnBehavior/Router.ts +13 -2
- package/src/newModules/randomTime/RandomTimeActions.ts +57 -49
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +33 -29
- package/src/newModules/randomTime/RandomTimePage.tsx +152 -84
- package/src/newModules/timeSchedule/Interface.ts +34 -4
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +118 -133
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +79 -49
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +209 -9
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +28 -15
|
@@ -42,6 +42,8 @@ import ManualSettings from './components/ManuaSettings';
|
|
|
42
42
|
import { defDeviceData, defMixDeviceData, defStripDeviceData } from './TimeScheduleActions';
|
|
43
43
|
import MoodItem from '../mood/MoodItem';
|
|
44
44
|
import { getRemoteMoodList } from '../mood/MoodActions';
|
|
45
|
+
import { MoodUIInfo } from '@ledvance/ui-biz-bundle/src/newModules/mood/Interface';
|
|
46
|
+
import Summary from '@ledvance/base/src/components/Summary'
|
|
45
47
|
|
|
46
48
|
const { convertX: cx } = Utils.RatioUtils;
|
|
47
49
|
const { toFixedString } = Utils.NumberUtils;
|
|
@@ -54,7 +56,7 @@ interface TimeScheduleDetailPageParams extends TimeSchedulePageParams {
|
|
|
54
56
|
refreshFn: () => void;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
59
|
+
const TimeScheduleDetailPage = (props: { theme?: any }) => {
|
|
58
60
|
const is24HourClock = useSystemTimeFormate();
|
|
59
61
|
const params = useParams<TimeScheduleDetailPageParams>();
|
|
60
62
|
const navigation = useNavigation();
|
|
@@ -73,7 +75,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
73
75
|
params.mode === 'add'
|
|
74
76
|
? getDefaultManual(params)
|
|
75
77
|
: params.manualDataDp2Obj(params.timeSchedule.dps).deviceData,
|
|
76
|
-
mood: undefined,
|
|
78
|
+
mood: params.mode === 'add' ? undefined : params.manualDataDp2Obj(params.timeSchedule.dps)?.mood,
|
|
77
79
|
moods: cloneDeep(moods),
|
|
78
80
|
timerId: undefined,
|
|
79
81
|
moodName: '',
|
|
@@ -109,10 +111,10 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
109
111
|
state.unSelectedSkill = [];
|
|
110
112
|
} else {
|
|
111
113
|
const selectedList = cloneApplyList.filter(item =>
|
|
112
|
-
Object.keys(timeSchedule
|
|
114
|
+
Object.keys(timeSchedule?.dps || {}).includes(item.dp)
|
|
113
115
|
);
|
|
114
116
|
const unSelectedList = cloneApplyList.filter(
|
|
115
|
-
item => !Object.keys(timeSchedule
|
|
117
|
+
item => !Object.keys(timeSchedule?.dps || {}).includes(item.dp)
|
|
116
118
|
);
|
|
117
119
|
state.selectedSkill = mode === 'add' ? [] : selectedList;
|
|
118
120
|
state.unSelectedSkill = mode === 'add' ? cloneApplyList : unSelectedList;
|
|
@@ -134,7 +136,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
134
136
|
if (!state.mood) state.mood = cloneDeep(res.data[0]);
|
|
135
137
|
}
|
|
136
138
|
});
|
|
137
|
-
},
|
|
139
|
+
}, 250);
|
|
138
140
|
return () => {
|
|
139
141
|
if (state.timerId) clearTimeout(state.timerId);
|
|
140
142
|
};
|
|
@@ -167,18 +169,14 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
167
169
|
}, []);
|
|
168
170
|
|
|
169
171
|
const isModify = useMemo(() => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const schedule = params.timeSchedule;
|
|
175
|
-
const manual = params.manualDataDp2Obj(params.timeSchedule?.dps).deviceData;
|
|
172
|
+
const schedule = params.mode === 'add' ? newTimeSchedule() : params.timeSchedule;
|
|
173
|
+
const manual = params.mode === 'add' ? getDefaultManual(params) : params.manualDataDp2Obj(params.timeSchedule?.dps).deviceData;
|
|
176
174
|
const before = {
|
|
177
175
|
...schedule,
|
|
178
176
|
selectedSkill: state.initSelectedSkill,
|
|
179
177
|
dps: manual,
|
|
180
|
-
isManual: params.manualDataDp2Obj(params.timeSchedule.dps).isManual,
|
|
181
|
-
mood: params.manualDataDp2Obj(params.timeSchedule?.dps).mood,
|
|
178
|
+
isManual: params.mode === 'add' || params.manualDataDp2Obj(params.timeSchedule.dps).isManual,
|
|
179
|
+
mood: params.mode === 'add' ? undefined : params.manualDataDp2Obj(params.timeSchedule?.dps).mood,
|
|
182
180
|
id: 1,
|
|
183
181
|
};
|
|
184
182
|
|
|
@@ -187,24 +185,33 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
187
185
|
selectedSkill: state.selectedSkill,
|
|
188
186
|
dps: state.manualData,
|
|
189
187
|
isManual: state.isManual,
|
|
190
|
-
mood: state.mood,
|
|
188
|
+
mood: state.isManual ? undefined : state.mood,
|
|
191
189
|
id: 1,
|
|
192
190
|
};
|
|
193
|
-
return
|
|
191
|
+
return isEqual(before, now);
|
|
194
192
|
}, [JSON.stringify(state.timeSchedule), state.manualData, state.isManual, state.mood, JSON.stringify(state.selectedSkill)]);
|
|
195
193
|
|
|
194
|
+
const showMoodFanSelectText = useMemo(() => {
|
|
195
|
+
return (params.isUVCFan || params.isFanLight) && !state.isManual && state.selectedSkill.length < 2
|
|
196
|
+
}, [params.isUVCFan, params.isFanLight, state.selectedSkill.length, state.isManual])
|
|
197
|
+
|
|
196
198
|
const allowSubmit = useMemo(() => {
|
|
197
199
|
return (
|
|
198
200
|
!!(state.timeSchedule.name.length && state.timeSchedule.name.length < 33) &&
|
|
199
201
|
!!state.selectedSkill.length &&
|
|
200
|
-
(state.isManual
|
|
201
|
-
isModify
|
|
202
|
+
(state.isManual || !!state.mood) &&
|
|
203
|
+
!isModify &&
|
|
204
|
+
!showMoodFanSelectText
|
|
202
205
|
);
|
|
203
|
-
}, [state.timeSchedule.name, state.selectedSkill, isModify, state.isManual, state.mood]);
|
|
206
|
+
}, [state.timeSchedule.name, state.selectedSkill, isModify, state.isManual, state.mood, showMoodFanSelectText]);
|
|
204
207
|
|
|
205
208
|
const showSelectedIcon = useMemo(() => {
|
|
206
|
-
return
|
|
207
|
-
}, [
|
|
209
|
+
return params.applyForList.length !== 1 && !params.applyForDisabled;
|
|
210
|
+
}, [params.applyForList.length, params.applyForDisabled]);
|
|
211
|
+
|
|
212
|
+
const getMoodItemEnable = useCallback((item: MoodUIInfo) => {
|
|
213
|
+
return params.isCeilingLight ? ((item.mainLamp.id === state.mood?.mainLamp?.id) && (item.secondaryLamp.id === state.mood?.secondaryLamp?.id)) : item.id === state.mood?.id
|
|
214
|
+
}, [state.mood, params.isCeilingLight])
|
|
208
215
|
|
|
209
216
|
const styles = StyleSheet.create({
|
|
210
217
|
cardContainer: {
|
|
@@ -217,13 +224,13 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
217
224
|
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
218
225
|
},
|
|
219
226
|
applyContent: {
|
|
220
|
-
backgroundColor: props.theme.card.
|
|
227
|
+
backgroundColor: props.theme.card.board,
|
|
221
228
|
borderRadius: 4,
|
|
222
229
|
minHeight: cx(55),
|
|
223
230
|
flex: 1,
|
|
224
231
|
justifyContent: 'center',
|
|
225
|
-
paddingHorizontal: cx(10),
|
|
226
232
|
paddingTop: cx(10),
|
|
233
|
+
paddingHorizontal: cx(10),
|
|
227
234
|
},
|
|
228
235
|
applyItem: {
|
|
229
236
|
paddingLeft: cx(5),
|
|
@@ -259,14 +266,15 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
259
266
|
},
|
|
260
267
|
summaryRight: {
|
|
261
268
|
flexDirection: 'column',
|
|
262
|
-
marginLeft: cx(21),
|
|
263
269
|
backgroundColor: props.theme.card.background,
|
|
264
270
|
borderRadius: cx(16),
|
|
265
271
|
alignItems: 'center'
|
|
266
272
|
},
|
|
273
|
+
|
|
267
274
|
rightItem: {
|
|
268
275
|
paddingHorizontal: cx(12),
|
|
269
276
|
color: props.theme.global.fontColor,
|
|
277
|
+
fontSize: cx(14)
|
|
270
278
|
},
|
|
271
279
|
switchButton: {
|
|
272
280
|
flexDirection: 'row',
|
|
@@ -276,6 +284,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
276
284
|
},
|
|
277
285
|
text: {
|
|
278
286
|
color: props.theme.global.fontColor,
|
|
287
|
+
fontSize: cx(14)
|
|
279
288
|
},
|
|
280
289
|
});
|
|
281
290
|
|
|
@@ -354,7 +363,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
354
363
|
}}
|
|
355
364
|
/>
|
|
356
365
|
<Spacer />
|
|
357
|
-
<Text style={{...styles.cardContainer, color: props.theme.global.fontColor}}>{loopText(state.timeSchedule.loops.split(''))}</Text>
|
|
366
|
+
<Text style={{ ...styles.cardContainer, color: props.theme.global.fontColor, fontSize: cx(14) }}>{loopText(state.timeSchedule.loops.split(''))}</Text>
|
|
358
367
|
<Spacer height={cx(30)} />
|
|
359
368
|
|
|
360
369
|
{/* Apply for */}
|
|
@@ -363,8 +372,8 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
363
372
|
{I18n.getLang('timeschedule_add_schedule_subheadline_text')}
|
|
364
373
|
</Text>
|
|
365
374
|
<Spacer height={cx(10)} />
|
|
366
|
-
<View style={styles.applyContent}>
|
|
367
|
-
{
|
|
375
|
+
<View style={[styles.applyContent, { paddingTop: state.selectedSkill.length ? cx(10) : 0 }]}>
|
|
376
|
+
{state.selectedSkill.length === 0 ? (
|
|
368
377
|
<Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text>
|
|
369
378
|
) : (
|
|
370
379
|
state.selectedSkill.map(skill => (
|
|
@@ -372,7 +381,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
372
381
|
style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}
|
|
373
382
|
key={skill.dp}
|
|
374
383
|
>
|
|
375
|
-
<Text style={{ color: props.theme.global.fontColor }}>{skill.key}</Text>
|
|
384
|
+
<Text style={{ color: props.theme.global.fontColor, fontSize: cx(12) }}>{skill.key}</Text>
|
|
376
385
|
{showSelectedIcon && (
|
|
377
386
|
<TouchableOpacity
|
|
378
387
|
onPress={() => {
|
|
@@ -401,7 +410,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
401
410
|
state.unSelectedSkill = state.unSelectedSkill.filter(s => item.dp !== s.dp);
|
|
402
411
|
}}
|
|
403
412
|
>
|
|
404
|
-
<Text style={{ color: props.theme.global.fontColor }}>{item.key}</Text>
|
|
413
|
+
<Text style={{ color: props.theme.global.fontColor, fontSize: cx(12) }}>{item.key}</Text>
|
|
405
414
|
<Image
|
|
406
415
|
style={{ width: cx(16), height: cx(16) }}
|
|
407
416
|
source={res.device_panel_timer_add}
|
|
@@ -429,6 +438,20 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
429
438
|
</>
|
|
430
439
|
)}
|
|
431
440
|
<Spacer height={cx(10)} />
|
|
441
|
+
{(!state.selectedSkill.length && !showMoodFanSelectText) && <InfoText
|
|
442
|
+
style={{ marginHorizontal: cx(24) }}
|
|
443
|
+
icon={res.ic_warning_amber}
|
|
444
|
+
contentColor="#FF9500"
|
|
445
|
+
text={I18n.getLang('timeschedule_add_schedule_no_device_warning_text')}
|
|
446
|
+
textStyle={{fontSize: cx(12)}}
|
|
447
|
+
/>}
|
|
448
|
+
{showMoodFanSelectText && <InfoText
|
|
449
|
+
style={{ marginHorizontal: cx(24) }}
|
|
450
|
+
icon={res.ic_warning_amber}
|
|
451
|
+
contentColor="#FF9500"
|
|
452
|
+
text={I18n.getLang('timeschedule_add_schedule_devicestate_sec_warning_text')}
|
|
453
|
+
textStyle={{fontSize: cx(12)}}
|
|
454
|
+
/>}
|
|
432
455
|
{state.isManual ? (
|
|
433
456
|
<ManualSettings
|
|
434
457
|
dps={state.dps}
|
|
@@ -439,9 +462,9 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
439
462
|
isStripLight={params.isStripLight}
|
|
440
463
|
manualData={state.manualData}
|
|
441
464
|
onManualChange={manual => {
|
|
442
|
-
// @ts-ignore
|
|
443
465
|
state.manualData = {
|
|
444
466
|
...state.manualData,
|
|
467
|
+
// @ts-ignore
|
|
445
468
|
deviceData: cloneDeep(manual),
|
|
446
469
|
};
|
|
447
470
|
}}
|
|
@@ -450,16 +473,16 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
450
473
|
}}
|
|
451
474
|
/>
|
|
452
475
|
) : (
|
|
453
|
-
<FlatList
|
|
476
|
+
!showMoodFanSelectText ? <FlatList
|
|
454
477
|
data={state.moods}
|
|
455
478
|
renderItem={({ item }) => {
|
|
456
479
|
return (
|
|
457
480
|
<MoodItem
|
|
458
|
-
enable={
|
|
481
|
+
enable={getMoodItemEnable(item)}
|
|
459
482
|
mood={item}
|
|
460
483
|
isMix={!!(params.isMixLight || params.isCeilingLight)}
|
|
461
484
|
onSwitch={_ => {
|
|
462
|
-
state.mood = item;
|
|
485
|
+
state.mood = cloneDeep(item);
|
|
463
486
|
}}
|
|
464
487
|
/>
|
|
465
488
|
);
|
|
@@ -468,10 +491,7 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
468
491
|
ItemSeparatorComponent={() => <Spacer />}
|
|
469
492
|
ListFooterComponent={() => <Spacer />}
|
|
470
493
|
keyExtractor={item => `${item.name}`}
|
|
471
|
-
/>
|
|
472
|
-
// <ScrollView style={styles.moodScrollView} nestedScrollEnabled={true}>
|
|
473
|
-
|
|
474
|
-
// </ScrollView>
|
|
494
|
+
/> : <View></View>
|
|
475
495
|
)}
|
|
476
496
|
<Spacer />
|
|
477
497
|
|
|
@@ -491,108 +511,71 @@ const TimeScheduleDetailPage = (props: {theme?: any}) => {
|
|
|
491
511
|
<Spacer />
|
|
492
512
|
|
|
493
513
|
{/* summary */}
|
|
494
|
-
<
|
|
495
|
-
{
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
<
|
|
500
|
-
icon={res.summary_icon1}
|
|
501
|
-
text={I18n.getLang('feature_summary_frequency_headline')}
|
|
502
|
-
iconStyle={styles.summaryImg}
|
|
503
|
-
textStyle={styles.leftTitle}
|
|
504
|
-
style={styles.summaryLeft}
|
|
505
|
-
/>
|
|
506
|
-
<View style={styles.summaryRight}>
|
|
507
|
-
<Text style={styles.rightItem}>
|
|
508
|
-
{loopText(state.timeSchedule.loops.split(''), state.timeSchedule.time)}
|
|
509
|
-
</Text>
|
|
510
|
-
</View>
|
|
511
|
-
</View>
|
|
512
|
-
<View style={styles.summaryContainer}>
|
|
513
|
-
<InfoText
|
|
514
|
-
icon={res.summary_icon2}
|
|
515
|
-
text={I18n.getLang('feature_summary_time_headline')}
|
|
516
|
-
iconStyle={styles.summaryImg}
|
|
517
|
-
textStyle={styles.leftTitle}
|
|
518
|
-
style={styles.summaryLeft}
|
|
519
|
-
/>
|
|
520
|
-
<View style={styles.summaryRight}>
|
|
521
|
-
<Text style={styles.rightItem}>
|
|
522
|
-
{is24HourClock
|
|
523
|
-
? state.timeSchedule.time
|
|
524
|
-
: convertTo12HourFormat(state.timeSchedule.time)}
|
|
525
|
-
</Text>
|
|
526
|
-
</View>
|
|
527
|
-
</View>
|
|
528
|
-
<View style={[styles.summaryContainer, { alignItems: 'flex-start' }]}>
|
|
529
|
-
<InfoText
|
|
530
|
-
icon={res.summary_icon3}
|
|
531
|
-
text={I18n.getLang('motion_detection_add_time_schedule_actions_text1')}
|
|
532
|
-
iconStyle={styles.summaryImg}
|
|
533
|
-
textStyle={styles.leftTitle}
|
|
534
|
-
style={styles.summaryLeft}
|
|
535
|
-
/>
|
|
536
|
-
<View style={{ marginLeft: cx(16), flex: 1 }}>
|
|
514
|
+
<Summary
|
|
515
|
+
frequency={loopText(state.timeSchedule.loops.split(''), state.timeSchedule.time)}
|
|
516
|
+
time={is24HourClock
|
|
517
|
+
? state.timeSchedule.time
|
|
518
|
+
: convertTo12HourFormat(state.timeSchedule.time)}
|
|
519
|
+
actions={<View style={{ flex: 1 }}>
|
|
537
520
|
{state.isManual
|
|
538
521
|
? !!state.selectedSkill.length && (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
522
|
+
<>
|
|
523
|
+
{!!state.selectedSkill.filter(skill => skill.enable).length && (
|
|
524
|
+
<>
|
|
525
|
+
<Text style={{ fontSize: cx(14), color: '#000' }}>
|
|
526
|
+
{I18n.getLang('feature_summary_action_txt_1')}
|
|
527
|
+
</Text>
|
|
528
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
529
|
+
{state.selectedSkill
|
|
530
|
+
.filter(skill => skill.enable)
|
|
531
|
+
.map(item => (
|
|
532
|
+
<View
|
|
533
|
+
style={[
|
|
534
|
+
styles.summaryRight,
|
|
535
|
+
{ marginRight: cx(5), marginBottom: cx(5) },
|
|
536
|
+
]}
|
|
537
|
+
key={item.dp}
|
|
538
|
+
>
|
|
539
|
+
<Text style={[styles.rightItem]}>{item.key}</Text>
|
|
540
|
+
</View>
|
|
541
|
+
))}
|
|
542
|
+
</View>
|
|
543
|
+
</>
|
|
544
|
+
)}
|
|
562
545
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
546
|
+
{!!state.selectedSkill.filter(skill => !skill.enable).length && (
|
|
547
|
+
<>
|
|
548
|
+
<Text style={{ fontSize: cx(14) }}>
|
|
549
|
+
{I18n.getLang('feature_summary_action_txt_2')}
|
|
550
|
+
</Text>
|
|
551
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
552
|
+
{state.selectedSkill
|
|
553
|
+
.filter(skill => !skill.enable)
|
|
554
|
+
.map((item) => (
|
|
555
|
+
<View
|
|
556
|
+
style={[
|
|
557
|
+
styles.summaryRight,
|
|
558
|
+
{ marginRight: cx(5), marginBottom: cx(5) },
|
|
559
|
+
]}
|
|
560
|
+
key={item.dp}
|
|
561
|
+
>
|
|
562
|
+
<Text style={[styles.rightItem]}>{item.key}</Text>
|
|
563
|
+
</View>
|
|
564
|
+
))}
|
|
565
|
+
</View>
|
|
566
|
+
</>
|
|
567
|
+
)}
|
|
568
|
+
</>
|
|
569
|
+
)
|
|
587
570
|
: !!state.moodName && (
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
571
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
572
|
+
<View style={[styles.summaryRight, { marginLeft: cx(5) }]}>
|
|
573
|
+
<Text style={styles.rightItem}>{state.moodName}</Text>
|
|
574
|
+
</View>
|
|
591
575
|
</View>
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
</View>
|
|
576
|
+
)}
|
|
577
|
+
</View>}
|
|
578
|
+
/>
|
|
596
579
|
<Spacer height={cx(30)} />
|
|
597
580
|
|
|
598
581
|
{/* delete */}
|
|
@@ -643,6 +626,8 @@ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig
|
|
|
643
626
|
? DeviceType.StripLight
|
|
644
627
|
: props.isMixLight
|
|
645
628
|
? DeviceType.MixLight
|
|
629
|
+
: props.isPowerStrip
|
|
630
|
+
? DeviceType.PowerStrip
|
|
646
631
|
: DeviceType.LightSource;
|
|
647
632
|
const deviceData =
|
|
648
633
|
deviceType === DeviceType.StripLight
|
|
@@ -19,6 +19,8 @@ import { getTimeSchedule, manageTimeSchedule } from './TimeScheduleActions';
|
|
|
19
19
|
import { useParams } from '@ledvance/base/src/hooks/Hooks';
|
|
20
20
|
import ScheduleCard from './components/ScheduleCard';
|
|
21
21
|
import { ui_biz_routerKey } from '../../navigation/Routers';
|
|
22
|
+
import Tag from '@ledvance/base/src/components/Tag';
|
|
23
|
+
import { cloneDeep } from 'lodash';
|
|
22
24
|
|
|
23
25
|
const { convertX: cx } = Utils.RatioUtils;
|
|
24
26
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -34,26 +36,17 @@ export interface TimeSchedulePageParams {
|
|
|
34
36
|
isMatterLight?: boolean;
|
|
35
37
|
isCeilingLight?: boolean;
|
|
36
38
|
isMixLight?: boolean;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
switchFan?: string;
|
|
41
|
-
fanModeCode?: string;
|
|
42
|
-
fanSpeedCode?: string;
|
|
43
|
-
workModeCode: string;
|
|
44
|
-
brightValueCode?: string;
|
|
39
|
+
isFanLight?: boolean;
|
|
40
|
+
isUVCFan?: boolean;
|
|
41
|
+
isPowerStrip?: boolean
|
|
45
42
|
featureId?: string
|
|
46
43
|
applyForList: ApplyForItem[];
|
|
47
44
|
applyForDisabled: boolean; // 是否可以选择apply for
|
|
48
45
|
manualDataDp2Obj: (dps: Record<string, any>) => DeviceStateType;
|
|
49
46
|
manualDataObj2Dp: (deviceState: DeviceStateType, applyForList: ApplyForItem[]) => Record<string, any>;
|
|
50
|
-
tempValueCode?: string;
|
|
51
|
-
sceneDataCode?: string;
|
|
52
|
-
colorDataCode?: string;
|
|
53
|
-
drawToolDataCode?: string;
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
const TimeSchedulePage = (props: {theme?: any}) => {
|
|
49
|
+
const TimeSchedulePage = (props: { theme?: any }) => {
|
|
57
50
|
const deviceInfo = useDeviceInfo();
|
|
58
51
|
const devId = useDeviceId();
|
|
59
52
|
const navigation = useNavigation();
|
|
@@ -61,42 +54,53 @@ const TimeSchedulePage = (props: {theme?: any}) => {
|
|
|
61
54
|
const params = useParams<TimeSchedulePageParams>();
|
|
62
55
|
const state = useReactive({
|
|
63
56
|
timeScheduleList: [] as Timer[],
|
|
57
|
+
originList: [] as Timer[],
|
|
64
58
|
flag: Symbol(),
|
|
65
59
|
loading: false,
|
|
60
|
+
checkTags: params.applyForList.map(v => ({ ...v, enable: false }))
|
|
66
61
|
});
|
|
67
62
|
|
|
68
|
-
const isMaxSchedule = useMemo(() => state.
|
|
69
|
-
state.
|
|
63
|
+
const isMaxSchedule = useMemo(() => state.originList.length >= MAX_NUM, [
|
|
64
|
+
state.originList,
|
|
70
65
|
]);
|
|
71
66
|
|
|
72
67
|
useUpdateEffect(() => {
|
|
73
|
-
const status = state.
|
|
68
|
+
const status = state.originList.some(item => item.enable);
|
|
74
69
|
if (status !== timeScheduleStatus) {
|
|
75
70
|
setTimeScheduleStatus(status);
|
|
76
71
|
}
|
|
77
|
-
}, [JSON.stringify(state.
|
|
72
|
+
}, [JSON.stringify(state.originList)]);
|
|
78
73
|
|
|
79
74
|
useEffect(() => {
|
|
80
75
|
getTimeSchedule(devId).then(res => {
|
|
81
|
-
state.
|
|
76
|
+
state.originList = cloneDeep(res)
|
|
82
77
|
});
|
|
83
78
|
}, [state.flag]);
|
|
84
79
|
|
|
80
|
+
useUpdateEffect(() => {
|
|
81
|
+
const isAll = state.checkTags.every(tag => tag.enable) || state.checkTags.every(tag => !tag.enable)
|
|
82
|
+
const checkedList = state.originList.filter(item => {
|
|
83
|
+
const checked = state.checkTags.find(tag => tag.enable && item.dps.hasOwnProperty(tag.dp))
|
|
84
|
+
return isAll || !!checked
|
|
85
|
+
})
|
|
86
|
+
state.timeScheduleList = cloneDeep(checkedList)
|
|
87
|
+
}, [JSON.stringify(state.checkTags), JSON.stringify(state.originList)])
|
|
88
|
+
|
|
85
89
|
const modDeleteTimeSchedule = async (mode: TimerActions, timeSchedule: Timer) => {
|
|
86
90
|
const res = await manageTimeSchedule(devId, timeSchedule, mode);
|
|
87
91
|
if (res.success) {
|
|
88
92
|
if (mode === 'add') {
|
|
89
93
|
state.flag = Symbol();
|
|
90
94
|
} else {
|
|
91
|
-
state.
|
|
95
|
+
state.originList =
|
|
92
96
|
mode === 'update'
|
|
93
|
-
? state.
|
|
97
|
+
? state.originList.map(item => {
|
|
94
98
|
if (item.id === timeSchedule.id) {
|
|
95
99
|
return timeSchedule;
|
|
96
100
|
}
|
|
97
101
|
return item;
|
|
98
102
|
})
|
|
99
|
-
: state.
|
|
103
|
+
: state.originList.filter(item => item.id !== timeSchedule.id);
|
|
100
104
|
}
|
|
101
105
|
return {
|
|
102
106
|
success: true,
|
|
@@ -139,8 +143,32 @@ const TimeSchedulePage = (props: {theme?: any}) => {
|
|
|
139
143
|
paddingHorizontal: cx(16),
|
|
140
144
|
backgroundColor: props.theme.button.active,
|
|
141
145
|
},
|
|
146
|
+
categoryList: {
|
|
147
|
+
display: 'flex',
|
|
148
|
+
flexDirection: 'row',
|
|
149
|
+
flexWrap: 'wrap',
|
|
150
|
+
marginHorizontal: cx(24),
|
|
151
|
+
alignSelf: 'flex-start'
|
|
152
|
+
},
|
|
142
153
|
});
|
|
143
154
|
|
|
155
|
+
const showTags = useMemo(() => (
|
|
156
|
+
<View style={styles.categoryList}>
|
|
157
|
+
{state.checkTags.map((tag, idx) => (
|
|
158
|
+
<Tag
|
|
159
|
+
key={tag.key}
|
|
160
|
+
text={tag.key}
|
|
161
|
+
checked={tag.enable}
|
|
162
|
+
onCheckedChange={(v) => {
|
|
163
|
+
state.checkTags[idx].enable = v
|
|
164
|
+
state.checkTags = cloneDeep(state.checkTags)
|
|
165
|
+
}}
|
|
166
|
+
style={{ marginRight: cx(5), marginBottom: cx(5) }}
|
|
167
|
+
/>
|
|
168
|
+
))}
|
|
169
|
+
</View>
|
|
170
|
+
), [state.checkTags])
|
|
171
|
+
|
|
144
172
|
return (
|
|
145
173
|
<Page
|
|
146
174
|
backText={deviceInfo.name}
|
|
@@ -166,11 +194,14 @@ const TimeSchedulePage = (props: {theme?: any}) => {
|
|
|
166
194
|
iconStyle={{ tintColor: props.theme.global.warning }}
|
|
167
195
|
/>
|
|
168
196
|
)}
|
|
169
|
-
|
|
197
|
+
{params.applyForList.length > 1 && !!state.originList.length && showTags}
|
|
198
|
+
{state.timeScheduleList.length > 0 ? <FlatList
|
|
170
199
|
data={state.timeScheduleList}
|
|
171
200
|
renderItem={({ item }) => (
|
|
172
201
|
<ScheduleCard
|
|
173
202
|
item={item}
|
|
203
|
+
tags={params.applyForList}
|
|
204
|
+
showTag={params.applyForList.length > 1}
|
|
174
205
|
onEnableChange={async enable => {
|
|
175
206
|
state.loading = true;
|
|
176
207
|
await modDeleteTimeSchedule('update', {
|
|
@@ -185,36 +216,35 @@ const TimeSchedulePage = (props: {theme?: any}) => {
|
|
|
185
216
|
/>
|
|
186
217
|
)}
|
|
187
218
|
keyExtractor={item => item.id.toString()}
|
|
188
|
-
ListEmptyComponent={
|
|
189
|
-
<View style={styles.emptyContainer}>
|
|
190
|
-
<Spacer height={cx(60)} />
|
|
191
|
-
<Image
|
|
192
|
-
style={styles.emptyImage}
|
|
193
|
-
source={{ uri: res.ldv_timer_empty }}
|
|
194
|
-
resizeMode="contain"
|
|
195
|
-
/>
|
|
196
|
-
<InfoText
|
|
197
|
-
icon={res.device_panel_schedule_alert}
|
|
198
|
-
text={I18n.getLang('timeschedule_overview_empty_information_text')}
|
|
199
|
-
style={{ width: 'auto', alignItems: 'center' }}
|
|
200
|
-
textStyle={{ color: props.theme.global.fontColor, flex: undefined }}
|
|
201
|
-
iconStyle={{ tintColor: props.theme.global.fontColor }}
|
|
202
|
-
/>
|
|
203
|
-
<Spacer height={cx(16)} />
|
|
204
|
-
<DeleteButton
|
|
205
|
-
style={styles.addBtn}
|
|
206
|
-
text={`${I18n.getLang('timeschedule_overview_empty_button_add_text')}`}
|
|
207
|
-
textStyle={{ fontSize: cx(12) }}
|
|
208
|
-
onPress={() => {
|
|
209
|
-
navigateToEdit('add');
|
|
210
|
-
}}
|
|
211
|
-
/>
|
|
212
|
-
</View>
|
|
213
|
-
)}
|
|
219
|
+
ListEmptyComponent={<Spacer />}
|
|
214
220
|
ListHeaderComponent={() => <Spacer height={cx(10)} />}
|
|
215
221
|
ItemSeparatorComponent={() => <Spacer />}
|
|
216
222
|
ListFooterComponent={() => <Spacer height={cx(30)} />}
|
|
217
|
-
/>
|
|
223
|
+
/> :
|
|
224
|
+
<View style={styles.emptyContainer}>
|
|
225
|
+
<Spacer height={cx(60)} />
|
|
226
|
+
<Image
|
|
227
|
+
style={styles.emptyImage}
|
|
228
|
+
source={{ uri: res.ldv_timer_empty }}
|
|
229
|
+
resizeMode="contain"
|
|
230
|
+
/>
|
|
231
|
+
<InfoText
|
|
232
|
+
icon={res.device_panel_schedule_alert}
|
|
233
|
+
text={I18n.getLang(!state.originList.length ? 'timeschedule_overview_empty_information_text' : 'sleepwakeschedule_empty_filtering_information_text')}
|
|
234
|
+
style={{ width: 'auto', alignItems: 'center' }}
|
|
235
|
+
textStyle={{ color: props.theme.global.fontColor, flex: undefined }}
|
|
236
|
+
iconStyle={{ tintColor: props.theme.global.fontColor }}
|
|
237
|
+
/>
|
|
238
|
+
<Spacer height={cx(16)} />
|
|
239
|
+
{!state.originList.length && <DeleteButton
|
|
240
|
+
style={styles.addBtn}
|
|
241
|
+
text={`${I18n.getLang('timeschedule_overview_empty_button_add_text')}`}
|
|
242
|
+
textStyle={{ fontSize: cx(12) }}
|
|
243
|
+
onPress={() => {
|
|
244
|
+
navigateToEdit('add');
|
|
245
|
+
}}
|
|
246
|
+
/>}
|
|
247
|
+
</View>}
|
|
218
248
|
</ScrollView>
|
|
219
249
|
</Page>
|
|
220
250
|
);
|