@ledvance/ui-biz-bundle 1.0.8 → 1.0.10
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 +2 -2
- package/src/{modules/hooks → hooks}/DeviceDpStateHooks.ts +12 -1
- package/src/modules/history/HistoryPage.tsx +5 -5
- package/src/modules/history/SwitchHistoryPageActions.ts +28 -5
- package/src/modules/mood/AddMoodPage.tsx +771 -0
- package/src/modules/mood/DynamicMoodEditorPage.tsx +540 -0
- package/src/modules/mood/MoodItem.tsx +10 -10
- package/src/modules/mood/MoodPage.tsx +246 -0
- package/src/modules/mood/RecommendMoodItem.tsx +75 -0
- package/src/modules/mood/StaticMoodEditorPage.tsx +292 -0
- package/src/modules/mood/tools.ts +12 -0
- package/src/modules/{mood/MoodAction.ts → scene/SceneAction.ts} +31 -37
- package/src/modules/scene/SceneDetailPage.tsx +422 -0
- package/src/modules/{mood → scene}/SceneInfo.ts +48 -1
- package/src/modules/scene/ScenePage.tsx +148 -0
- package/src/modules/select/SelectPage.tsx +140 -0
- package/src/modules/timeSchedule/DeviceState.tsx +6 -4
- package/src/modules/timeSchedule/ManualSetting.tsx +13 -31
- package/src/modules/timeSchedule/MoodSetting.tsx +11 -11
- package/src/modules/timeSchedule/ScheduleScene.tsx +9 -7
- package/src/modules/timeSchedule/SingleLightView.tsx +119 -72
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +9 -11
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +12 -8
- package/src/modules/timeSchedule/mix/MixLightView.tsx +4 -5
- package/src/navigation/tools.ts +21 -0
- package/src/modules/mood/MixLightActions.ts +0 -82
- package/src/modules/mood/MixLightSceneActions.ts +0 -259
- package/src/modules/mood/MixMoodItem.tsx +0 -137
- package/src/modules/mood/MixScene.tsx +0 -131
- package/src/modules/mood/MixSceneBeans.ts +0 -62
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"name": "@ledvance/ui-biz-bundle",
|
|
5
5
|
"pid": [],
|
|
6
6
|
"uiid": "",
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.10",
|
|
8
8
|
"scripts": {},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@ledvance/base": "^1.
|
|
10
|
+
"@ledvance/base": "^1.x",
|
|
11
11
|
"@reduxjs/toolkit": "^1.8.6",
|
|
12
12
|
"@tuya/tuya-panel-api": "^1.12.0",
|
|
13
13
|
"@tuya/tuya-panel-lamp-sdk": "^1.14.1",
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
2
|
+
import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
3
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
2
4
|
export const WHITE = 'white'
|
|
3
5
|
export const COLOUR = 'colour'
|
|
4
6
|
export const SCENE = 'scene'
|
|
5
7
|
export const MUSIC = 'music'
|
|
6
8
|
|
|
9
|
+
export const modeOptions = [
|
|
10
|
+
{label: 'Classic', value: 'normal'},
|
|
11
|
+
{label: 'Nature', value: 'nature'},
|
|
12
|
+
]
|
|
13
|
+
|
|
7
14
|
export const setBiorhythmDp = (deviceId: string, value: string, dpCodes: Record<string, string>) => {
|
|
8
15
|
return NativeApi.setDp(deviceId, dpCodes.rhythm_mode, value)
|
|
9
16
|
}
|
|
@@ -24,4 +31,8 @@ export const setSceneDp = (deviceId: string, value: string, dpCodes: Record<stri
|
|
|
24
31
|
|
|
25
32
|
export const setMixSceneDp = (deviceId: string, value: string, dpCodes: Record<string, string>) => {
|
|
26
33
|
return NativeApi.setDps(deviceId, { [dpCodes.work_mode]: 'scene', [dpCodes.mix_light_scene]: value })
|
|
27
|
-
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const useWorkMode = (dpCodes: Record<string,string>): [string, (mode: string) => Promise<Result<any>>] => {
|
|
37
|
+
return useDp(dpCodes.work_mode);
|
|
38
|
+
}
|
|
@@ -15,7 +15,7 @@ import Tag from "@ledvance/base/src/components/Tag"
|
|
|
15
15
|
const cx = Utils.RatioUtils.convertX
|
|
16
16
|
|
|
17
17
|
type SwitchHistoryPageRouteParams = {
|
|
18
|
-
params: { dpIds: string[], tags?: object }
|
|
18
|
+
params: { dpIds: string[], tags?: object, headlineText: string, backText?: string, stringOff?:string, stringOn?: string, showLimit?: boolean, actionKey?:string}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
type Props = {
|
|
@@ -24,7 +24,7 @@ type Props = {
|
|
|
24
24
|
|
|
25
25
|
const SwitchHistoryPage = () => {
|
|
26
26
|
const deviceInfo = useDeviceInfo()
|
|
27
|
-
const { dpIds, tags } = useRoute<Props['route']>().params
|
|
27
|
+
const { dpIds, tags ,headlineText, backText, stringOff, stringOn, actionKey, showLimit } = useRoute<Props['route']>().params
|
|
28
28
|
|
|
29
29
|
const state = useReactive<SwitchHistoryPageState>({
|
|
30
30
|
refreshing: true,
|
|
@@ -68,7 +68,7 @@ const SwitchHistoryPage = () => {
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
useEffect(() => {
|
|
71
|
-
getSwitchHistoryData(deviceInfo.devId, getRequestIds(), state.dataOffset)
|
|
71
|
+
getSwitchHistoryData(deviceInfo.devId, getRequestIds(), state.dataOffset, 100, stringOn, stringOff, actionKey, showLimit)
|
|
72
72
|
.then(res => {
|
|
73
73
|
state.refreshing = false
|
|
74
74
|
state.data = res.data
|
|
@@ -79,8 +79,8 @@ const SwitchHistoryPage = () => {
|
|
|
79
79
|
|
|
80
80
|
return (
|
|
81
81
|
<Page
|
|
82
|
-
backText={deviceInfo.name}
|
|
83
|
-
headlineText={I18n.getLang('history_socket_headline_text')}
|
|
82
|
+
backText={backText || deviceInfo.name}
|
|
83
|
+
headlineText={headlineText || I18n.getLang('history_socket_headline_text')}
|
|
84
84
|
headlineIcon={res.rn_ic_download}>
|
|
85
85
|
<View style={styles.content}>
|
|
86
86
|
<Text style={styles.titleText}>{I18n.getLang('history_contact_sensor_description_text')}</Text>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getDpReportSataData, PagingResult } from '@ledvance/base/src/models/TuyaApi'
|
|
2
|
-
import { groupBy, isEqual, uniqWith } from 'lodash'
|
|
2
|
+
import { cloneDeep, groupBy, isEqual, uniqWith } from 'lodash'
|
|
3
3
|
import dayjs from 'dayjs'
|
|
4
4
|
import I18n from '@ledvance/base/src/i18n'
|
|
5
|
+
import duration from 'dayjs/plugin/duration'
|
|
6
|
+
dayjs.extend(duration)
|
|
5
7
|
export interface SwitchHistoryUIItemData {
|
|
6
8
|
title: string
|
|
7
9
|
actions: SwitchHistoryUIItemActionData[]
|
|
@@ -24,17 +26,38 @@ export interface SwitchHistoryUIItemActionData {
|
|
|
24
26
|
dpId: string
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
const formateLimitTime = (time: number) =>{
|
|
30
|
+
const duration = dayjs.duration(time * 1000);
|
|
31
|
+
const hours = duration.hours();
|
|
32
|
+
const minutes = duration.minutes();
|
|
33
|
+
const seconds = duration.seconds();
|
|
34
|
+
const hoursString = ` ${hours}h ${minutes}min ${seconds}sec`
|
|
35
|
+
const minutesString = ` ${minutes}min ${seconds}sec`
|
|
36
|
+
const secondsString = ` ${seconds}sec`
|
|
37
|
+
const v = hours > 0 ? hoursString : (hours > 0 || minutes > 0) ? minutesString : secondsString
|
|
38
|
+
return v
|
|
39
|
+
// return ` ${hours > 0 ? hours + 'h' : ''} ${(minutes > 0 || hours > 0) ? minutes + 'min' : ''} ${seconds}sec`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type getSwitchHistoryDataFunType = (deviceId: string, dpIds: string[], offset: number, limit?: number, stringOn?:string, stringOff?:string, actionKey?:string, showLimit?:boolean) => Promise<PagingResult<SwitchHistoryUIItemData[]>>
|
|
28
43
|
|
|
29
|
-
export const getSwitchHistoryData: getSwitchHistoryDataFunType = async (deviceId: string, dpIds: string[], offset: number, limit: number = 100) => {
|
|
44
|
+
export const getSwitchHistoryData: getSwitchHistoryDataFunType = async (deviceId: string, dpIds: string[], offset: number, limit: number = 100, stringOn, stringOff, actionKey, showLimit) => {
|
|
30
45
|
const res = await getDpReportSataData(deviceId, dpIds, 0, offset + limit)
|
|
31
46
|
const uniqData = uniqWith(res.dps, isEqual)
|
|
32
|
-
const
|
|
47
|
+
const reverseData = cloneDeep(uniqData).reverse()
|
|
48
|
+
const limitTimeData = reverseData.map((item, idx) =>{
|
|
49
|
+
return {
|
|
50
|
+
...item,
|
|
51
|
+
limitTime: reverseData[idx + 1] ? formateLimitTime(reverseData[idx + 1].timeStamp - item.timeStamp) : ''
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
const key = actionKey || 'true'
|
|
55
|
+
const dateActionsMap = groupBy(limitTimeData.reverse().map(dpData => {
|
|
33
56
|
const dayjsDate = dayjs(dpData.timeStr)
|
|
34
57
|
return {
|
|
35
58
|
date: `${dayjsDate.format('DD/MM/YYYY')} (${weekList[dayjsDate.format('ddd')]})`,
|
|
36
59
|
time: dayjsDate.format('HH:mm:ss'),
|
|
37
|
-
action: I18n.formatValue(dpData.value ===
|
|
60
|
+
action: I18n.formatValue(dpData.value === key ? (stringOn || 'history_powerstrip_field1_text') : (stringOff || 'history_powerstrip_field1_text2'), '', showLimit ? dpData.limitTime : ''),
|
|
38
61
|
dpId: dpData.dpId,
|
|
39
62
|
}
|
|
40
63
|
}), 'date')
|