@ledvance/ui-biz-bundle 1.0.76 → 1.0.78
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/mood/FantasyMood.tsx +4 -2
- package/src/modules/music/MusicDataBean.ts +2 -2
- package/src/modules/scene/SceneAction.ts +26 -0
- package/src/modules/scene/SceneInfo.ts +44 -44
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +1 -1
- package/src/modules/timer/TimerPage.tsx +17 -27
- package/src/modules/timer/TimerPageAction.ts +44 -16
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import Spacer from '@ledvance/base/src/components/Spacer'
|
|
|
12
12
|
import FantasyMoodItem from './FantasyMoodItem'
|
|
13
13
|
import { useNavigation, useRoute } from '@react-navigation/core'
|
|
14
14
|
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
15
|
+
import { SCENE, useWorkMode } from 'hooks/DeviceDpStateHooks'
|
|
15
16
|
const cx = Utils.RatioUtils.convertX
|
|
16
17
|
|
|
17
18
|
interface MoodPageUIState extends StripScenePageUIState {
|
|
@@ -41,6 +42,7 @@ const FantasyMoodPage = () => {
|
|
|
41
42
|
...routeParams,
|
|
42
43
|
}
|
|
43
44
|
const [sceneId, setScene] = useFantasyScene(params.sceneDpCode, params.workModeDpCode, params.isStringLight)
|
|
45
|
+
const [workMode] = useWorkMode(params.workModeDpCode)
|
|
44
46
|
const deviceInfo = useDeviceInfo()
|
|
45
47
|
const navigation = useNavigation()
|
|
46
48
|
|
|
@@ -81,8 +83,8 @@ const FantasyMoodPage = () => {
|
|
|
81
83
|
}, [])
|
|
82
84
|
|
|
83
85
|
const getSwitchEnable = useCallback((id: number) => {
|
|
84
|
-
return state.currentScene?.id === id
|
|
85
|
-
}, [state.currentScene?.id])
|
|
86
|
+
return state.currentScene?.id === id && workMode === SCENE
|
|
87
|
+
}, [state.currentScene?.id, workMode])
|
|
86
88
|
|
|
87
89
|
return (
|
|
88
90
|
<>
|
|
@@ -144,13 +144,13 @@ export type DreamMusicDataType = {
|
|
|
144
144
|
{
|
|
145
145
|
id: 4,
|
|
146
146
|
mode: 0,
|
|
147
|
-
title:
|
|
147
|
+
title: Strings.getLang('devicemusic_classical_text'),
|
|
148
148
|
value: '0101020064320100006400006400786400f064003c6400b464012c64'
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
id: 5,
|
|
152
152
|
mode: 0,
|
|
153
|
-
title:
|
|
153
|
+
title: Strings.getLang('devicemusic_techno_text'),
|
|
154
154
|
value: '0101031064320100006400006400786400f064003c6400b464012c64000000'
|
|
155
155
|
}
|
|
156
156
|
]
|
|
@@ -272,8 +272,34 @@ export async function saveScene(
|
|
|
272
272
|
return await setRemoteSceneList(deviceId, newScenes)
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
const getDefaultScene = () => {
|
|
276
|
+
return {
|
|
277
|
+
version: 0,
|
|
278
|
+
// 场景号
|
|
279
|
+
id: -1,
|
|
280
|
+
// 变化方式
|
|
281
|
+
mode: 0,
|
|
282
|
+
// 速度
|
|
283
|
+
speed: 0,
|
|
284
|
+
// 段落 0 全段, 1 分段
|
|
285
|
+
segmented: 0,
|
|
286
|
+
// 循环 0 不循环, 1 循环
|
|
287
|
+
loop: 0,
|
|
288
|
+
// 过渡 0 不过渡, 1 过渡
|
|
289
|
+
excessive: 0,
|
|
290
|
+
// 拓展 other
|
|
291
|
+
expand: 0,
|
|
292
|
+
// 方向 0 顺时针方向, 1 逆时针方向
|
|
293
|
+
direction: 0,
|
|
294
|
+
// 设置 目前灯用不上
|
|
295
|
+
reserved1: 0,
|
|
296
|
+
reserved2: 0,
|
|
297
|
+
nodes: []
|
|
298
|
+
}
|
|
299
|
+
}
|
|
275
300
|
|
|
276
301
|
export function stripDp2Obj(dp: string, isStringLight: boolean = false): StripSceneInfo {
|
|
302
|
+
if (!dp) return getDefaultScene()
|
|
277
303
|
const version = hex2Int(dp.slice(0, 2))
|
|
278
304
|
const id = hex2Int(dp.slice(2, 4))
|
|
279
305
|
const mode = hex2Int(dp.slice(4, 6))
|
|
@@ -515,308 +515,308 @@ function getStringLightSceneList(): RemoteSceneInfo[] {
|
|
|
515
515
|
function getStripLightSceneList(): RemoteSceneInfo[] {
|
|
516
516
|
return [
|
|
517
517
|
{
|
|
518
|
-
n: '
|
|
518
|
+
n: I18n.getLang('strip_lights_mood_text1'),
|
|
519
519
|
i: '01150a5252e000006400c16100b43000b55200c463',
|
|
520
520
|
s: '',
|
|
521
521
|
t: 0,
|
|
522
522
|
e: false,
|
|
523
523
|
},
|
|
524
524
|
{
|
|
525
|
-
n: '
|
|
525
|
+
n: I18n.getLang('strip_lights_mood_text2'),
|
|
526
526
|
i: '01160a64646000006400925f00c660',
|
|
527
527
|
s: '',
|
|
528
528
|
t: 0,
|
|
529
529
|
e: false,
|
|
530
530
|
},
|
|
531
531
|
{
|
|
532
|
-
n: '
|
|
532
|
+
n: I18n.getLang('strip_lights_mood_text3'),
|
|
533
533
|
i: '0117035e5e6000006400382f001e5c00d545011a64',
|
|
534
534
|
s: '',
|
|
535
535
|
t: 0,
|
|
536
536
|
e: false,
|
|
537
537
|
},
|
|
538
538
|
{
|
|
539
|
-
n: '
|
|
539
|
+
n: I18n.getLang('strip_lights_mood_text4'),
|
|
540
540
|
i: '0118026464e000006400b239010a64012d64013f64',
|
|
541
541
|
s: '',
|
|
542
542
|
t: 0,
|
|
543
543
|
e: false
|
|
544
544
|
},
|
|
545
545
|
{
|
|
546
|
-
n: '
|
|
546
|
+
n: I18n.getLang('strip_lights_mood_text5'),
|
|
547
547
|
i: '01190a54546000006400b12c00c064',
|
|
548
548
|
s: '',
|
|
549
549
|
t: 0,
|
|
550
550
|
e: false,
|
|
551
551
|
},
|
|
552
552
|
{
|
|
553
|
-
n: '
|
|
553
|
+
n: I18n.getLang('strip_lights_mood_text6'),
|
|
554
554
|
i: '011a034b4be000006400e039010953',
|
|
555
555
|
s: '',
|
|
556
556
|
t: 0,
|
|
557
557
|
e: false,
|
|
558
558
|
},
|
|
559
559
|
{
|
|
560
|
-
n: '
|
|
560
|
+
n: I18n.getLang('strip_lights_mood_text7'),
|
|
561
561
|
i: '011b035f5f6000006400ae3900c45d00f964',
|
|
562
562
|
s: '',
|
|
563
563
|
t: 0,
|
|
564
564
|
e: false,
|
|
565
565
|
},
|
|
566
566
|
{
|
|
567
|
-
n: '
|
|
567
|
+
n: I18n.getLang('strip_lights_mood_text8'),
|
|
568
568
|
i: '011c0a5a5ae0000052009d64008e64',
|
|
569
569
|
s: '',
|
|
570
570
|
t: 0,
|
|
571
571
|
e: false,
|
|
572
572
|
},
|
|
573
573
|
{
|
|
574
|
-
n: '
|
|
574
|
+
n: I18n.getLang('strip_lights_mood_text9'),
|
|
575
575
|
i: '011d035252e000006400ae6400a66400c16400cc64',
|
|
576
576
|
s: '',
|
|
577
577
|
t: 0,
|
|
578
578
|
e: false,
|
|
579
579
|
},
|
|
580
580
|
{
|
|
581
|
-
n: '
|
|
581
|
+
n: I18n.getLang('strip_lights_mood_text10'),
|
|
582
582
|
i: '011e0a5252e000006400196400225e002c5b001464000c64',
|
|
583
583
|
s: '',
|
|
584
584
|
t: 0,
|
|
585
585
|
e: false,
|
|
586
586
|
},
|
|
587
587
|
{
|
|
588
|
-
n: '
|
|
588
|
+
n: I18n.getLang('strip_lights_mood_text11'),
|
|
589
589
|
i: '0147054d4d0000006401034500c143',
|
|
590
590
|
s: '',
|
|
591
591
|
t: 0,
|
|
592
592
|
e: false,
|
|
593
593
|
},
|
|
594
594
|
{
|
|
595
|
-
n: '
|
|
595
|
+
n: I18n.getLang('strip_lights_mood_text12'),
|
|
596
596
|
i: '014806323200000064014e41001f49',
|
|
597
597
|
s: '',
|
|
598
598
|
t: 0,
|
|
599
599
|
e: false,
|
|
600
600
|
},
|
|
601
601
|
{
|
|
602
|
-
n: '
|
|
602
|
+
n: I18n.getLang('strip_lights_mood_text13'),
|
|
603
603
|
i: '0149070e0e0000006400da37015241005c37',
|
|
604
604
|
s: '',
|
|
605
605
|
t: 0,
|
|
606
606
|
e: false,
|
|
607
607
|
},
|
|
608
608
|
{
|
|
609
|
-
n: '
|
|
609
|
+
n: I18n.getLang('strip_lights_mood_text14'),
|
|
610
610
|
i: '014a0832320000006400f75000294f010d3800a327',
|
|
611
611
|
s: '',
|
|
612
612
|
t: 0,
|
|
613
613
|
e: false,
|
|
614
614
|
},
|
|
615
615
|
{
|
|
616
|
-
n: '
|
|
616
|
+
n: I18n.getLang('strip_lights_mood_text15'),
|
|
617
617
|
i: '014b0932320000006401034500413a00254b005e42',
|
|
618
618
|
s: '',
|
|
619
619
|
t: 0,
|
|
620
620
|
e: false,
|
|
621
621
|
},
|
|
622
622
|
{
|
|
623
|
-
n: '
|
|
623
|
+
n: I18n.getLang('strip_lights_mood_text16'),
|
|
624
624
|
i: '014c0c32320000006400d84d00c143010345005c37',
|
|
625
625
|
s: '',
|
|
626
626
|
t: 0,
|
|
627
627
|
e: false,
|
|
628
628
|
},
|
|
629
629
|
{
|
|
630
|
-
n: '
|
|
630
|
+
n: I18n.getLang('strip_lights_mood_text17'),
|
|
631
631
|
i: '014d0d323200000064002864005e4200c16400ff50',
|
|
632
632
|
s: '',
|
|
633
633
|
t: 0,
|
|
634
634
|
e: false,
|
|
635
635
|
},
|
|
636
636
|
{
|
|
637
|
-
n: '
|
|
637
|
+
n: I18n.getLang('strip_lights_mood_text18'),
|
|
638
638
|
i: '014e0e323200000064003e5f00be5c',
|
|
639
639
|
s: '',
|
|
640
640
|
t: 0,
|
|
641
641
|
e: false,
|
|
642
642
|
},
|
|
643
643
|
{
|
|
644
|
-
n: '
|
|
644
|
+
n: I18n.getLang('strip_lights_mood_text19'),
|
|
645
645
|
i: '014f0f19190000006400bc64002d4e00006400643c',
|
|
646
646
|
s: '',
|
|
647
647
|
t: 0,
|
|
648
648
|
e: false,
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
|
-
n: '
|
|
651
|
+
n: I18n.getLang('strip_lights_mood_text20'),
|
|
652
652
|
i: '01501032320000006400e64700643c01194d00b839',
|
|
653
653
|
s: '',
|
|
654
654
|
t: 0,
|
|
655
655
|
e: false,
|
|
656
656
|
},
|
|
657
657
|
{
|
|
658
|
-
n: '
|
|
658
|
+
n: I18n.getLang('strip_lights_mood_text21'),
|
|
659
659
|
i: '011f025f5f6000006401106400d26400ad64008b64',
|
|
660
660
|
s: '',
|
|
661
661
|
t: 0,
|
|
662
662
|
e: false,
|
|
663
663
|
},
|
|
664
664
|
{
|
|
665
|
-
n: '
|
|
665
|
+
n: I18n.getLang('strip_lights_mood_text22'),
|
|
666
666
|
i: '01200a55556000006400c258013e3300ff46011d64',
|
|
667
667
|
s: '',
|
|
668
668
|
t: 0,
|
|
669
669
|
e: false,
|
|
670
670
|
},
|
|
671
671
|
{
|
|
672
|
-
n: '
|
|
672
|
+
n: I18n.getLang('strip_lights_mood_text23'),
|
|
673
673
|
i: '0121033c3c6000006400bf18010417',
|
|
674
674
|
s: '',
|
|
675
675
|
t: 0,
|
|
676
676
|
e: false,
|
|
677
677
|
},
|
|
678
678
|
{
|
|
679
|
-
n: '
|
|
679
|
+
n: I18n.getLang('strip_lights_mood_text24'),
|
|
680
680
|
i: '01220464646000006400d75c00bc5300371e002c3f01613f',
|
|
681
681
|
s: '',
|
|
682
682
|
t: 0,
|
|
683
683
|
e: false,
|
|
684
684
|
},
|
|
685
685
|
{
|
|
686
|
-
n: '
|
|
686
|
+
n: I18n.getLang('strip_lights_mood_text25'),
|
|
687
687
|
i: '01230264646000006401084b00b12f00cd57',
|
|
688
688
|
s: '',
|
|
689
689
|
t: 0,
|
|
690
690
|
e: false,
|
|
691
691
|
},
|
|
692
692
|
{
|
|
693
|
-
n: '
|
|
693
|
+
n: I18n.getLang('strip_lights_mood_text26'),
|
|
694
694
|
i: '01240a4b4b6000006400bc2600d65501186400f94d',
|
|
695
695
|
s: '',
|
|
696
696
|
t: 0,
|
|
697
697
|
e: false,
|
|
698
698
|
},
|
|
699
699
|
{
|
|
700
|
-
n: '
|
|
700
|
+
n: I18n.getLang('strip_lights_mood_text27'),
|
|
701
701
|
i: '01250343436000006400b735009b5400cd61',
|
|
702
702
|
s: '',
|
|
703
703
|
t: 0,
|
|
704
704
|
e: false,
|
|
705
705
|
},
|
|
706
706
|
{
|
|
707
|
-
n: '
|
|
707
|
+
n: I18n.getLang('strip_lights_mood_text28'),
|
|
708
708
|
i: '0126015959e000006401194701493d00cd61002664',
|
|
709
709
|
s: '',
|
|
710
710
|
t: 0,
|
|
711
711
|
e: false,
|
|
712
712
|
},
|
|
713
713
|
{
|
|
714
|
-
n: '
|
|
714
|
+
n: I18n.getLang('strip_lights_mood_text29'),
|
|
715
715
|
i: '0129026161e0000064000b6400d964002b6400916400b964',
|
|
716
716
|
s: '',
|
|
717
717
|
t: 0,
|
|
718
718
|
e: false,
|
|
719
719
|
},
|
|
720
720
|
{
|
|
721
|
-
n: '
|
|
721
|
+
n: I18n.getLang('strip_lights_mood_text30'),
|
|
722
722
|
i: '012a01646460000064011564010564014564012f64',
|
|
723
723
|
s: '',
|
|
724
724
|
t: 0,
|
|
725
725
|
e: false,
|
|
726
726
|
},
|
|
727
727
|
{
|
|
728
|
-
n: '
|
|
728
|
+
n: I18n.getLang('strip_lights_mood_text31'),
|
|
729
729
|
i: '012b035a5ae000006400005701166400da6400b364009564',
|
|
730
730
|
s: '',
|
|
731
731
|
t: 0,
|
|
732
732
|
e: false,
|
|
733
733
|
},
|
|
734
734
|
{
|
|
735
|
-
n: '
|
|
735
|
+
n: I18n.getLang('strip_lights_mood_text32'),
|
|
736
736
|
i: '012c0a484860000064003d64010c5b00ba49001761',
|
|
737
737
|
s: '',
|
|
738
738
|
t: 0,
|
|
739
739
|
e: false,
|
|
740
740
|
},
|
|
741
741
|
{
|
|
742
|
-
n: '
|
|
742
|
+
n: I18n.getLang('strip_lights_mood_text33'),
|
|
743
743
|
i: '012d02595960000064009c6300bc62007b60',
|
|
744
744
|
s: '',
|
|
745
745
|
t: 0,
|
|
746
746
|
e: false,
|
|
747
747
|
},
|
|
748
748
|
{
|
|
749
|
-
n: '
|
|
749
|
+
n: I18n.getLang('strip_lights_mood_text34'),
|
|
750
750
|
i: '012e035a5a60000064013e36010c56011f23',
|
|
751
751
|
s: '',
|
|
752
752
|
t: 0,
|
|
753
753
|
e: false,
|
|
754
754
|
},
|
|
755
755
|
{
|
|
756
|
-
n: '
|
|
756
|
+
n: I18n.getLang('strip_lights_mood_text35'),
|
|
757
757
|
i: '012f026464e000006400dc4200b64a00e14d',
|
|
758
758
|
s: '',
|
|
759
759
|
t: 0,
|
|
760
760
|
e: false,
|
|
761
761
|
},
|
|
762
762
|
{
|
|
763
|
-
n: '
|
|
763
|
+
n: I18n.getLang('strip_lights_mood_text36'),
|
|
764
764
|
i: '0130025e5e6000006400006400786400bb64',
|
|
765
765
|
s: '',
|
|
766
766
|
t: 0,
|
|
767
767
|
e: false,
|
|
768
768
|
},
|
|
769
769
|
{
|
|
770
|
-
n: '
|
|
770
|
+
n: I18n.getLang('strip_lights_mood_text37'),
|
|
771
771
|
i: '01330352526000006400885000d23900fb27',
|
|
772
772
|
s: '',
|
|
773
773
|
t: 0,
|
|
774
774
|
e: false,
|
|
775
775
|
},
|
|
776
776
|
{
|
|
777
|
-
n: '
|
|
777
|
+
n: I18n.getLang('strip_lights_mood_text38'),
|
|
778
778
|
i: '0134035d5d6000006400f73601352b00c634009129',
|
|
779
779
|
s: '',
|
|
780
780
|
t: 0,
|
|
781
781
|
e: false,
|
|
782
782
|
},
|
|
783
783
|
{
|
|
784
|
-
n: '
|
|
784
|
+
n: I18n.getLang('strip_lights_mood_text39'),
|
|
785
785
|
i: '01350352526000004d01126201305d',
|
|
786
786
|
s: '',
|
|
787
787
|
t: 0,
|
|
788
788
|
e: false,
|
|
789
789
|
},
|
|
790
790
|
{
|
|
791
|
-
n: '
|
|
791
|
+
n: I18n.getLang('strip_lights_mood_text40'),
|
|
792
792
|
i: '01360249496000006400663c003c49001e64',
|
|
793
793
|
s: '',
|
|
794
794
|
t: 0,
|
|
795
795
|
e: false,
|
|
796
796
|
},
|
|
797
797
|
{
|
|
798
|
-
n: '
|
|
798
|
+
n: I18n.getLang('strip_lights_mood_text41'),
|
|
799
799
|
i: '01370a5a5a6000006400335800186401004500e35e00ac30',
|
|
800
800
|
s: '',
|
|
801
801
|
t: 0,
|
|
802
802
|
e: false,
|
|
803
803
|
},
|
|
804
804
|
{
|
|
805
|
-
n: '
|
|
805
|
+
n: I18n.getLang('strip_lights_mood_text42'),
|
|
806
806
|
i: '0138025757e0000064010c64011a41014759001564003c38',
|
|
807
807
|
s: '',
|
|
808
808
|
t: 0,
|
|
809
809
|
e: false,
|
|
810
810
|
},
|
|
811
811
|
{
|
|
812
|
-
n: '
|
|
812
|
+
n: I18n.getLang('strip_lights_mood_text43'),
|
|
813
813
|
i: '0139034848e000006400596400b347',
|
|
814
814
|
s: '',
|
|
815
815
|
t: 0,
|
|
816
816
|
e: false,
|
|
817
817
|
},
|
|
818
818
|
{
|
|
819
|
-
n: '
|
|
819
|
+
n: I18n.getLang('strip_lights_mood_text44'),
|
|
820
820
|
i: '013a025d5de000004d00b45e011c6400e84900c65f',
|
|
821
821
|
s: '',
|
|
822
822
|
t: 0,
|
|
@@ -11,7 +11,7 @@ import Page from "@ledvance/base/src/components/Page";
|
|
|
11
11
|
import LdvPickerView from '@ledvance/base/src/components/ldvPickerView'
|
|
12
12
|
import { Utils, Progress } from 'tuya-panel-kit'
|
|
13
13
|
import { useDeviceInfo } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
14
|
-
import {
|
|
14
|
+
import { useProgress } from "./TimerPageAction";
|
|
15
15
|
import { cloneDeep } from "lodash";
|
|
16
16
|
import dayjs from "dayjs";
|
|
17
17
|
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
@@ -39,13 +39,7 @@ const TimerPage = () => {
|
|
|
39
39
|
const devInfo = useDeviceInfo()
|
|
40
40
|
const navigation = useNavigation()
|
|
41
41
|
const { dps } = useRoute<Props['route']>().params
|
|
42
|
-
const
|
|
43
|
-
const cancelTimer = (dpId: string) => {
|
|
44
|
-
const countdown = countdowns.find(c => c.dpId === dpId)?.countdown
|
|
45
|
-
countdown && countdown[1](0)
|
|
46
|
-
}
|
|
47
|
-
const progress = useProgress(dps, cancelTimer)
|
|
48
|
-
|
|
42
|
+
const progress = useProgress(dps)
|
|
49
43
|
const state = useReactive({
|
|
50
44
|
hour: '00',
|
|
51
45
|
minute: '01',
|
|
@@ -55,11 +49,11 @@ const TimerPage = () => {
|
|
|
55
49
|
|
|
56
50
|
|
|
57
51
|
const hasNotRunningTimer = () => {
|
|
58
|
-
return !!
|
|
52
|
+
return !!progress.find(p => p.progressHook.countdown === 0)
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
const runningTimer = () => {
|
|
62
|
-
return
|
|
56
|
+
return progress.filter(p => p.progressHook.countdown > 0)
|
|
63
57
|
}
|
|
64
58
|
|
|
65
59
|
const getProgressByDp = useCallback((dpId: string) => {
|
|
@@ -67,8 +61,8 @@ const TimerPage = () => {
|
|
|
67
61
|
}, [progress])
|
|
68
62
|
|
|
69
63
|
useEffect(() => {
|
|
70
|
-
if (
|
|
71
|
-
state.skillList =
|
|
64
|
+
if (progress.length > 1) {
|
|
65
|
+
state.skillList = progress.filter(p => p.progressHook.countdown === 0)
|
|
72
66
|
} else {
|
|
73
67
|
state.skillList = []
|
|
74
68
|
state.selectedSkill = cloneDeep(dps)
|
|
@@ -104,13 +98,11 @@ const TimerPage = () => {
|
|
|
104
98
|
}
|
|
105
99
|
if (!state.selectedSkill.length || mCountdown === 0) return
|
|
106
100
|
for (let skill of state.selectedSkill) {
|
|
107
|
-
const timer = countdowns.find(timer => timer.dpId === skill.dpId)
|
|
108
|
-
await timer?.countdown[1](mCountdown)
|
|
109
101
|
const time = dayjs()
|
|
110
102
|
.add(Number(hour), 'h')
|
|
111
103
|
.add(Number(minute), 'm')
|
|
112
104
|
.format('YYYY-MM-DD HH:mm:ss');
|
|
113
|
-
await getProgressByDp(skill.dpId)
|
|
105
|
+
await getProgressByDp(skill.dpId).startTimer(mCountdown, time)
|
|
114
106
|
}
|
|
115
107
|
state.selectedSkill = []
|
|
116
108
|
}
|
|
@@ -138,7 +130,7 @@ const TimerPage = () => {
|
|
|
138
130
|
}
|
|
139
131
|
|
|
140
132
|
const showActiveView = () => {
|
|
141
|
-
return
|
|
133
|
+
return progress.length > 1
|
|
142
134
|
}
|
|
143
135
|
|
|
144
136
|
const renderItem = ({ item }) => {
|
|
@@ -160,7 +152,7 @@ const TimerPage = () => {
|
|
|
160
152
|
>
|
|
161
153
|
{item.label}
|
|
162
154
|
</Text>
|
|
163
|
-
{
|
|
155
|
+
{progress.length > 1 && <TouchableOpacity onPress={() => handelTimer(item, false)}>
|
|
164
156
|
<Image style={{ width: cx(16), height: cx(16), marginRight: cx(5) }} source={res.ic_arrows_nav_clear} />
|
|
165
157
|
</TouchableOpacity>}
|
|
166
158
|
</View>
|
|
@@ -247,8 +239,7 @@ const TimerPage = () => {
|
|
|
247
239
|
<Text style={styles.activeTimerTitle}>{timer.label}</Text>
|
|
248
240
|
<TouchableOpacity
|
|
249
241
|
onPress={() => {
|
|
250
|
-
timer.
|
|
251
|
-
getProgressByDp(timer.dpId)[2]()
|
|
242
|
+
getProgressByDp(timer.dpId).endTimer()
|
|
252
243
|
}}
|
|
253
244
|
style={styles.activeTimerCancelBtn}>
|
|
254
245
|
<Text style={{ color: '#fff', fontSize: cx(12) }}>{I18n.getLang('auto_scan_system_cancel')}</Text>
|
|
@@ -265,16 +256,16 @@ const TimerPage = () => {
|
|
|
265
256
|
}}
|
|
266
257
|
disabled={true}
|
|
267
258
|
minValue={0}
|
|
268
|
-
maxValue={getProgressByDp(timer.dpId)
|
|
259
|
+
maxValue={getProgressByDp(timer.dpId).progressNumber}
|
|
269
260
|
startDegree={270}
|
|
270
261
|
andDegree={360}
|
|
271
262
|
scaleHeight={2}
|
|
272
263
|
thumbStrokeWidth={2}
|
|
273
264
|
thumbRadius={0}
|
|
274
265
|
/>
|
|
275
|
-
<Text style={{ marginLeft: cx(20), fontSize: cx(22) }}>{getActiveTimeString(timer.countdown
|
|
266
|
+
<Text style={{ marginLeft: cx(20), fontSize: cx(22) }}>{getActiveTimeString(timer.progressHook.countdown)}</Text>
|
|
276
267
|
</View>
|
|
277
|
-
<Text>{I18n.formatValue(timer.enable
|
|
268
|
+
<Text>{I18n.formatValue(timer.enable ? timer.stringOff : timer.stringOn, getSingleLightEndTimeString(timer.progressHook.countdown))}</Text>
|
|
278
269
|
</Card>
|
|
279
270
|
<Spacer height={cx(40)} />
|
|
280
271
|
</View>
|
|
@@ -295,7 +286,7 @@ const TimerPage = () => {
|
|
|
295
286
|
alignItems: 'center',
|
|
296
287
|
}}
|
|
297
288
|
minValue={0}
|
|
298
|
-
maxValue={getProgressByDp(runningTimer()[0].dpId)
|
|
289
|
+
maxValue={getProgressByDp(runningTimer()[0].dpId).progressNumber}
|
|
299
290
|
startDegree={270}
|
|
300
291
|
andDegree={360}
|
|
301
292
|
disabled={true}
|
|
@@ -310,7 +301,7 @@ const TimerPage = () => {
|
|
|
310
301
|
renderCenterView={
|
|
311
302
|
<View style={{ position: 'absolute' }}>
|
|
312
303
|
<Text style={{ fontSize: cx(22), fontWeight: 'bold', color: '#666' }}>
|
|
313
|
-
{getActiveTimeString(runningTimer()[0].countdown
|
|
304
|
+
{getActiveTimeString(runningTimer()[0].progressHook.countdown)}
|
|
314
305
|
</Text>
|
|
315
306
|
</View>
|
|
316
307
|
}
|
|
@@ -320,7 +311,7 @@ const TimerPage = () => {
|
|
|
320
311
|
{I18n.formatValue(
|
|
321
312
|
runningTimer()[0].enable[0] ?
|
|
322
313
|
runningTimer()[0].stringOff :
|
|
323
|
-
runningTimer()[0].stringOn, getSingleLightEndTimeString(runningTimer()[0].countdown
|
|
314
|
+
runningTimer()[0].stringOn, getSingleLightEndTimeString(runningTimer()[0].progressHook.countdown)
|
|
324
315
|
)}
|
|
325
316
|
</Text>
|
|
326
317
|
</View>
|
|
@@ -329,8 +320,7 @@ const TimerPage = () => {
|
|
|
329
320
|
style={{ paddingHorizontal: cx(15), width: 'auto', height: cx(40) }}
|
|
330
321
|
textStyle={{ fontSize: cx(14) }}
|
|
331
322
|
onPress={() => {
|
|
332
|
-
runningTimer()[0].
|
|
333
|
-
getProgressByDp(runningTimer()[0].dpId)[2]()
|
|
323
|
+
getProgressByDp(runningTimer()[0].dpId).endTimer()
|
|
334
324
|
}}
|
|
335
325
|
/>
|
|
336
326
|
</View>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react"
|
|
1
2
|
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
2
3
|
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
3
4
|
import { dpItem } from "./TimerPage"
|
|
4
5
|
import { useCountDown as useCountDownAHook, useUpdateEffect } from 'ahooks'
|
|
5
6
|
import dayjs from "dayjs"
|
|
6
7
|
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
7
|
-
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
export const useCountdowns = (dps: dpItem[]) => {
|
|
10
11
|
return dps.map(dp => {
|
|
@@ -16,20 +17,26 @@ export const useCountdowns = (dps: dpItem[]) => {
|
|
|
16
17
|
})
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
type FormateProgressType = {
|
|
21
|
+
progressNumber: number
|
|
22
|
+
countdown: number
|
|
23
|
+
startTimer: (c: number, time: string) => Promise<void>
|
|
24
|
+
endTimer: () => void
|
|
25
|
+
}
|
|
26
|
+
const useFormateProgress: (dp: dpItem) => FormateProgressType = (dp) => {
|
|
27
|
+
const [countdown, setCountdown] = useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId)
|
|
21
28
|
const [progress, setProgress] = useCountDownAHook({
|
|
22
29
|
interval: 1000,
|
|
23
30
|
onEnd: () => {
|
|
24
|
-
cancelTimer(dp.dpId)
|
|
25
31
|
initTimerFn()
|
|
32
|
+
setCountdown(0)
|
|
26
33
|
},
|
|
27
34
|
})
|
|
28
|
-
const [countdown] = useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId)
|
|
29
35
|
const devId = useDeviceId()
|
|
30
36
|
const [cloudProgressNumber, setCloudProgressNumber] = useState(0)
|
|
31
37
|
const [progressNumber, setProgressNumber] = useState(0)
|
|
32
38
|
const [cloudData, setCloudData] = useState<any>()
|
|
39
|
+
const [isTrigger, setIsTeigger] = useState(false)
|
|
33
40
|
const getCloudJson = () => {
|
|
34
41
|
NativeApi.getJson(devId, dp.cloudKey).then(res => {
|
|
35
42
|
if (res.success && res.data) {
|
|
@@ -41,7 +48,9 @@ const useFormateProgress: (dp: dpItem, func: Function) => [number, (time: number
|
|
|
41
48
|
})
|
|
42
49
|
}
|
|
43
50
|
useEffect(() => {
|
|
44
|
-
|
|
51
|
+
if(countdown > 0){
|
|
52
|
+
getCloudJson()
|
|
53
|
+
}
|
|
45
54
|
}, [])
|
|
46
55
|
|
|
47
56
|
useEffect(() => {
|
|
@@ -54,19 +63,26 @@ const useFormateProgress: (dp: dpItem, func: Function) => [number, (time: number
|
|
|
54
63
|
}
|
|
55
64
|
}, [progress])
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
useUpdateEffect(() =>{
|
|
67
|
+
if(countdown === 0){
|
|
68
|
+
setIsTeigger(false)
|
|
69
|
+
initTimerFn()
|
|
70
|
+
}
|
|
71
|
+
}, [countdown])
|
|
72
|
+
|
|
58
73
|
useUpdateEffect(() => {
|
|
59
74
|
if (countdown === 0) {
|
|
60
|
-
|
|
61
|
-
if(cloudData && cloudData.progressAllNumber !== 0){
|
|
75
|
+
if(isTrigger){
|
|
62
76
|
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then()
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
if (countdown > 0 && !cloudData) {
|
|
80
|
+
if (countdown > 0 && !cloudData && !isTrigger) {
|
|
67
81
|
getCloudJson()
|
|
68
82
|
}
|
|
69
83
|
}, [countdown, cloudData])
|
|
84
|
+
|
|
85
|
+
|
|
70
86
|
|
|
71
87
|
const initTimerFn = useCallback(() =>{
|
|
72
88
|
setProgressNumber(0)
|
|
@@ -80,24 +96,36 @@ const useFormateProgress: (dp: dpItem, func: Function) => [number, (time: number
|
|
|
80
96
|
return key
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
const startTimer = async (time: number, t) => {
|
|
84
|
-
|
|
99
|
+
const startTimer = async (time: number, t:string) => {
|
|
100
|
+
setIsTeigger(true)
|
|
101
|
+
await setCountdown(time)
|
|
102
|
+
const putData = { [getKey('Status', dp.dpId)]: true, [getKey('StartTime', dp.dpId)]: t, progressAllNumber: time }
|
|
103
|
+
await NativeApi.putJson(devId, dp.cloudKey, JSON.stringify(putData))
|
|
85
104
|
setCloudProgressNumber(time)
|
|
86
105
|
setProgress(Date.now() + time * 1000)
|
|
106
|
+
setCloudData(putData)
|
|
87
107
|
}
|
|
88
108
|
|
|
89
|
-
const endTimer = () =>{
|
|
109
|
+
const endTimer = async () =>{
|
|
110
|
+
setIsTeigger(false)
|
|
111
|
+
await setCountdown(0)
|
|
90
112
|
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then(() => {
|
|
91
113
|
initTimerFn()
|
|
92
114
|
})
|
|
93
115
|
}
|
|
94
116
|
|
|
95
|
-
return
|
|
117
|
+
return {
|
|
118
|
+
progressNumber,
|
|
119
|
+
countdown,
|
|
120
|
+
startTimer,
|
|
121
|
+
endTimer
|
|
122
|
+
}
|
|
96
123
|
}
|
|
97
124
|
|
|
98
|
-
export const useProgress = (dps: dpItem[]
|
|
125
|
+
export const useProgress = (dps: dpItem[]) => {
|
|
99
126
|
return dps.map(dp => ({
|
|
100
|
-
progressHook: useFormateProgress(dp
|
|
127
|
+
progressHook: useFormateProgress(dp),
|
|
128
|
+
enable: useDp(dp.enableDp)[0] as boolean,
|
|
101
129
|
...dp
|
|
102
130
|
}))
|
|
103
131
|
}
|