@ledvance/ui-biz-bundle 1.0.77 → 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/music/MusicDataBean.ts +2 -2
- package/src/modules/scene/SceneAction.ts +26 -0
- package/src/modules/scene/SceneInfo.ts +1 -1
- 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
|
@@ -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))
|
|
@@ -648,7 +648,7 @@ function getStripLightSceneList(): RemoteSceneInfo[] {
|
|
|
648
648
|
e: false,
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
|
-
n: I18n.getLang('
|
|
651
|
+
n: I18n.getLang('strip_lights_mood_text20'),
|
|
652
652
|
i: '01501032320000006400e64700643c01194d00b839',
|
|
653
653
|
s: '',
|
|
654
654
|
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
|
}
|