@ledvance/ui-biz-bundle 1.0.13 → 1.0.14

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.0.13",
7
+ "version": "1.0.14",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Utils as lampUtils } from "@tuya/tuya-panel-lamp-sdk"
3
- import { View } from "react-native";
3
+ import { View, Text, Image } from "react-native";
4
4
  import { Utils } from 'tuya-panel-kit'
5
5
  import SegmentControl from "@ledvance/base/src/components/segmentControl";
6
6
  import I18n from "@ledvance/base/src/i18n";
@@ -8,46 +8,73 @@ import ManualSetting from "./ManualSetting";
8
8
  import { ScheduleItemDp } from "./TimeScheduleEditpage";
9
9
  import MoodSetting from "./MoodSetting";
10
10
  import { isPlug } from "@ledvance/base/src/utils/Support";
11
+ import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
12
+ import res from "@ledvance/base/src/res";
11
13
  const { convertX: cx } = Utils.RatioUtils
12
14
  const { isSupportScene } = lampUtils.SupportUtils
13
- interface DeviceStateProps{
15
+ interface DeviceStateProps extends JudgeTimeScheduleProps {
14
16
  scheduleItem: any
15
17
  dps: ScheduleItemDp[]
16
- dpCodes: Record<string,string>
18
+ selectedDps: ScheduleItemDp[]
19
+ dpCodes: Record<string, string>
17
20
  isManual: boolean
18
21
  setIsManual?: (isManual: boolean) => void
19
- setSendDps: (dpId: string, dp: Record<string,any>) => void
20
- changeSkillEnable: (dpId:string, enable: boolean) => void
22
+ setSendDps: (dpId: string, dp: Record<string, any>) => void
23
+ changeSkillEnable: (dpId: string, enable: boolean) => void
21
24
  }
22
25
 
23
- const DeviceState = (props: DeviceStateProps) =>{
24
- const showSegmentControl = () =>{
25
- return !!(isSupportScene() && !isPlug(props.dpCodes) && props.dps.length && props.dps.find(dp => dp.value.includes('light')))
26
+ const DeviceState = (props: DeviceStateProps) => {
27
+ const showSegmentControl = () => {
28
+ return !!(isSupportScene() && !isPlug(props.dpCodes) && props.selectedDps.length && props.selectedDps.find(dp => dp.value.includes('light')))
26
29
  }
27
- return(
30
+
31
+ const showErrorText = () => {
32
+ return !!props.dps.length
33
+ }
34
+ return (
28
35
  <View>
29
36
  {showSegmentControl() && <SegmentControl
30
37
  title1={I18n.getLang('timeschedule_add_schedule_switch_tab_manual_text')}
31
38
  title2={I18n.getLang('timeschedule_add_schedule_switch_tab_mood_text')}
32
39
  isFirst={props.isManual}
33
40
  setIsFirst={(v: boolean) => props.setIsManual && props.setIsManual(v)}
34
- style={{marginHorizontal: cx(0)}}
41
+ style={{ marginHorizontal: cx(0) }}
35
42
  />}
36
43
  {props.isManual ?
37
- <ManualSetting
44
+ <ManualSetting
38
45
  dpCodes={props.dpCodes}
39
- dps={props.dps}
46
+ dps={props.selectedDps}
40
47
  scheduleItem={props.scheduleItem}
41
48
  setSendDps={props.setSendDps}
42
49
  changeSkillEnable={props.changeSkillEnable}
50
+ isDIMLamp={props.isDIMLamp}
51
+ isGARDOT={props.isGARDOT}
52
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
53
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
54
+ isRGBLamp={props.isRGBLamp}
55
+ isRGBWLamp={props.isRGBWLamp}
56
+ isTWLamp={props.isTWLamp}
57
+ isFanLamp={props.isFanLamp}
58
+ isSupportMode={props.isSupportMode}
59
+ isSupportBrightness={props.isSupportBrightness}
60
+ isSupportTemperature={props.isSupportTemperature}
43
61
  /> :
44
- <MoodSetting
45
- dpCodes={props.dpCodes}
46
- dps={props.dps}
47
- scheduleItem={props.scheduleItem}
48
- setSendDps={props.setSendDps}
49
- changeSkillEnable={props.changeSkillEnable}
50
- />
62
+ <View>
63
+ {
64
+ showErrorText() ?
65
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
66
+ <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber} />
67
+ <Text style={{ color: '#FF9500', marginLeft: cx(5) }}>{I18n.getLang('timeschedule_add_schedule_no_device_warning_text')}</Text>
68
+ </View> :
69
+ <MoodSetting
70
+ dpCodes={props.dpCodes}
71
+ dps={props.dps}
72
+ scheduleItem={props.scheduleItem}
73
+ setSendDps={props.setSendDps}
74
+ changeSkillEnable={props.changeSkillEnable}
75
+ />
76
+ }
77
+ </View>
51
78
  }
52
79
  </View>
53
80
  )
@@ -4,9 +4,10 @@ import { isMixRGBWLamp } from '@ledvance/base/src/utils/Support'
4
4
  import SingleLightView from "./SingleLightView";
5
5
  import { ScheduleItemDp } from "./TimeScheduleEditpage";
6
6
  import MixLightView from "./mix/MixLightView";
7
+ import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
7
8
 
8
9
 
9
- interface ManualSettingProps {
10
+ interface ManualSettingProps extends JudgeTimeScheduleProps{
10
11
  scheduleItem: any
11
12
  dps: ScheduleItemDp[]
12
13
  dpCodes: Record<string, string>
@@ -35,6 +36,17 @@ const ManualSetting = (props: ManualSettingProps) => {
35
36
  scheduleItem={props.scheduleItem}
36
37
  setSendDps={props.setSendDps}
37
38
  setEnable={props.changeSkillEnable}
39
+ isDIMLamp={props.isDIMLamp}
40
+ isGARDOT={props.isGARDOT}
41
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
42
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
43
+ isRGBLamp={props.isRGBLamp}
44
+ isRGBWLamp={props.isRGBWLamp}
45
+ isTWLamp={props.isTWLamp}
46
+ isFanLamp={props.isFanLamp}
47
+ isSupportMode={props.isSupportMode}
48
+ isSupportBrightness={props.isSupportBrightness}
49
+ isSupportTemperature={props.isSupportTemperature}
38
50
  />
39
51
  </View>
40
52
  ))
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useEffect } from 'react'
2
2
  import { View } from 'react-native'
3
3
  import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
4
- import { isDIMLamp, isGARDOT, isGlassRGBWLamp, isOnlyRGBLamp, isRGBLamp, isRGBWLamp, isTWLamp, isSupportBrightness, isSupportTemperature, isSupportMode, isFanLamp } from '@ledvance/base/src/utils/Support'
5
4
  import { Utils } from 'tuya-panel-kit'
6
5
  import { useReactive } from 'ahooks'
7
6
  import { getHSVByHex, getHexByHSV, hsv2Hex } from '@ledvance/base/src/utils'
@@ -14,10 +13,11 @@ import { COLOUR, WHITE, modeOptions } from '../../hooks/DeviceDpStateHooks'
14
13
  import { ScheduleItemDp } from './TimeScheduleEditpage'
15
14
  import FanAdjustView from '@ledvance/base/src/components/FanAdjustView'
16
15
  import { useFanMaxSpeed } from '@ledvance/base/src/models/modules/NativePropsSlice'
16
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean'
17
17
 
18
18
  const { convertX: cx } = Utils.RatioUtils
19
19
 
20
- interface SingleLightViewProps {
20
+ interface SingleLightViewProps extends JudgeTimeScheduleProps {
21
21
  scheduleItem: any
22
22
  dpCodes: Record<string, string>
23
23
  dp: ScheduleItemDp
@@ -26,7 +26,7 @@ interface SingleLightViewProps {
26
26
  }
27
27
 
28
28
  export default function SingleLightView(props: SingleLightViewProps) {
29
- const { scheduleItem, dpCodes, dp, setSendDps, setEnable } = props
29
+ const { scheduleItem, dpCodes, dp, setSendDps, setEnable, isDIMLamp, isGARDOT, isGlassRGBWLamp, isOnlyRGBLamp, isRGBLamp, isRGBWLamp, isTWLamp, isSupportBrightness, isSupportTemperature, isFanLamp, isSupportMode } = props
30
30
  const state = useReactive({
31
31
  enable: true,
32
32
  isColor: true,
@@ -70,11 +70,11 @@ export default function SingleLightView(props: SingleLightViewProps) {
70
70
  }, [state.flag])
71
71
 
72
72
  const getSendDps = () => {
73
- if (isDIMLamp(dpCodes)) {
73
+ if (isDIMLamp) {
74
74
  return {
75
75
  [dpCodes.bright_value]: state.brightness * 10,
76
76
  };
77
- } else if (isFanLamp(dpCodes)) {
77
+ } else if (isFanLamp) {
78
78
  const v = dp.value.includes('fan') ? {
79
79
  [dpCodes.fan_mode]: state.fanMode,
80
80
  [dpCodes.fan_speed]: state.fanSpeed
@@ -84,13 +84,13 @@ export default function SingleLightView(props: SingleLightViewProps) {
84
84
  [dpCodes.temp_value]: state.temperature * 10,
85
85
  }
86
86
  return v
87
- } else if (isTWLamp(dpCodes)) {
87
+ } else if (isTWLamp) {
88
88
  return {
89
89
  [dpCodes.work_mode]: WHITE,
90
90
  [dpCodes.bright_value]: state.brightness * 10,
91
91
  [dpCodes.temp_value]: state.temperature * 10,
92
92
  };
93
- } else if (isRGBWLamp(dpCodes)) {
93
+ } else if (isRGBWLamp) {
94
94
  if (state.isColor) {
95
95
  const colorString = getHexByHSV({
96
96
  h: state.h,
@@ -108,7 +108,7 @@ export default function SingleLightView(props: SingleLightViewProps) {
108
108
  [dpCodes.bright_value]: state.brightness * 10,
109
109
  };
110
110
 
111
- } else if (isGlassRGBWLamp(dpCodes)) {
111
+ } else if (isGlassRGBWLamp) {
112
112
  const colorString = getHexByHSV({
113
113
  h: state.h,
114
114
  s: state.s * 10,
@@ -118,7 +118,7 @@ export default function SingleLightView(props: SingleLightViewProps) {
118
118
  [dpCodes.work_mode]: COLOUR,
119
119
  [dpCodes.colour_data]: colorString,
120
120
  };
121
- } else if (isGARDOT(dpCodes)) {
121
+ } else if (isGARDOT) {
122
122
  const colorString = getHexByHSV({
123
123
  h: state.h,
124
124
  s: state.s * 10,
@@ -211,19 +211,19 @@ export default function SingleLightView(props: SingleLightViewProps) {
211
211
 
212
212
  const getColorBlockColor = useCallback(() => {
213
213
  const s = Math.round(mapFloatToRange(state.s / 100, 30, 100))
214
- if (isOnlyRGBLamp(dpCodes)) {
214
+ if (isOnlyRGBLamp) {
215
215
  return hsv2Hex(state.h, s, 100)
216
216
  }
217
- if (isTWLamp(dpCodes)) {
217
+ if (isTWLamp) {
218
218
  return cctToColor(state.temperature.toFixed())
219
219
  }
220
- if (isDIMLamp(dpCodes)) {
220
+ if (isDIMLamp) {
221
221
  return '#fff'
222
222
  }
223
223
  if (state.isColor) {
224
224
  return hsv2Hex(state.h, s, 100)
225
225
  }
226
- if (isSupportTemperature(dpCodes)) {
226
+ if (isSupportTemperature) {
227
227
  return cctToColor(state.temperature.toFixed())
228
228
  }
229
229
  }, [state.temperature])
@@ -240,13 +240,13 @@ export default function SingleLightView(props: SingleLightViewProps) {
240
240
  setEnable={setEnableStateAction} />
241
241
  {state.enable &&
242
242
  <LampAdjustView
243
- isDIMLamp={isDIMLamp(dpCodes)}
244
- isRGBLamp={isRGBLamp(dpCodes)}
245
- isOnlyRGBLamp={isOnlyRGBLamp(dpCodes)}
246
- isTWLamp={isTWLamp(dpCodes)}
247
- isRGBWLamp={isRGBWLamp(dpCodes)}
248
- isSupportBrightness={isSupportBrightness(dpCodes)}
249
- isSupportTemperature={isSupportTemperature(dpCodes)}
243
+ isDIMLamp={isDIMLamp}
244
+ isRGBLamp={isRGBLamp}
245
+ isOnlyRGBLamp={isOnlyRGBLamp}
246
+ isTWLamp={isTWLamp}
247
+ isRGBWLamp={isRGBWLamp}
248
+ isSupportBrightness={!!isSupportBrightness}
249
+ isSupportTemperature={!!isSupportTemperature}
250
250
  isColorMode={state.isColor}
251
251
  setIsColorMode={setWorkModeStateAction}
252
252
  h={state.h}
@@ -265,7 +265,7 @@ export default function SingleLightView(props: SingleLightViewProps) {
265
265
  </View> :
266
266
  props.dp.value.includes('fan') ?
267
267
  <FanAdjustView
268
- isSupportMode={isSupportMode(props.dpCodes)}
268
+ isSupportMode={isSupportMode}
269
269
  modeValue={state.fanMode}
270
270
  fanEnable={state.fanEnable}
271
271
  fanSpeed={state.fanSpeed}
@@ -0,0 +1,13 @@
1
+ export interface JudgeTimeScheduleProps {
2
+ isDIMLamp?: boolean
3
+ isGARDOT?: boolean
4
+ isGlassRGBWLamp?: boolean
5
+ isOnlyRGBLamp?: boolean
6
+ isRGBLamp?: boolean
7
+ isRGBWLamp?: boolean
8
+ isTWLamp?: boolean
9
+ isSupportBrightness?: boolean
10
+ isSupportTemperature?: boolean
11
+ isFanLamp?: boolean
12
+ isSupportMode?: boolean
13
+ }
@@ -18,6 +18,7 @@ import { useReactive } from 'ahooks';
18
18
  import { dpItem } from "./TimeSchedulePage";
19
19
  import { differenceBy } from "lodash";
20
20
  import DeviceState from "./DeviceState";
21
+ import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
21
22
 
22
23
  const { convertX: cx } = Utils.RatioUtils
23
24
 
@@ -26,7 +27,7 @@ export interface ScheduleItemDp extends dpItem {
26
27
  enable: boolean
27
28
  }
28
29
 
29
- interface TimeScheduleEditPageParams {
30
+ interface TimeScheduleEditPageParams extends JudgeTimeScheduleProps {
30
31
  scheduleItem: any,
31
32
  dps: ScheduleItemDp[]
32
33
  dpCodes: Record<any, any>
@@ -38,7 +39,8 @@ const TimeScheduleEditPage = () => {
38
39
  const navigation = useNavigation()
39
40
  const devId = useDeviceId()
40
41
  const route = useRoute()
41
- const { scheduleItem, dps, reloadData, deleteDialog, dpCodes } = route.params as TimeScheduleEditPageParams
42
+ const props = route.params as TimeScheduleEditPageParams
43
+ const { scheduleItem, dps, reloadData, deleteDialog, dpCodes } = props
42
44
  const state = useReactive({
43
45
  hour: '00',
44
46
  minute: '00',
@@ -283,12 +285,24 @@ const TimeScheduleEditPage = () => {
283
285
  </View>
284
286
  <DeviceState
285
287
  dpCodes={dpCodes}
286
- dps={state.selectedSkill}
288
+ dps={state.skillList}
289
+ selectedDps={state.selectedSkill}
287
290
  scheduleItem={scheduleItem}
288
291
  isManual={state.isManual}
289
292
  setIsManual={(v) => state.isManual = v}
290
293
  setSendDps={setSendDps}
291
294
  changeSkillEnable={changeSkillEnable}
295
+ isDIMLamp={props.isDIMLamp}
296
+ isGARDOT={props.isGARDOT}
297
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
298
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
299
+ isRGBLamp={props.isRGBLamp}
300
+ isRGBWLamp={props.isRGBWLamp}
301
+ isTWLamp={props.isTWLamp}
302
+ isFanLamp={props.isFanLamp}
303
+ isSupportMode={props.isSupportMode}
304
+ isSupportBrightness={props.isSupportBrightness}
305
+ isSupportTemperature={props.isSupportTemperature}
292
306
  />
293
307
  {!hasSelected() && <View style={{ flexDirection: 'row', alignItems: 'center' }}>
294
308
  <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber} />
@@ -15,6 +15,7 @@ import { showDialog } from '@ledvance/base/src/utils/common'
15
15
  import { useReactive } from 'ahooks'
16
16
  import { cloneDeep } from 'lodash'
17
17
  import { ui_biz_routerKey } from 'navigation/Routers'
18
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean'
18
19
 
19
20
  const { convertX: cx } = Utils.RatioUtils
20
21
 
@@ -24,18 +25,18 @@ export type dpItem = {
24
25
  dpId: string
25
26
  }
26
27
 
27
- type TimeSchedulePageRouteParams = {
28
- params: { dps: dpItem[], dpCodes: Record<string,string>}
28
+ export interface TimeSchedulePageRouteParams extends JudgeTimeScheduleProps{
29
+ dps: dpItem[],
30
+ dpCodes: Record<string,string>
29
31
  }
30
32
 
31
- type Props = {
32
- route: RouteProp<TimeSchedulePageRouteParams, 'params'>
33
- }
34
33
 
35
34
  const TimeSchedulePage = () => {
36
35
  const deviceInfo = useDeviceInfo()
37
36
  const navigation = useNavigation()
38
- const { dps, dpCodes } = useRoute<Props['route']>().params
37
+ const props = useRoute().params as TimeSchedulePageRouteParams
38
+ console.log(props, '< --- propssss')
39
+ const { dps, dpCodes } = props
39
40
  const state = useReactive({
40
41
  timeScheduleList: [] as any[],
41
42
  filterScheduleList: [] as any[],
@@ -68,12 +69,11 @@ const TimeSchedulePage = () => {
68
69
  navigation.navigate(path, {
69
70
  name: path,
70
71
  scheduleItem: item,
71
- dpCodes,
72
- dps,
73
72
  reloadData: getTimerScheduleList,
74
73
  deleteDialog: (item:any) =>{
75
74
  return deleteDialog(item)
76
- }
75
+ },
76
+ ...props
77
77
  })
78
78
  }, [state.timeScheduleList])
79
79
 
@@ -0,0 +1,50 @@
1
+ import { spliceByStep } from "@ledvance/base/src/utils/common"
2
+ import { MixLightBean } from "./MixLightBean"
3
+
4
+ export function obj2Dp(obj: MixLightBean): string {
5
+ const powerSwitchDpValueArray = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
6
+ if (obj.whiteLightSwitch) {
7
+ powerSwitchDpValueArray[15] = '1'
8
+ }
9
+ if (obj.colorLightSwitch) {
10
+ powerSwitchDpValueArray[14] = '1'
11
+ }
12
+ if (obj.mixRgbcwEnabled) {
13
+ powerSwitchDpValueArray[13] = '1'
14
+ }
15
+ const powerSwitchDpValueBinary = powerSwitchDpValueArray.join('')
16
+ const powerSwitchDpValue = parseInt(powerSwitchDpValueBinary, 2).toString(16).padStart(4, '0')
17
+ const hueDpValue = obj.hue.toString(16).padStart(4, '0')
18
+ const satDpValue = (obj.sat * 10).toString(16).padStart(4, '0')
19
+ const lightnessDpValue = (obj.lightness * 10).toString(16).padStart(4, '0')
20
+ const brightnessDpValue = (obj.brightness * 10).toString(16).padStart(4, '0')
21
+ const colorTempDpValue = (obj.colorTempPercent * 10).toString(16).padStart(4, '0')
22
+ return powerSwitchDpValue + hueDpValue + satDpValue + lightnessDpValue + brightnessDpValue + colorTempDpValue
23
+ }
24
+
25
+ export function dp2Obj(dp: string): MixLightBean {
26
+ if (!dp) {
27
+ return {
28
+ whiteLightSwitch: true,
29
+ colorLightSwitch: true,
30
+ mixRgbcwEnabled: true,
31
+ hue: 360,
32
+ sat: 100,
33
+ lightness: 100,
34
+ brightness: 100,
35
+ colorTempPercent: 100,
36
+ }
37
+ }
38
+ const dpValueArray = spliceByStep(dp, 4)
39
+ const powerSwitch = parseInt(dpValueArray[0], 16).toString(2).padStart(16, '0')
40
+ return {
41
+ whiteLightSwitch: powerSwitch[15] === '1',
42
+ colorLightSwitch: powerSwitch[14] === '1',
43
+ mixRgbcwEnabled: powerSwitch[13] === '1',
44
+ hue: parseInt(dpValueArray[1], 16), // 色相 0-360
45
+ sat: parseInt(dpValueArray[2], 16) / 10, // 饱和度 0-100
46
+ lightness: parseInt(dpValueArray[3], 16) / 10, // 明度 0-100
47
+ brightness: parseInt(dpValueArray[4], 16) / 10, // 亮度 0-100
48
+ colorTempPercent: parseInt(dpValueArray[5], 16) / 10, // 色温 0-100
49
+ }
50
+ }
@@ -14,7 +14,7 @@ import LdvSaturation from '@ledvance/base/src/components/ldvSaturation'
14
14
  import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
15
15
  import { mapFloatToRange } from '@ledvance/base/src/utils'
16
16
  import { Buffer } from 'buffer';
17
- import { dp2Obj, obj2Dp } from '../../scene/SceneAction'
17
+ import { dp2Obj, obj2Dp } from './MixLightActions'
18
18
 
19
19
  const { convertX: cx } = Utils.RatioUtils
20
20