@ledvance/ui-biz-bundle 1.1.81 → 1.1.83
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
CHANGED
|
@@ -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 { useProgress
|
|
14
|
+
import {timeFormatToRealTime, 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";
|
|
@@ -123,14 +123,6 @@ const TimerPage = (props: {theme?: any}) => {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
const getSingleLightEndTimeString = (mCountdown: number) => {
|
|
127
|
-
const date = new Date()
|
|
128
|
-
const now = date.getTime()
|
|
129
|
-
const after = new Date(now + mCountdown * 1000)
|
|
130
|
-
const timeString = `${after.getHours()}:${after.getMinutes().toString().padStart(2, '0')}`
|
|
131
|
-
return timeString
|
|
132
|
-
}
|
|
133
|
-
|
|
134
126
|
const showActiveView = () => {
|
|
135
127
|
return progress.length > 1
|
|
136
128
|
}
|
|
@@ -317,7 +309,7 @@ const TimerPage = (props: {theme?: any}) => {
|
|
|
317
309
|
/>
|
|
318
310
|
<Text style={{ marginLeft: cx(20), fontSize: cx(22) }}>{getActiveTimeString(timer.progressHook.countdown)}</Text>
|
|
319
311
|
</View>
|
|
320
|
-
<Text>{I18n.formatValue(timer.enable ? timer.stringOff : timer.stringOn,
|
|
312
|
+
<Text>{I18n.formatValue(timer.enable ? timer.stringOff : timer.stringOn, timeFormatToRealTime(timer.progressHook.countdown))}</Text>
|
|
321
313
|
</Card>
|
|
322
314
|
<Spacer height={cx(40)} />
|
|
323
315
|
</View>
|
|
@@ -363,7 +355,7 @@ const TimerPage = (props: {theme?: any}) => {
|
|
|
363
355
|
{I18n.formatValue(
|
|
364
356
|
runningTimer()[0].enable ?
|
|
365
357
|
runningTimer()[0].stringOff :
|
|
366
|
-
runningTimer()[0].stringOn,
|
|
358
|
+
runningTimer()[0].stringOn, timeFormatToRealTime(runningTimer()[0].progressHook.countdown)
|
|
367
359
|
)}
|
|
368
360
|
</Text>
|
|
369
361
|
</View>
|
|
@@ -130,6 +130,13 @@ export const useProgress = (dps: dpItem[]) => {
|
|
|
130
130
|
}))
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
export function timeFormatToRealTime(mCountdown: number) {
|
|
134
|
+
const date = new Date()
|
|
135
|
+
const now = date.getTime()
|
|
136
|
+
const after = new Date(now + mCountdown * 1000)
|
|
137
|
+
return `${after.getHours()}:${after.getMinutes().toString().padStart(2, '0')}`
|
|
138
|
+
}
|
|
139
|
+
|
|
133
140
|
export function timeFormat(time: number): string {
|
|
134
141
|
let hour = Math.trunc(time / 3600)
|
|
135
142
|
const beforeMin = (time % 3600) / 60
|
|
@@ -92,6 +92,7 @@ export interface DefMoodOption extends LightCategory{
|
|
|
92
92
|
isSupportColor: boolean;
|
|
93
93
|
isSupportTemperature: boolean;
|
|
94
94
|
isSupportBrightness: boolean;
|
|
95
|
+
isSupportSceneStatus?: boolean;// putFeature中的SceneStatus,包含Flag和Mood选中的ID
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export interface MoodDps {
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
stripDp2Obj,
|
|
20
20
|
stripObj2Dp,
|
|
21
21
|
} from './MoodParse';
|
|
22
|
-
import { useDp, useDps
|
|
23
|
-
import { useState
|
|
22
|
+
import {useDeviceId, useDp, useDps} from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
23
|
+
import {useCallback, useEffect, useState} from 'react';
|
|
24
24
|
import { useUpdateEffect } from 'ahooks';
|
|
25
|
-
import { WorkMode } from '@ledvance/base/src/utils/interface';
|
|
25
|
+
import {SceneStatusType, WorkMode } from '@ledvance/base/src/utils/interface';
|
|
26
26
|
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
27
27
|
|
|
28
28
|
const SceneFeatureId = 'SimplifyScene';
|
|
@@ -241,3 +241,31 @@ export const saveMoodList = (
|
|
|
241
241
|
: SceneFeatureId;
|
|
242
242
|
return setRemoteMoodList(devId, isFeature, remoteMoods, moodFeatureId);
|
|
243
243
|
};
|
|
244
|
+
|
|
245
|
+
export function useSceneStatusId(params: MoodPageParams): [number, (moodId: number) => Promise<any>] {
|
|
246
|
+
const devId = useDeviceId();
|
|
247
|
+
const [sceneStatusId, setSceneStatusId] = useState(-1);
|
|
248
|
+
if (!params.isSupportSceneStatus) {
|
|
249
|
+
const setEmpty = useCallback(() => {
|
|
250
|
+
return new Promise<any>(() => {});
|
|
251
|
+
}, [])
|
|
252
|
+
return [sceneStatusId, setEmpty]
|
|
253
|
+
}
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
getFeature(devId, "SceneStatus").then((res) => {
|
|
256
|
+
if (res.data && res.data.type === SceneStatusType.Mood) {
|
|
257
|
+
setSceneStatusId(res.data.id)
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
}, [])
|
|
261
|
+
const setSceneStatusIdRemote = useCallback((moodId: number) => {
|
|
262
|
+
return new Promise<any>((resolve, _reject) => {
|
|
263
|
+
putFeature(devId, "SceneStatus", {type: SceneStatusType.Mood, id: moodId}).then((res) => {
|
|
264
|
+
setSceneStatusId(moodId);
|
|
265
|
+
resolve(res);
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
}, [])
|
|
269
|
+
|
|
270
|
+
return [sceneStatusId, setSceneStatusIdRemote]
|
|
271
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import Page from '@ledvance/base/src/components/Page';
|
|
3
3
|
import { Utils } from 'tuya-panel-kit';
|
|
4
|
-
import {
|
|
4
|
+
import {saveMoodList, useSceneStatusId, useSwitchLed, useWorkMode} from './MoodActions';
|
|
5
5
|
import {
|
|
6
6
|
useDeviceId,
|
|
7
7
|
useDeviceInfo,
|
|
@@ -41,6 +41,7 @@ const MoodPage = () => {
|
|
|
41
41
|
const [secondaryWork, setSecondaryWork] = useWorkMode(params.secondaryWorkMode!);
|
|
42
42
|
const [switchLed] = useSwitchLed(params.switchLedDp)
|
|
43
43
|
const [flagMode, setFlagMode] = useFlagMode();
|
|
44
|
+
const [sceneStatusId, setSceneStatusId] = useSceneStatusId(params);
|
|
44
45
|
|
|
45
46
|
const state = useReactive<MoodPageState>({
|
|
46
47
|
currentMood: undefined,
|
|
@@ -160,7 +161,9 @@ const MoodPage = () => {
|
|
|
160
161
|
},
|
|
161
162
|
};
|
|
162
163
|
if (mode === 'set') {
|
|
163
|
-
|
|
164
|
+
await setMoodInfo(checkedMood);
|
|
165
|
+
await setSceneStatusId(checkedMood.id);
|
|
166
|
+
return;
|
|
164
167
|
}
|
|
165
168
|
let newScene: MoodUIInfo[] = [];
|
|
166
169
|
if (mode === 'add') {
|
|
@@ -197,18 +200,20 @@ const MoodPage = () => {
|
|
|
197
200
|
if (mood) {
|
|
198
201
|
if (mode === 'del') {
|
|
199
202
|
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
(mainWork !== WorkMode.Scene && secondaryWork !== WorkMode.Scene) ||
|
|
204
|
+
(params.isCeilingLight
|
|
205
|
+
? currentMood.mainLamp.id !== moodInfo.mainLamp.id &&
|
|
206
|
+
currentMood.secondaryLamp.id !== moodInfo.secondaryLamp.id
|
|
207
|
+
: (params.isSupportSceneStatus ? currentMood.id !== sceneStatusId : currentMood.id !== moodInfo.id)) || !switchLed
|
|
205
208
|
) {
|
|
206
209
|
return {
|
|
207
210
|
success: true,
|
|
208
211
|
};
|
|
209
212
|
}
|
|
210
213
|
}
|
|
211
|
-
setMoodInfo(mood).then()
|
|
214
|
+
setMoodInfo(mood).then(() => {
|
|
215
|
+
setSceneStatusId(mood.id).then();
|
|
216
|
+
});
|
|
212
217
|
} else {
|
|
213
218
|
if (mainWork === WorkMode.Scene) {
|
|
214
219
|
if (params.isCeilingLight) {
|
|
@@ -266,18 +271,20 @@ const MoodPage = () => {
|
|
|
266
271
|
);
|
|
267
272
|
|
|
268
273
|
const getItemEnable = useCallback(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
(moodItem: MoodUIInfo) => {
|
|
275
|
+
if (params.isCeilingLight) {
|
|
276
|
+
return (
|
|
277
|
+
moodInfo.mainLamp.id === moodItem.mainLamp.id &&
|
|
278
|
+
moodInfo.secondaryLamp.id === moodItem.secondaryLamp.id &&
|
|
279
|
+
(mainWork === WorkMode.Scene || secondaryWork === WorkMode.Scene) && !flagMode.flagMode && switchLed
|
|
280
|
+
);
|
|
281
|
+
} else if (params.isSupportSceneStatus) {
|
|
282
|
+
return sceneStatusId === moodItem.id && mainWork === WorkMode.Scene && !flagMode.flagMode && switchLed
|
|
283
|
+
} else {
|
|
284
|
+
return moodInfo.id === moodItem.id && mainWork === WorkMode.Scene && !flagMode.flagMode && switchLed
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
[moodInfo, mainWork, secondaryWork, flagMode?.flagMode, switchLed, sceneStatusId]
|
|
281
288
|
);
|
|
282
289
|
|
|
283
290
|
const nameRepeat = useCallback((mood: MoodUIInfo) => {
|