@ledvance/ui-biz-bundle 1.1.7 → 1.1.8

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
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.7",
7
+ "version": "1.1.8",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -1,7 +1,7 @@
1
1
  import { useDps } from "@ledvance/base/src/models/modules/NativePropsSlice";
2
2
  import { FlagPageProps } from "./FlagPage";
3
3
  import { SceneNodeTransitionMode } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneInfo";
4
- import { WORK_MODE, parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
4
+ import { WORK_MODE, nToHS, parseJSON, toFixed } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
5
5
  import { cloneDeep } from "lodash";
6
6
  import { FlagItemInfo, FlagUiInfo, defFlagList } from "./FlagInfo";
7
7
  import { hex2Int } from "@ledvance/base/src/utils/common";
@@ -10,6 +10,7 @@ import { useMemo, useState } from "react";
10
10
  import { useUpdateEffect } from "ahooks";
11
11
  import { NativeApi } from "@ledvance/base/src/api/native";
12
12
  import { hsv2Hex } from "@ledvance/base/src/utils";
13
+ import { stripDp2Obj } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneAction";
13
14
 
14
15
  export interface ExtraParams extends FlagPageProps, FlagOption {
15
16
  }
@@ -55,24 +56,21 @@ export const useFlag: UseFlagType = (flagCode, extra) => {
55
56
  return setDps({ [flagCode]: hex })
56
57
  } else {
57
58
  const hex = obj2Dp(flagItem, extra)
58
- return setDps({ [flagCode]: hex, [extra.workModeCode]: WORK_MODE.SCENE })
59
+ return setDps({ [flagCode]: hex, [extra.workModeCode]: WORK_MODE.SCENE, [extra.switchLedCode]: true })
59
60
  }
60
61
  }
61
62
  return [flagState, setFlagFn]
62
63
  }
63
64
 
64
65
  export interface FlagOption {
65
- isFan?: boolean
66
- isUVCFan?: boolean
67
66
  isMixLight?: boolean
67
+ isStringLight?: boolean
68
68
  workModeCode: string
69
69
  }
70
70
 
71
71
  export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
72
- let fanEnableHex = ''
73
- let fanSpeedHex = ''
74
72
  const version = '00'
75
- const idHex = flagItem.id.toString(16).padStart(2, '0')
73
+ const idHex = nToHS(flagItem.id)
76
74
  if (option?.isMixLight) {
77
75
  const whiteEnable = '01'
78
76
  const whiteNum = '01'
@@ -80,34 +78,58 @@ export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
80
78
  const whiteHex = whiteEnable + whiteNum + whiteStatus + flagItem.whiteColors.map(colors => {
81
79
  const speed = '00'
82
80
  const mode = '00'
83
- const bHex = (colors.brightness * 10).toString(16).padStart(4, '0')
84
- const tHex = (colors.colorTemp * 10).toString(16).padStart(4, '0')
81
+ const bHex = nToHS(colors.brightness * 10, 4)
82
+ const tHex = nToHS(colors.colorTemp * 10, 4)
85
83
  return speed + speed + mode + bHex + tHex
86
84
  }).join('')
87
85
  const colorEnable = '01'
88
- const colorNum = flagItem.colors.length.toString(16).padStart(2, '0')
86
+ const colorNum = nToHS(flagItem.colors.length)
89
87
  const colorStatus = '03'
90
88
  const colorHex = colorEnable + colorNum + colorStatus + flagItem.colors.map(item => {
91
- const speed = flagItem.speed.toString(16).padStart(2, '0')
92
- const mode = flagItem.mode.toString(16).padStart(2, '0')
93
- const hHex = item.h.toString(16).padStart(4, '0')
94
- const sHex = (item.s * 10).toString(16).padStart(4, '0')
95
- const vHex = (item.v * 10).toString(16).padStart(4, '0')
89
+ const speed = nToHS(flagItem.speed)
90
+ const mode = nToHS(flagItem.mode)
91
+ const hHex = nToHS(item.h, 4)
92
+ const sHex = nToHS(item.s * 10, 4)
93
+ const vHex = nToHS(item.v * 10, 4)
96
94
  return speed + speed + mode + hHex + sHex + vHex
97
95
  }).join('')
98
96
  return version + idHex + whiteHex + colorHex
97
+ } else if (option?.isStringLight) {
98
+ const version = '00'
99
+ const idHex = nToHS(flagItem.id)
100
+ const expand = 0
101
+ const reserved1 = 0
102
+ const reserved2 = 0
103
+ const loop = 0
104
+ const excessive = 0
105
+ const direction = 0
106
+ const segmented = 0
107
+ const modeHex = nToHS(10)
108
+ const intervalTimeHex = nToHS(flagItem.speed)
109
+ const changeTimeHex = nToHS(flagItem.speed)
110
+ const optionAHex = nToHS(
111
+ parseInt(
112
+ `${segmented}${loop}${excessive}${direction}${toFixed(
113
+ expand.toString(2),
114
+ 2
115
+ )}${reserved1}${reserved2}`,
116
+ 2
117
+ )
118
+ );
119
+ const optionBHex = nToHS(0)
120
+ const optionCHex = nToHS(0)
121
+ const nodeHex = flagItem.colors.map(node => {
122
+ return `${nToHS(node.v)}${nToHS(node.h, 4)}${nToHS(node.s)}${nToHS(0, 4)}${nToHS(0, 4)}`
123
+ }).join('')
124
+ return version + idHex + modeHex + intervalTimeHex + changeTimeHex + optionAHex + optionBHex + optionCHex + nodeHex
99
125
  } else {
100
- if (option?.isFan) {
101
- fanEnableHex = (flagItem.fanEnable ? 1 : 0).toString(16).padStart(2, '0')
102
- fanSpeedHex = (flagItem.fanSpeed || 1).toString(16).padStart(2, '0')
103
- }
104
- const switchingIntervalHex = (option?.isUVCFan ? 101 - flagItem.speed : flagItem.speed).toString(16).padStart(2, '0')
105
- const transitionTimeHex = (option?.isUVCFan ? 101 - flagItem.speed : flagItem.speed).toString(16).padStart(2, '0')
106
- const transitionModeHex = flagItem.mode.toString(16).padStart(2, '0')
107
- const hex = idHex + fanEnableHex + fanSpeedHex + flagItem.colors.map(color => {
108
- const hHex = Math.round(color.h).toString(16).padStart(4, '0')
109
- const sHex = Math.round(color.s * 10).toString(16).padStart(4, '0')
110
- const vHex = Math.round(color.v * 10).toString(16).padStart(4, '0')
126
+ const switchingIntervalHex = nToHS(flagItem.speed)
127
+ const transitionTimeHex = nToHS(flagItem.speed)
128
+ const transitionModeHex = nToHS(flagItem.mode)
129
+ const hex = idHex + flagItem.colors.map(color => {
130
+ const hHex = nToHS(Math.round(color.h), 4)
131
+ const sHex = nToHS(Math.round(color.s * 10), 4)
132
+ const vHex = nToHS(Math.round(color.v * 10), 4)
111
133
  const brightnessHex = '0000'
112
134
  const colorTempHex = '0000'
113
135
  return switchingIntervalHex + transitionTimeHex + transitionModeHex + hHex + sHex + vHex + brightnessHex + colorTempHex
@@ -137,20 +159,27 @@ export function dp2Obj(dp: string, option?: FlagOption): FlagItemInfo | undefine
137
159
  }
138
160
  })
139
161
  return result
162
+ } else if (option?.isStringLight) {
163
+ const { speed, mode, id, nodes } = stripDp2Obj(dp, true)
164
+ const colors = nodes.map(node => ({
165
+ ...node,
166
+ s: node.s / 10,
167
+ v: node.v / 10
168
+ }))
169
+ return {
170
+ id,
171
+ mode,
172
+ speed,
173
+ whiteColors: [{ brightness: 100, colorTemp: 0 }],
174
+ colors
175
+ }
140
176
  } else {
141
177
  const id = hex2Int(dp.slice(0, 2))
142
- let fanEnable: any = undefined
143
- let fanSpeed: any = undefined
144
- if (option?.isFan) {
145
- fanEnable = hex2Int(dp.slice(2, 4)) === 1
146
- fanSpeed = hex2Int(dp.slice(4, 6))
147
- }
148
- const c = option?.isFan ? 6 : 2
149
- const sliceDp = dp.slice(c)
178
+ const sliceDp = dp.slice(2)
150
179
  let mode = SceneNodeTransitionMode.Jump
151
180
  let speed = 70
152
181
  const colors = spliceByStep(sliceDp, 26).map(nodeHex => {
153
- speed = option?.isUVCFan ? 101 - hex2Int(nodeHex.slice(0, 2)) : hex2Int(nodeHex.slice(0, 2))
182
+ speed = hex2Int(nodeHex.slice(0, 2))
154
183
  mode = hex2Int(nodeHex.slice(4, 6))
155
184
  const h = hex2Int(nodeHex.slice(6, 10))
156
185
  const s = hex2Int(nodeHex.slice(10, 14))
@@ -166,8 +195,6 @@ export function dp2Obj(dp: string, option?: FlagOption): FlagItemInfo | undefine
166
195
  id,
167
196
  mode,
168
197
  speed,
169
- fanEnable,
170
- fanSpeed,
171
198
  colors,
172
199
  whiteColors
173
200
  }
@@ -72,6 +72,7 @@ const FlagEditPage = () => {
72
72
  <Page
73
73
  backText={I18n.getLang('mesh_device_detail_mode')}
74
74
  showBackDialog={true}
75
+ loading={state.loading}
75
76
  backDialogTitle={
76
77
  I18n.getLang(params.mode === 'add' ?
77
78
  'flag_canceladding' :
@@ -87,7 +88,6 @@ const FlagEditPage = () => {
87
88
  if (state.loading) return
88
89
  state.loading = true
89
90
  const res = await params.modDeleteFlag(params.mode, state.mood)
90
- console.log(res, '< --- resss')
91
91
  if (res.success) {
92
92
  state.loading = false
93
93
  navigation.goBack()
@@ -19,8 +19,6 @@ export interface FlagItemInfo {
19
19
  speed: number
20
20
  colors: HSV[]
21
21
  whiteColors: BT []
22
- fanEnable?: boolean
23
- fanSpeed?: number
24
22
  }
25
23
 
26
24
  export interface FlagUiInfo extends FlagItemInfo{
@@ -24,8 +24,7 @@ export interface FlagPageProps {
24
24
  isSupportColor?: boolean
25
25
  isSupportBrightness?: boolean
26
26
  isSupportTemperature?: boolean
27
- isSupportFan?: boolean
28
- isSupportUVCFan?: boolean
27
+ isStringLight?: boolean
29
28
  isSupportMixScene?: boolean
30
29
  drawToolLight?: {
31
30
  drawToolCode: string
@@ -35,7 +34,7 @@ export interface FlagPageProps {
35
34
  getRemoteMoodList?: (devId: string) => Promise<Result<any>>
36
35
  sceneDataCode?: string
37
36
  workModeCode: string
38
- switchLed?: string
37
+ switchLedCode: string
39
38
  }
40
39
 
41
40
  const FlagPage = () => {
@@ -45,9 +44,8 @@ const FlagPage = () => {
45
44
  const navigation = useNavigation()
46
45
  const [, setDps] = useDps()
47
46
  const [flagState, setFlag] = useFlag((params.sceneDataCode || params?.drawToolLight?.drawToolCode)!!, {
48
- isFan: params.isSupportFan,
49
- isUVCFan: params.isSupportUVCFan,
50
47
  isMixLight: params.isSupportMixScene,
48
+ isStringLight: params.isStringLight,
51
49
  ...params
52
50
  })
53
51
  const state = useReactive({
@@ -124,6 +122,11 @@ const FlagPage = () => {
124
122
  const res = await saveFlag(devId, cloneDeep(newScene))
125
123
  if (res.success) {
126
124
  state.flags = cloneDeep(newScene)
125
+ if(currentMood.id === flagState.id){
126
+ return {
127
+ success: true
128
+ }
129
+ }
127
130
  if(mood){
128
131
  setFlag(mood)
129
132
  }else{