@ledvance/group-ui-biz-bundle 1.0.23 → 1.0.25
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/flags/FlagActions.ts +48 -87
- package/src/modules/flags/FlagEditPage.tsx +1 -1
- package/src/modules/flags/FlagPage.tsx +2 -2
- package/src/modules/mood/DynamicMoodEditorPage.tsx +4 -4
- package/src/modules/mood/MoodPage.tsx +2 -2
- package/src/modules/mood/StaticMoodEditorPage.tsx +3 -4
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useFeatureHook } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
2
|
-
import { SceneNodeTransitionMode } from "@ledvance/group-ui-biz-bundle/src/modules/mood/SceneInfo";
|
|
3
2
|
import { parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
4
3
|
import { cloneDeep } from "lodash";
|
|
5
4
|
import { FlagItemInfo, FlagUiInfo, defFlagList, def2FlagList, def3FlagList } from "./FlagInfo";
|
|
6
|
-
import { hex2Int } from "@ledvance/base/src/utils/common";
|
|
7
|
-
import { spliceByStep } from "@ledvance/base/src/utils/common";
|
|
8
5
|
import { NativeApi } from "@ledvance/base/src/api/native";
|
|
9
6
|
import { hsv2Hex } from "@ledvance/base/src/utils";
|
|
10
7
|
import { WorkMode } from "@ledvance/base/src/utils/interface";
|
|
8
|
+
import { Utils } from '@tuya/tuya-panel-lamp-sdk'
|
|
9
|
+
const { nToHS, toFixed } = Utils
|
|
11
10
|
|
|
12
11
|
interface LightType {
|
|
13
12
|
isStringLight?: boolean
|
|
@@ -48,7 +47,7 @@ export const useFlag: UseFlagType = (params) => {
|
|
|
48
47
|
dps[workModeDpCode] = WorkMode.Colour
|
|
49
48
|
}else{
|
|
50
49
|
if(sceneStatus){
|
|
51
|
-
dps[sceneStatus.sceneDataDpCode] =
|
|
50
|
+
dps[sceneStatus.sceneDataDpCode] = flag ? obj2Dp(flag, {isMixLight: params.isMixLight, isStringLight: params.isStringLight}) : ''
|
|
52
51
|
dps[workModeDpCode] = WorkMode.Scene
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -60,16 +59,13 @@ export const useFlag: UseFlagType = (params) => {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
export interface FlagOption {
|
|
63
|
-
isFan?: boolean
|
|
64
|
-
isUVCFan?: boolean
|
|
65
62
|
isMixLight?: boolean
|
|
63
|
+
isStringLight?: boolean
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
|
|
69
|
-
let fanEnableHex = ''
|
|
70
|
-
let fanSpeedHex = ''
|
|
71
67
|
const version = '00'
|
|
72
|
-
const idHex = flagItem.id
|
|
68
|
+
const idHex = nToHS(flagItem.id)
|
|
73
69
|
if (option?.isMixLight) {
|
|
74
70
|
const whiteEnable = '01'
|
|
75
71
|
const whiteNum = '01'
|
|
@@ -77,36 +73,58 @@ export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
|
|
|
77
73
|
const whiteHex = whiteEnable + whiteNum + whiteStatus + flagItem.whiteColors.map(colors => {
|
|
78
74
|
const speed = '00'
|
|
79
75
|
const mode = '00'
|
|
80
|
-
const bHex = (colors.brightness * 10
|
|
81
|
-
const tHex = (colors.colorTemp * 10
|
|
76
|
+
const bHex = nToHS(colors.brightness * 10, 4)
|
|
77
|
+
const tHex = nToHS(colors.colorTemp * 10, 4)
|
|
82
78
|
return speed + speed + mode + bHex + tHex
|
|
83
79
|
}).join('')
|
|
84
80
|
const colorEnable = '01'
|
|
85
|
-
const colorNum = flagItem.colors.length
|
|
81
|
+
const colorNum = nToHS(flagItem.colors.length)
|
|
86
82
|
const colorStatus = '03'
|
|
87
83
|
const colorHex = colorEnable + colorNum + colorStatus + flagItem.colors.map(item => {
|
|
88
|
-
const speed = flagItem.speed
|
|
89
|
-
const mode = flagItem.mode
|
|
90
|
-
const hHex = item.h
|
|
91
|
-
const sHex = (item.s * 10
|
|
92
|
-
const vHex = (item.v * 10
|
|
84
|
+
const speed = nToHS(flagItem.speed)
|
|
85
|
+
const mode = nToHS(flagItem.mode)
|
|
86
|
+
const hHex = nToHS(item.h, 4)
|
|
87
|
+
const sHex = nToHS(item.s * 10, 4)
|
|
88
|
+
const vHex = nToHS(item.v * 10, 4)
|
|
93
89
|
return speed + speed + mode + hHex + sHex + vHex
|
|
94
90
|
}).join('')
|
|
95
91
|
return version + idHex + whiteHex + colorHex
|
|
92
|
+
} else if (option?.isStringLight) {
|
|
93
|
+
const version = '00'
|
|
94
|
+
const idHex = nToHS(flagItem.id)
|
|
95
|
+
const expand = 0
|
|
96
|
+
const reserved1 = 0
|
|
97
|
+
const reserved2 = 0
|
|
98
|
+
const loop = 0
|
|
99
|
+
const excessive = 0
|
|
100
|
+
const direction = 0
|
|
101
|
+
const segmented = 0
|
|
102
|
+
const modeHex = nToHS(10)
|
|
103
|
+
const intervalTimeHex = nToHS(flagItem.speed)
|
|
104
|
+
const changeTimeHex = nToHS(flagItem.speed)
|
|
105
|
+
const optionAHex = nToHS(
|
|
106
|
+
parseInt(
|
|
107
|
+
`${segmented}${loop}${excessive}${direction}${toFixed(
|
|
108
|
+
expand.toString(2),
|
|
109
|
+
2
|
|
110
|
+
)}${reserved1}${reserved2}`,
|
|
111
|
+
2
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
const optionBHex = nToHS(0)
|
|
115
|
+
const optionCHex = nToHS(0)
|
|
116
|
+
const nodeHex = flagItem.colors.map(node => {
|
|
117
|
+
return `${nToHS(node.v)}${nToHS(node.h, 4)}${nToHS(node.s)}${nToHS(0, 4)}${nToHS(0, 4)}`
|
|
118
|
+
}).join('')
|
|
119
|
+
return version + idHex + modeHex + intervalTimeHex + changeTimeHex + optionAHex + optionBHex + optionCHex + nodeHex
|
|
96
120
|
} else {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const transitionTimeHex = (option?.isUVCFan ? 101 - flagItem.speed : flagItem.speed).toString(16).padStart(2, '0')
|
|
105
|
-
const transitionModeHex = flagItem.mode.toString(16).padStart(2, '0')
|
|
106
|
-
const hex = idHex + fanEnableHex + fanSpeedHex + flagItem.colors.map(color => {
|
|
107
|
-
const hHex = Math.round(color.h).toString(16).padStart(4, '0')
|
|
108
|
-
const sHex = Math.round(color.s * 10).toString(16).padStart(4, '0')
|
|
109
|
-
const vHex = Math.round(color.v * 10).toString(16).padStart(4, '0')
|
|
121
|
+
const switchingIntervalHex = nToHS(flagItem.speed)
|
|
122
|
+
const transitionTimeHex = nToHS(flagItem.speed)
|
|
123
|
+
const transitionModeHex = nToHS(flagItem.mode)
|
|
124
|
+
const hex = idHex + flagItem.colors.map(color => {
|
|
125
|
+
const hHex = nToHS(Math.round(color.h), 4)
|
|
126
|
+
const sHex = nToHS(Math.round(color.s * 10), 4)
|
|
127
|
+
const vHex = nToHS(Math.round(color.v * 10), 4)
|
|
110
128
|
const brightnessHex = '0000'
|
|
111
129
|
const colorTempHex = '0000'
|
|
112
130
|
return switchingIntervalHex + transitionTimeHex + transitionModeHex + hHex + sHex + vHex + brightnessHex + colorTempHex
|
|
@@ -115,63 +133,6 @@ export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
|
|
|
115
133
|
}
|
|
116
134
|
}
|
|
117
135
|
|
|
118
|
-
export function dp2Obj(dp: string, option?: FlagOption): FlagItemInfo | undefined {
|
|
119
|
-
if (!dp) return
|
|
120
|
-
const result = {} as FlagItemInfo
|
|
121
|
-
if (option?.isMixLight) {
|
|
122
|
-
result.version = hex2Int(dp.slice(0, 2))
|
|
123
|
-
result.id = hex2Int(dp.slice(2, 4))
|
|
124
|
-
let lampHex = dp.slice(16)
|
|
125
|
-
result.whiteColors = [
|
|
126
|
-
{ brightness: hex2Int(lampHex.slice(0, 4)) / 10, colorTemp: hex2Int(lampHex.slice(4, 8)) / 10 }
|
|
127
|
-
]
|
|
128
|
-
lampHex = lampHex.slice(14)
|
|
129
|
-
result.colors = spliceByStep(lampHex, 18).map(lamp => {
|
|
130
|
-
result.speed = hex2Int(lamp.slice(0, 2))
|
|
131
|
-
result.mode = hex2Int(lamp.slice(4, 6))
|
|
132
|
-
return {
|
|
133
|
-
h: hex2Int(lamp.slice(6, 10)),
|
|
134
|
-
s: hex2Int(lamp.slice(10, 14)) / 10,
|
|
135
|
-
v: hex2Int(lamp.slice(14, 18)) / 10
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
return result
|
|
139
|
-
} else {
|
|
140
|
-
const id = hex2Int(dp.slice(0, 2))
|
|
141
|
-
let fanEnable: any = undefined
|
|
142
|
-
let fanSpeed: any = undefined
|
|
143
|
-
if (option?.isFan) {
|
|
144
|
-
fanEnable = hex2Int(dp.slice(2, 4)) === 1
|
|
145
|
-
fanSpeed = hex2Int(dp.slice(4, 6))
|
|
146
|
-
}
|
|
147
|
-
const c = option?.isFan ? 6 : 2
|
|
148
|
-
const sliceDp = dp.slice(c)
|
|
149
|
-
let mode = SceneNodeTransitionMode.Jump
|
|
150
|
-
let speed = 70
|
|
151
|
-
const colors = spliceByStep(sliceDp, 26).map(nodeHex => {
|
|
152
|
-
speed = option?.isUVCFan ? 101 - hex2Int(nodeHex.slice(0, 2)) : hex2Int(nodeHex.slice(0, 2))
|
|
153
|
-
mode = hex2Int(nodeHex.slice(4, 6))
|
|
154
|
-
const h = hex2Int(nodeHex.slice(6, 10))
|
|
155
|
-
const s = hex2Int(nodeHex.slice(10, 14))
|
|
156
|
-
const v = hex2Int(nodeHex.slice(14, 18))
|
|
157
|
-
return {
|
|
158
|
-
h,
|
|
159
|
-
s: s / 10,
|
|
160
|
-
v: v / 10
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
const whiteColors = [{ brightness: 100, colorTemp: 0 }]
|
|
164
|
-
return {
|
|
165
|
-
id,
|
|
166
|
-
mode,
|
|
167
|
-
speed,
|
|
168
|
-
colors,
|
|
169
|
-
whiteColors
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
136
|
interface defFlagOption {
|
|
176
137
|
isDef2?: boolean
|
|
177
138
|
isDef3?: boolean
|
|
@@ -11,7 +11,7 @@ import TextField from '@ledvance/base/src/components/TextField'
|
|
|
11
11
|
import Card from '@ledvance/base/src/components/Card'
|
|
12
12
|
import LdvSlider from '@ledvance/base/src/components/ldvSlider'
|
|
13
13
|
import TextButton from '@ledvance/base/src/components/TextButton'
|
|
14
|
-
import {
|
|
14
|
+
import { hsv2Hex } from '@ledvance/base/src/utils'
|
|
15
15
|
import { cloneDeep, find, isEqual } from 'lodash'
|
|
16
16
|
import { FlagUiInfo } from './FlagInfo'
|
|
17
17
|
import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView'
|
|
@@ -58,7 +58,7 @@ const FlagPage = () => {
|
|
|
58
58
|
const defParams = {
|
|
59
59
|
workModeDpCode: params.workModeCode,
|
|
60
60
|
switchLedDpCode: params.switchLedCode,
|
|
61
|
-
workMode: WorkMode.Scene,
|
|
61
|
+
workMode: params.isStripLight ? WorkMode.Colour : WorkMode.Scene,
|
|
62
62
|
sceneStatus: !params.isStripLight && params.sceneDataCode ? {
|
|
63
63
|
sceneDataDpCode: params.sceneDataCode
|
|
64
64
|
} : undefined,
|
|
@@ -192,7 +192,6 @@ const FlagPage = () => {
|
|
|
192
192
|
flagId: flag?.id
|
|
193
193
|
})
|
|
194
194
|
}
|
|
195
|
-
|
|
196
195
|
return (
|
|
197
196
|
<Page
|
|
198
197
|
headlineText={I18n.getLang('Feature_devicepanel_flags')}
|
|
@@ -216,6 +215,7 @@ const FlagPage = () => {
|
|
|
216
215
|
onChangeText={(v)=>{
|
|
217
216
|
state.searchText = v
|
|
218
217
|
}}
|
|
218
|
+
placeholder={I18n.getLang('country_selection_textfield_headline_search')}
|
|
219
219
|
/>
|
|
220
220
|
<FlatList
|
|
221
221
|
data={state.flags}
|
|
@@ -340,12 +340,12 @@ const DynamicMoodEditorPage = () => {
|
|
|
340
340
|
state.mood.nodes.forEach(node => {
|
|
341
341
|
node.isColorNode = true
|
|
342
342
|
node.h = h
|
|
343
|
-
node.s = s
|
|
343
|
+
node.s = s || 1
|
|
344
344
|
node.v = v
|
|
345
345
|
})
|
|
346
346
|
} else {
|
|
347
347
|
state.currentNode.h = h
|
|
348
|
-
state.currentNode.s = s
|
|
348
|
+
state.currentNode.s = s || 1
|
|
349
349
|
state.currentNode.v = v
|
|
350
350
|
}
|
|
351
351
|
}}
|
|
@@ -354,12 +354,12 @@ const DynamicMoodEditorPage = () => {
|
|
|
354
354
|
state.mood.nodes.forEach(node => {
|
|
355
355
|
node.isColorNode = true
|
|
356
356
|
node.h = h
|
|
357
|
-
node.s = s
|
|
357
|
+
node.s = s || 1
|
|
358
358
|
node.v = v
|
|
359
359
|
})
|
|
360
360
|
} else {
|
|
361
361
|
state.currentNode.h = h
|
|
362
|
-
state.currentNode.s = s
|
|
362
|
+
state.currentNode.s = s || 1
|
|
363
363
|
state.currentNode.v = v
|
|
364
364
|
}
|
|
365
365
|
}}
|
|
@@ -195,7 +195,7 @@ const MoodPage = () => {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
const updateFlagMode = () =>{
|
|
198
|
-
if(flagMode && params.isSupportColor){
|
|
198
|
+
if(flagMode?.flagMode && params.isSupportColor){
|
|
199
199
|
saveFlagMode(uaGroupInfo.tyGroupId.toString(), JSON.stringify({
|
|
200
200
|
flagMode: false,
|
|
201
201
|
flagId: undefined
|
|
@@ -274,7 +274,7 @@ const MoodPage = () => {
|
|
|
274
274
|
renderItem={({ item }) => {
|
|
275
275
|
return (
|
|
276
276
|
<MoodItem
|
|
277
|
-
enable={switchLed && workMode === WorkMode.Scene && scene?.scene?.id === item.id}
|
|
277
|
+
enable={switchLed && workMode === WorkMode.Scene && scene?.scene?.id === item.id && !flagMode?.flagMode}
|
|
278
278
|
mood={item}
|
|
279
279
|
onPress={() => {
|
|
280
280
|
navigationRoute(item.nodes.length === 1, 'edit', item)
|
|
@@ -11,7 +11,7 @@ import Card from '@ledvance/base/src/components/Card'
|
|
|
11
11
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
12
12
|
import res from '@ledvance/base/src/res'
|
|
13
13
|
import TextButton from '@ledvance/base/src/components/TextButton'
|
|
14
|
-
import { useFanMaxSpeed
|
|
14
|
+
import { useFanMaxSpeed } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
15
15
|
import { SceneNodeInfo, SceneUIState } from './SceneInfo'
|
|
16
16
|
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
17
17
|
import FanAdjustView from '@ledvance/base/src/components/FanAdjustView'
|
|
@@ -45,7 +45,6 @@ const StaticMoodEditorPage = () => {
|
|
|
45
45
|
const routeParams = useRoute().params as StaticMoodEditorPageParams
|
|
46
46
|
const params = cloneDeep(routeParams)
|
|
47
47
|
const moduleParams = params.moduleParams
|
|
48
|
-
const role = useRole()
|
|
49
48
|
|
|
50
49
|
const state = useReactive<StaticMoodEditorPageState>({
|
|
51
50
|
headline: '',
|
|
@@ -152,12 +151,12 @@ const StaticMoodEditorPage = () => {
|
|
|
152
151
|
v={state.currentNode.v}
|
|
153
152
|
onHSVChange={(h, s, v) => {
|
|
154
153
|
state.currentNode.h = h
|
|
155
|
-
state.currentNode.s = s
|
|
154
|
+
state.currentNode.s = s || 1
|
|
156
155
|
state.currentNode.v = v
|
|
157
156
|
}}
|
|
158
157
|
onHSVChangeComplete={(h, s, v) => {
|
|
159
158
|
state.currentNode.h = h
|
|
160
|
-
state.currentNode.s = s
|
|
159
|
+
state.currentNode.s = s || 1
|
|
161
160
|
state.currentNode.v = v
|
|
162
161
|
}}
|
|
163
162
|
colorTemp={state.currentNode.colorTemp}
|