@ledvance/ui-biz-bundle 1.1.105 → 1.1.107
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/hooks/DeviceDpStateHooks.ts +156 -0
- package/src/modules/flags/FlagActions.ts +4 -1
- package/src/modules/flags/FlagPage.tsx +12 -42
- package/src/modules/music/MusicPage.tsx +13 -7
- package/src/modules/timer/TimerPage.tsx +4 -1
- package/src/modules/timer/TimerPageAction.ts +0 -1
- package/src/navigation/Routers.ts +3 -1
- package/src/newModules/biorhythm/BiorhythmBean.ts +1 -1
- package/src/newModules/biorhythm/BiorhythmPage.tsx +27 -4
- package/src/newModules/diyScene/DefaultScenes.ts +438 -0
- package/src/newModules/diyScene/DiySceneActions.ts +232 -0
- package/src/newModules/diyScene/DiySceneEditorPage.tsx +359 -0
- package/src/newModules/diyScene/DiyScenePage.tsx +297 -0
- package/src/newModules/diyScene/Router.ts +25 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +15 -2
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +31 -10
- package/src/newModules/energyConsumption/component/DateSwitch.tsx +111 -0
- package/src/newModules/energyConsumption/component/DateTypeItem.tsx +1 -0
- package/src/newModules/energyConsumption/component/NewBarChart.tsx +16 -3
- package/src/newModules/fixedTime/FixedTimeActions.ts +3 -3
- package/src/newModules/fixedTime/FixedTimePage.tsx +58 -6
- package/src/newModules/mood/MoodActions.ts +4 -1
- package/src/newModules/mood/MoodItem.tsx +2 -1
- package/src/newModules/mood/MoodPage.tsx +4 -3
- package/src/newModules/randomTime/RandomTimeActions.ts +3 -3
- package/src/newModules/randomTime/RandomTimePage.tsx +60 -7
- package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +21 -11
- package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +108 -13
- package/src/newModules/switchGradient/SwitchGradientPage.tsx +7 -4
- package/src/newModules/swithInching/SwithInching.tsx +1 -0
- package/src/newModules/timeSchedule/Interface.ts +19 -7
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +6 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +134 -57
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +23 -6
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +42 -9
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import {NativeApi} from '@ledvance/base/src/api/native'
|
|
2
2
|
import {useDp} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
3
3
|
import {Result} from '@ledvance/base/src/models/modules/Result'
|
|
4
|
+
import { useRandomTime } from '../newModules/randomTime/RandomTimeActions'
|
|
5
|
+
import { useBiorhythm } from '../newModules/biorhythm/BiorhythmActions'
|
|
6
|
+
import { useFixedTime } from '../newModules/fixedTime/FixedTimeActions'
|
|
7
|
+
import { getEndTime, getStartTime, useSleepMode, useWakeUp } from '../newModules/sleepWakeUp/SleepWakeUpActions'
|
|
8
|
+
import { isConflictTask } from '@ledvance/base/src/utils/common'
|
|
9
|
+
import { isEmpty } from 'lodash'
|
|
10
|
+
import { useReactive } from 'ahooks'
|
|
4
11
|
|
|
5
12
|
export const WHITE = 'white'
|
|
6
13
|
export const COLOUR = 'colour'
|
|
@@ -48,4 +55,153 @@ export const setMixSceneDp = (deviceId: string, value: string, dpCodes: Record<s
|
|
|
48
55
|
|
|
49
56
|
export const useWorkMode = (workModeDpCode: string): [string, (mode: string) => Promise<Result<any>>] => {
|
|
50
57
|
return useDp(workModeDpCode)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface ConflictDps {
|
|
61
|
+
fixedTimeDpCode?: string
|
|
62
|
+
randomTimeDpCode?: string
|
|
63
|
+
biorhythmDpCode?: string
|
|
64
|
+
sleepDpCode?: string
|
|
65
|
+
wakeUpDpCode?: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface ConflictItem {
|
|
69
|
+
startTime: number
|
|
70
|
+
endTime: number
|
|
71
|
+
weeks: number[]
|
|
72
|
+
enable: boolean
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const useConflictTask = (conflictDps: ConflictDps): [(v: ConflictItem) => boolean, () => void] => {
|
|
76
|
+
const [biorhythm, setBiorhythm] = useBiorhythm(conflictDps.biorhythmDpCode!, true)
|
|
77
|
+
const [fixedTime, setFixedTime] = useFixedTime(conflictDps.fixedTimeDpCode!, false, true)
|
|
78
|
+
const [randomTime, setRandomTime] = useRandomTime(conflictDps.randomTimeDpCode!, false, true)
|
|
79
|
+
const [sleepPlan, setSleepPlan] = useSleepMode(conflictDps.sleepDpCode!, true)
|
|
80
|
+
const [wakeUpPlan, setWakeUpPlan] = useWakeUp(conflictDps.wakeUpDpCode!, true)
|
|
81
|
+
const state = useReactive({
|
|
82
|
+
conflictTask: {}
|
|
83
|
+
})
|
|
84
|
+
const checkConflict = (conflictItem: ConflictItem) => {
|
|
85
|
+
state.conflictTask = {}
|
|
86
|
+
if (conflictDps.biorhythmDpCode && biorhythm.enable){
|
|
87
|
+
const biorhythmTask = {
|
|
88
|
+
startTime: 0,
|
|
89
|
+
endTime: 1440,
|
|
90
|
+
weeks: biorhythm.repeatPeriod.map(item => item.enabled ? 1 : 0)
|
|
91
|
+
}
|
|
92
|
+
if (isConflictTask(conflictItem, biorhythmTask)){
|
|
93
|
+
state.conflictTask = {
|
|
94
|
+
...state.conflictTask,
|
|
95
|
+
[conflictDps.biorhythmDpCode]: {
|
|
96
|
+
...biorhythm,
|
|
97
|
+
enable: false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (conflictDps.fixedTimeDpCode && fixedTime.length){
|
|
103
|
+
let conflict = false
|
|
104
|
+
const newFixedTime = fixedTime.map(item => {
|
|
105
|
+
if (item.enable && isConflictTask(item, conflictItem)) {
|
|
106
|
+
conflict = true
|
|
107
|
+
return {
|
|
108
|
+
...item,
|
|
109
|
+
enable: false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return item
|
|
113
|
+
})
|
|
114
|
+
if (conflict){
|
|
115
|
+
state.conflictTask = {
|
|
116
|
+
...state.conflictTask,
|
|
117
|
+
[conflictDps.fixedTimeDpCode]: newFixedTime
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (conflictDps.randomTimeDpCode && randomTime.length){
|
|
122
|
+
let conflict = false
|
|
123
|
+
const newRandomTime = randomTime.map(item => {
|
|
124
|
+
if (item.enable && isConflictTask(item, conflictItem)) {
|
|
125
|
+
conflict = true
|
|
126
|
+
return {
|
|
127
|
+
...item,
|
|
128
|
+
enable: false
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return item
|
|
132
|
+
})
|
|
133
|
+
if (conflict){
|
|
134
|
+
state.conflictTask = {
|
|
135
|
+
...state.conflictTask,
|
|
136
|
+
[conflictDps.randomTimeDpCode]: newRandomTime
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (conflictDps.sleepDpCode && sleepPlan.length){
|
|
141
|
+
let conflict = false
|
|
142
|
+
const newSleepPlan = sleepPlan.map(item => {
|
|
143
|
+
if (item.enable && isConflictTask({
|
|
144
|
+
...item,
|
|
145
|
+
startTime: getStartTime(item),
|
|
146
|
+
endTime: getEndTime(item)
|
|
147
|
+
}, conflictItem)) {
|
|
148
|
+
conflict = true
|
|
149
|
+
return {
|
|
150
|
+
...item,
|
|
151
|
+
enable: false
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return item
|
|
155
|
+
})
|
|
156
|
+
if (conflict){
|
|
157
|
+
state.conflictTask = {
|
|
158
|
+
...state.conflictTask,
|
|
159
|
+
[conflictDps.sleepDpCode]: newSleepPlan
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (conflictDps.wakeUpDpCode && wakeUpPlan.length){
|
|
164
|
+
let conflict = false
|
|
165
|
+
const newWakeUpPlan = wakeUpPlan.map(item => {
|
|
166
|
+
if (item.enable && isConflictTask({
|
|
167
|
+
...item,
|
|
168
|
+
startTime: getStartTime(item),
|
|
169
|
+
endTime: getEndTime(item)
|
|
170
|
+
}, conflictItem)) {
|
|
171
|
+
conflict = true
|
|
172
|
+
return {
|
|
173
|
+
...item,
|
|
174
|
+
enable: false
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return item
|
|
178
|
+
})
|
|
179
|
+
if (conflict){
|
|
180
|
+
state.conflictTask = {
|
|
181
|
+
...state.conflictTask,
|
|
182
|
+
[conflictDps.wakeUpDpCode]: newWakeUpPlan
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return !isEmpty(state.conflictTask)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const resolveConfict = () => {
|
|
190
|
+
if (conflictDps.biorhythmDpCode && state.conflictTask[conflictDps.biorhythmDpCode]){
|
|
191
|
+
setBiorhythm(state.conflictTask[conflictDps.biorhythmDpCode], false).then()
|
|
192
|
+
}
|
|
193
|
+
if (conflictDps.fixedTimeDpCode && state.conflictTask[conflictDps.fixedTimeDpCode]){
|
|
194
|
+
setFixedTime(state.conflictTask[conflictDps.fixedTimeDpCode], false).then()
|
|
195
|
+
}
|
|
196
|
+
if (conflictDps.randomTimeDpCode && state.conflictTask[conflictDps.randomTimeDpCode]){
|
|
197
|
+
setRandomTime(state.conflictTask[conflictDps.randomTimeDpCode], false).then()
|
|
198
|
+
}
|
|
199
|
+
if (conflictDps.sleepDpCode && state.conflictTask[conflictDps.sleepDpCode]){
|
|
200
|
+
setSleepPlan(state.conflictTask[conflictDps.sleepDpCode], false).then()
|
|
201
|
+
}
|
|
202
|
+
if (conflictDps.wakeUpDpCode && state.conflictTask[conflictDps.wakeUpDpCode]){
|
|
203
|
+
setWakeUpPlan(state.conflictTask[conflictDps.wakeUpDpCode], false).then()
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return [checkConflict, resolveConfict]
|
|
51
207
|
}
|
|
@@ -9,6 +9,7 @@ import { useMemo, useState } from "react";
|
|
|
9
9
|
import { useUpdateEffect } from "ahooks";
|
|
10
10
|
import { NativeApi } from "@ledvance/base/src/api/native";
|
|
11
11
|
import { stripDp2Obj } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneAction";
|
|
12
|
+
import { cloneDeep } from "lodash";
|
|
12
13
|
|
|
13
14
|
export interface ExtraParams extends FlagPageProps, FlagOption {
|
|
14
15
|
}
|
|
@@ -71,7 +72,9 @@ export const useFlag: UseFlagType = (flagCode, extra) => {
|
|
|
71
72
|
}
|
|
72
73
|
return setDps(extraDps)
|
|
73
74
|
} else {
|
|
74
|
-
const
|
|
75
|
+
const cloneFlagItem = cloneDeep(flagItem)
|
|
76
|
+
cloneFlagItem.colors = cloneFlagItem.colors.reverse()
|
|
77
|
+
const hex = obj2Dp(cloneFlagItem, extra)
|
|
75
78
|
const newHex = extra.isSolarLight ? ('01'+hex.substring(2)) : hex
|
|
76
79
|
return setDps({ [flagCode]: newHex, [extra.workModeCode]: WORK_MODE.SCENE, [extra.switchLedCode]: true })
|
|
77
80
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo } from "react";
|
|
2
2
|
import Page from "@ledvance/base/src/components/Page";
|
|
3
|
-
import { useDeviceId, useDeviceInfo, useFlagMode, useFlags
|
|
3
|
+
import { useDeviceId, useDeviceInfo, useFlagMode, useFlags } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
4
4
|
import { FlatList, Image, TouchableOpacity, View } from "react-native";
|
|
5
5
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
6
6
|
import { Utils } from "tuya-panel-kit";
|
|
@@ -22,8 +22,6 @@ import TextField from "@ledvance/base/src/components/TextField";
|
|
|
22
22
|
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
23
23
|
import { defFlagHash, fnv1aHash } from "./FlagHash";
|
|
24
24
|
import { NativeApi } from "@ledvance/base/src/api/native";
|
|
25
|
-
import { useSceneStatusId } from "@ledvance/ui-biz-bundle/src/newModules/mood/MoodActions";
|
|
26
|
-
import { SceneStatusType } from "@ledvance/base/src/utils/interface";
|
|
27
25
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
28
26
|
|
|
29
27
|
const cx = Utils.RatioUtils.convertX
|
|
@@ -61,7 +59,6 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
61
59
|
const devId = useDeviceId()
|
|
62
60
|
const navigation = useNavigation()
|
|
63
61
|
const [dps, setDps] = useDps()
|
|
64
|
-
const [moods, setMoods] = useMoods()
|
|
65
62
|
const [flags, setFlags] = useFlags()
|
|
66
63
|
const [flagMode, setFlagMode] = useFlagMode()
|
|
67
64
|
const [flagState, setFlag] = useFlag(((params.isStripLight || params.isCeilingLight) ? params?.drawToolLight?.drawToolCode : params.sceneDataCode)!!, {
|
|
@@ -70,14 +67,10 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
70
67
|
isCeilingLight: params.isCeilingLight,
|
|
71
68
|
...params
|
|
72
69
|
})
|
|
73
|
-
const [sceneStatusId, setSceneStatusId] = useSceneStatusId({
|
|
74
|
-
isSupportSceneStatus: params.isSupportSceneStatus,
|
|
75
|
-
sceneStatusType: SceneStatusType.Flag
|
|
76
|
-
});
|
|
77
70
|
const state = useReactive({
|
|
78
71
|
loading: false,
|
|
79
72
|
flags: cloneDeep(flags) as FlagUiInfo[],
|
|
80
|
-
|
|
73
|
+
filterFlags: cloneDeep(flags) as FlagUiInfo[],
|
|
81
74
|
searchText: ''
|
|
82
75
|
})
|
|
83
76
|
const flagId = useMemo(() => {
|
|
@@ -97,30 +90,12 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
97
90
|
|
|
98
91
|
useEffect(() => {
|
|
99
92
|
if (!devInfo.devId) return
|
|
100
|
-
|
|
101
|
-
getRemoteFlagInfo().then()
|
|
102
|
-
}
|
|
103
|
-
if (params.getRemoteMoodList && !moods?.length) {
|
|
104
|
-
params.getRemoteMoodList(devInfo.devId).then(res => {
|
|
105
|
-
if (res.success && Array.isArray(res.data)) {
|
|
106
|
-
state.moods = res.data
|
|
107
|
-
setMoods(cloneDeep(res.data))
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
}
|
|
93
|
+
getRemoteFlagInfo().then()
|
|
111
94
|
}, [devInfo.devId])
|
|
112
95
|
|
|
113
96
|
useUpdateEffect(() => {
|
|
114
|
-
state.
|
|
115
|
-
}, [
|
|
116
|
-
|
|
117
|
-
useUpdateEffect(() => {
|
|
118
|
-
state.flags = cloneDeep(flags)
|
|
119
|
-
}, [JSON.stringify(flags)])
|
|
120
|
-
|
|
121
|
-
useUpdateEffect(() => {
|
|
122
|
-
state.flags = state.searchText !== '' ? cloneDeep(flags).filter(flag => (flag.name ?? '').toLowerCase().includes(state.searchText.toLowerCase())) : cloneDeep(flags)
|
|
123
|
-
}, [state.searchText, flags])
|
|
97
|
+
state.filterFlags = state.searchText !== '' ? cloneDeep(state.flags).filter(flag => (flag.name ?? '').toLowerCase().includes(state.searchText.toLowerCase())) : cloneDeep(state.flags)
|
|
98
|
+
}, [state.searchText, state.flags])
|
|
124
99
|
|
|
125
100
|
const getRemoteFlagInfo = async (isRefresh?: boolean) => {
|
|
126
101
|
const res = await getRemoteFlag(devInfo.devId, isRefresh)
|
|
@@ -169,13 +144,12 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
169
144
|
setFlags(cloneDeep(newScene))
|
|
170
145
|
state.flags = cloneDeep(newScene)
|
|
171
146
|
if (mood) {
|
|
172
|
-
if (mode === 'del' && (!flagMode?.flagMode || currentMood.id !== flagId || !dps[params.switchLedCode])) {
|
|
147
|
+
if (mode === 'del' && (!flagMode?.flagMode || (params.isSolarLight ? (flagMode?.flagId !== currentMood.id) : currentMood.id !== flagId) || !dps[params.switchLedCode])) {
|
|
173
148
|
return {
|
|
174
149
|
success: true
|
|
175
150
|
}
|
|
176
151
|
}
|
|
177
152
|
updateFlagMode(true, mood)
|
|
178
|
-
setSceneStatusId(mood.id).then()
|
|
179
153
|
return setFlag(mood)
|
|
180
154
|
} else {
|
|
181
155
|
updateFlagMode(false)
|
|
@@ -199,12 +173,10 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
199
173
|
}
|
|
200
174
|
|
|
201
175
|
const getItemEnable = useCallback((flagItem: FlagUiInfo) =>{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
}, [params.isSupportSceneStatus, sceneStatusId, dps[params.workModeCode], dps[params.switchLedCode], flagId, flagMode?.flagMode])
|
|
176
|
+
const workMode = params.isCeilingLight ? WORK_MODE.WHITE : params.isStripLight ? WORK_MODE.COLOUR : WORK_MODE.SCENE
|
|
177
|
+
const idEnable = params.isSolarLight ? (flagMode?.flagId === flagItem.id) : (flagId === flagItem.id)
|
|
178
|
+
return flagMode?.flagMode && dps[params.workModeCode] === workMode && idEnable && dps[params.switchLedCode]
|
|
179
|
+
}, [dps[params.workModeCode], dps[params.switchLedCode], flagId, JSON.stringify(flagMode)])
|
|
208
180
|
|
|
209
181
|
return (
|
|
210
182
|
<Page
|
|
@@ -214,8 +186,7 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
214
186
|
loading={state.loading}
|
|
215
187
|
onHeadlineIconClick={() => {
|
|
216
188
|
const useIds = map([
|
|
217
|
-
...state.flags
|
|
218
|
-
...state.moods
|
|
189
|
+
...state.flags
|
|
219
190
|
], 'id')
|
|
220
191
|
const idRange = range(0, 256)
|
|
221
192
|
const unuseId = last(difference(idRange, useIds))
|
|
@@ -252,7 +223,7 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
252
223
|
</TouchableOpacity>
|
|
253
224
|
</View>
|
|
254
225
|
<FlatList
|
|
255
|
-
data={state.
|
|
226
|
+
data={state.filterFlags}
|
|
256
227
|
renderItem={({ item }) => <FlagItem
|
|
257
228
|
enable={getItemEnable(item)}
|
|
258
229
|
title={item.name}
|
|
@@ -262,7 +233,6 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
262
233
|
if (enable) {
|
|
263
234
|
state.loading = true
|
|
264
235
|
await setFlag(item)
|
|
265
|
-
await setSceneStatusId(item.id)
|
|
266
236
|
const flagHash = fnv1aHash(JSON.stringify(item.colors))
|
|
267
237
|
if (defFlagHash[flagHash]) {
|
|
268
238
|
NativeApi.putFlagFirebase({
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect } from 'react'
|
|
|
2
2
|
import { StyleSheet, View, Text, Image } from 'react-native'
|
|
3
3
|
import { useRoute, useNavigation } from '@react-navigation/core'
|
|
4
4
|
import Page from '@ledvance/base/src/components/Page'
|
|
5
|
-
import { useDeviceId, useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
5
|
+
import { useDeviceId, useDeviceInfo, useDps } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
6
6
|
import Strings from '@ledvance/base/src/i18n'
|
|
7
7
|
import Img from './res'
|
|
8
8
|
import { useEnable, useWorkMode, useMixRgbcw, useMixScene, useMusicData, useDreamMusic, DreamLightMicMusicData, getRemoteDreamMusic, DreamLightMicMusicUIState, saveRemoteDreamMusic } from './MusicPageActions'
|
|
@@ -17,7 +17,7 @@ import LdvSlider from '@ledvance/base/src/components/ldvSlider'
|
|
|
17
17
|
import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton'
|
|
18
18
|
import { SelectPageParams } from '../select/SelectPage'
|
|
19
19
|
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
20
|
-
import { cloneDeep } from 'lodash'
|
|
20
|
+
import { cloneDeep, isEmpty } from 'lodash'
|
|
21
21
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
22
22
|
import { WorkMode } from '@ledvance/base/src/utils/interface'
|
|
23
23
|
|
|
@@ -45,6 +45,7 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
45
45
|
const [, setMusicData] = useMusicData(params.music_data)
|
|
46
46
|
const [dreamMusic, setDreamMusic] = params.dreamMusicDp ? useDreamMusic(params.dreamMusicDp) : []
|
|
47
47
|
const [switchLed, setSwitchLed] = useEnable(params.switch_led)
|
|
48
|
+
const [, setDps] = useDps()
|
|
48
49
|
|
|
49
50
|
const state = useReactive({
|
|
50
51
|
musicEnable: false,
|
|
@@ -112,8 +113,12 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
112
113
|
power: true
|
|
113
114
|
}, extraDp).then()
|
|
114
115
|
} else {
|
|
115
|
-
|
|
116
|
-
if (
|
|
116
|
+
const dps = {}
|
|
117
|
+
if (workMode !== 'music') dps[params.work_mode] = WorkMode.Music
|
|
118
|
+
if (!switchLed) dps[params.switch_led] = true
|
|
119
|
+
if (!isEmpty(dps)){
|
|
120
|
+
await setDps(dps)
|
|
121
|
+
}
|
|
117
122
|
await MusicManager.open(
|
|
118
123
|
musicDefalutDatasource[state.phoneGenreMode],
|
|
119
124
|
() => { },
|
|
@@ -184,11 +189,12 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
const getSelect = async () => {
|
|
192
|
+
state.musicEnable = workMode === 'music' && !!switchLed
|
|
193
|
+
if (!state.musicEnable) return
|
|
187
194
|
const res: any = await NativeApi.getJson(deviceId, 'musicSelect')
|
|
188
195
|
const type = res?.data ? (JSON.parse(res?.data)?.type || 0) : 0
|
|
189
196
|
state.musicType = res?.data ? JSON.parse(res?.data)?.musicType : params.dreamMusicDp ? 0 : 1
|
|
190
197
|
state.phoneGenreMode = musicDefalutDatasource[type]?.id
|
|
191
|
-
state.musicEnable = workMode === 'music' && !!switchLed
|
|
192
198
|
if (type !== '' && state.musicType === 1 && state.musicEnable) {
|
|
193
199
|
openMusic()
|
|
194
200
|
}
|
|
@@ -216,7 +222,7 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
216
222
|
|
|
217
223
|
useEffect(() => {
|
|
218
224
|
getSelect().then()
|
|
219
|
-
}, [workMode])
|
|
225
|
+
}, [workMode, switchLed])
|
|
220
226
|
|
|
221
227
|
const getSelectModeData = useCallback((): [string | undefined, any[]] => {
|
|
222
228
|
const genreModeData = params.dreamMusicDp && state.musicType === 0 ? state.musicModeData : musicDefalutDatasource
|
|
@@ -270,8 +276,8 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
270
276
|
confirmText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
|
|
271
277
|
onConfirm: async (_, { close }) => {
|
|
272
278
|
close()
|
|
273
|
-
state.musicEnable = v
|
|
274
279
|
await openMusic()
|
|
280
|
+
state.musicEnable = v
|
|
275
281
|
},
|
|
276
282
|
})
|
|
277
283
|
} else {
|
|
@@ -65,7 +65,10 @@ const TimerPage = (props: {theme?: ThemeType}) => {
|
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
if (progress.length > 1) {
|
|
68
|
-
|
|
68
|
+
const runSkill = progress.filter(p => p.progressHook.countdown > 0)
|
|
69
|
+
const skill = progress.filter(p => p.progressHook.countdown === 0)
|
|
70
|
+
state.selectedSkill = state.selectedSkill.filter(item => runSkill.find(r => r.dpId !== item.dpId))
|
|
71
|
+
state.skillList = skill.filter(item => !state.selectedSkill.find(s => s.dpId === item.dpId))
|
|
69
72
|
} else {
|
|
70
73
|
state.skillList = []
|
|
71
74
|
state.selectedSkill = cloneDeep(dps)
|
|
@@ -44,5 +44,7 @@ export const ui_biz_routerKey = {
|
|
|
44
44
|
'ui_biz_overcharge_switch': 'ui_biz_overcharge_switch',
|
|
45
45
|
'ui_biz_child_lock': 'ui_biz_child_lock',
|
|
46
46
|
'ui_biz_remote_control': 'ui_biz_remote_control',
|
|
47
|
-
'ui_biz_switch_gradient': 'ui_biz_switch_gradient'
|
|
47
|
+
'ui_biz_switch_gradient': 'ui_biz_switch_gradient',
|
|
48
|
+
'ui_biz_diy_scene_page': 'ui_biz_diy_scene_page',
|
|
49
|
+
'ui_biz_diy_scene_edit_page': 'ui_biz_diy_scene_edit_page',
|
|
48
50
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getDefBiorhythmUIState,
|
|
10
10
|
Plan,
|
|
11
11
|
} from './BiorhythmBean'
|
|
12
|
-
import { Modal, Utils } from 'tuya-panel-kit'
|
|
12
|
+
import { Dialog, Modal, Utils } from 'tuya-panel-kit'
|
|
13
13
|
import { cloneDeep, sortBy } from 'lodash'
|
|
14
14
|
import iconList from './iconListData'
|
|
15
15
|
import pIdList from './pIdList'
|
|
@@ -33,6 +33,7 @@ import Spacer from '@ledvance/base/src/components/Spacer'
|
|
|
33
33
|
import DeleteButton from '@ledvance/base/src/components/DeleteButton'
|
|
34
34
|
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
35
35
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
36
|
+
import { useConflictTask } from 'hooks/DeviceDpStateHooks'
|
|
36
37
|
|
|
37
38
|
const cx = Utils.RatioUtils.convertX
|
|
38
39
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -67,9 +68,8 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
|
|
|
67
68
|
const { productId } = deviceInfo
|
|
68
69
|
const is24Hour = useSystemTimeFormate()
|
|
69
70
|
const devicesJudge = pIdList.some(val => val === productId)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// const sleepWakeUpStatus = [...sleepList, ...wakeUpList].some(ele => ele.enable)
|
|
71
|
+
const [checkConflict, resolveConflict] = useConflictTask(params.conflictDps)
|
|
72
|
+
|
|
73
73
|
const state = useReactive<UIState>({
|
|
74
74
|
...biorhythm,
|
|
75
75
|
showGradientTypeSelectModal: false,
|
|
@@ -269,6 +269,29 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
|
|
|
269
269
|
thumbColor={props.theme?.icon.primary}
|
|
270
270
|
trackColor={{ false: '#00000026', true: '#ff660036' }}
|
|
271
271
|
onValueChange={async enable => {
|
|
272
|
+
const biorhythmTask = {
|
|
273
|
+
startTime: 0,
|
|
274
|
+
endTime: 1440,
|
|
275
|
+
weeks: biorhythm.repeatPeriod.map(item => item.enabled ? 1 : 0),
|
|
276
|
+
enable: biorhythm.enable
|
|
277
|
+
}
|
|
278
|
+
if (enable && checkConflict(biorhythmTask)) {
|
|
279
|
+
return showCommonDialog({
|
|
280
|
+
method: 'confirm',
|
|
281
|
+
title: I18n.getLang('conflict_dialog_active_item_bio_rhythm_titel'),
|
|
282
|
+
subTitle: I18n.getLang('conflict_dialog_active_item_bio_rhythm_description'),
|
|
283
|
+
onConfirm: (_, { close }) => {
|
|
284
|
+
resolveConflict()
|
|
285
|
+
close()
|
|
286
|
+
state.loading = true
|
|
287
|
+
state.enable = enable
|
|
288
|
+
requestSetBiorhythm(false)
|
|
289
|
+
},
|
|
290
|
+
onCancel: () => {
|
|
291
|
+
Dialog.close()
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
}
|
|
272
295
|
state.loading = true
|
|
273
296
|
state.enable = enable
|
|
274
297
|
requestSetBiorhythm(false)
|