@ledvance/group-ui-biz-bundle 1.0.24 → 1.0.26

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/group-ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.24",
7
+ "version": "1.0.26",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -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] = flag ? obj2Dp(flag, {isMixLight: params.isMixLight}) : ''
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.toString(16).padStart(2, '0')
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).toString(16).padStart(4, '0')
81
- const tHex = (colors.colorTemp * 10).toString(16).padStart(4, '0')
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.toString(16).padStart(2, '0')
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.toString(16).padStart(2, '0')
89
- const mode = flagItem.mode.toString(16).padStart(2, '0')
90
- const hHex = item.h.toString(16).padStart(4, '0')
91
- const sHex = (item.s * 10).toString(16).padStart(4, '0')
92
- const vHex = (item.v * 10).toString(16).padStart(4, '0')
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
- if (!flagItem.speed) {
98
- flagItem.speed = 12
99
- }
100
- if (!flagItem.mode) {
101
- flagItem.mode = 0
102
- }
103
- const switchingIntervalHex = (option?.isUVCFan ? 101 - flagItem.speed : flagItem.speed).toString(16).padStart(2, '0')
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 { hex2Hsv, hsv2Hex } from '@ledvance/base/src/utils'
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}
@@ -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)
@@ -1,8 +1,9 @@
1
- import { useFeatureHook } from '@ledvance/base/src/models/modules/NativePropsSlice'
2
- import { Result } from '@ledvance/base/src/models/modules/Result'
1
+ import {useFeatureHook} from '@ledvance/base/src/models/modules/NativePropsSlice'
2
+ import {Result} from '@ledvance/base/src/models/modules/Result'
3
3
  import dayjs from 'dayjs'
4
- import { useCountDown, useReactive } from 'ahooks'
5
- import { useEffect, useMemo } from 'react'
4
+ import {useCountDown, useReactive} from 'ahooks'
5
+ import {useEffect, useMemo} from 'react'
6
+ import {I18nKey} from "../../../.yalc/@ledvance/base/src/i18n/index";
6
7
 
7
8
  export interface TimerTask {
8
9
  name: string
@@ -15,8 +16,8 @@ export interface TimerTask {
15
16
  enable: boolean
16
17
  }
17
18
  status: TaskStatus
18
- stringOn: string
19
- stringOff: string
19
+ stringOn: I18nKey
20
+ stringOff: I18nKey
20
21
  }
21
22
 
22
23
  export enum TaskStatus {
@@ -154,14 +155,21 @@ export interface TimerSettableDp {
154
155
  code: string
155
156
  enable: boolean
156
157
  }
157
- stringOn: string
158
- stringOff: string
158
+ stringOn: I18nKey
159
+ stringOff: I18nKey
159
160
  }
160
161
 
161
162
  export interface TimerPageParams {
162
163
  timerSettableDps: TimerSettableDp[]
163
164
  }
164
165
 
166
+ export function timeFormatToRealTime(mCountdown: number) {
167
+ const date = new Date()
168
+ const now = date.getTime()
169
+ const after = new Date(now + mCountdown * 1000)
170
+ return `${after.getHours()}:${after.getMinutes().toString().padStart(2, '0')}`
171
+ }
172
+
165
173
  export function timeFormat(time: number): string {
166
174
  let hour = Math.trunc(time / 3600)
167
175
  const beforeMin = (time % 3600) / 60
@@ -8,7 +8,7 @@ import LdvPickerView from '@ledvance/base/src/components/ldvPickerView'
8
8
  import { useReactive } from 'ahooks'
9
9
  import Spacer from '@ledvance/base/src/components/Spacer'
10
10
  import DeleteButton from '@ledvance/base/src/components/DeleteButton'
11
- import { TaskStatus, timeFormat, TimerPageParams, TimerTask, useTimerTasks } from './TimerAction'
11
+ import {TaskStatus, timeFormat, timeFormatToRealTime, TimerPageParams, TimerTask, useTimerTasks} from './TimerAction'
12
12
  import { cloneDeep, groupBy } from 'lodash'
13
13
  import { useParams } from '@ledvance/base/src/hooks/Hooks'
14
14
  import GroupBizRes from '../../res/GroupBizRes'
@@ -188,7 +188,7 @@ const TimerPage = () => {
188
188
  </View>
189
189
  <Spacer height={cx(32)}/>
190
190
  <Text
191
- style={[styles.activeTaskDesc, { textAlign: 'center' }]}>{I18n.formatValue(startedTasks[0].dp.enable ? startedTasks[0].stringOff : startedTasks[0].stringOn, timeFormat(startedTasks[0].timeLeft))}</Text>
191
+ style={[styles.activeTaskDesc, { textAlign: 'center' }]}>{I18n.formatValue(startedTasks[0].dp.enable ? startedTasks[0].stringOff : startedTasks[0].stringOn, timeFormatToRealTime(startedTasks[0].timeLeft))}</Text>
192
192
  <Spacer height={cx(32)}/>
193
193
  <TextButton
194
194
  text={I18n.getLang('auto_scan_system_cancel')}
@@ -241,7 +241,7 @@ function ActiveTimerItem(task: TimerTask, onCancel: () => void) {
241
241
  <Spacer/>
242
242
  <View style={{ marginHorizontal: cx(20) }}>
243
243
  <Text style={styles.activeTaskDesc}>{
244
- I18n.formatValue(task.dp.enable ? task.stringOff : task.stringOn, timeFormat(task.timeLeft))
244
+ I18n.formatValue(task.dp.enable ? task.stringOff : task.stringOn, timeFormatToRealTime(task.timeLeft))
245
245
  }</Text>
246
246
  </View>
247
247
  <Spacer height={cx(22)}/>
@@ -339,7 +339,7 @@ const styles = StyleSheet.create({
339
339
  fontSize: cx(14),
340
340
  },
341
341
  activeTasBtn: {
342
- width: cx(75),
342
+ width: 'auto',
343
343
  height: cx(36),
344
344
  padding: 0,
345
345
  backgroundColor: '#666',