@ledvance/ui-biz-bundle 1.0.45 → 1.0.47

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/.temp/img.png ADDED
Binary file
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.45",
7
+ "version": "1.0.47",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -124,7 +124,7 @@ const BiorhythmPage = () => {
124
124
  console.log('设置生物节律数据', state)
125
125
  await userOperation(deviceId, false)
126
126
  state.loading = false
127
- const res = await setBiorhythm(deviceId, {...state, planList})
127
+ const res = await setBiorhythm(deviceId, {...state, enable: !state.enable, planList})
128
128
  console.log('设置生物节律res', res)
129
129
  if (res.success) {
130
130
  state.enable = !state.enable
@@ -1,90 +1,94 @@
1
- import React from "react";
2
- import { Utils as lampUtils } from "@tuya/tuya-panel-lamp-sdk"
3
- import { View, Text, Image } from "react-native";
1
+ import React from 'react'
2
+ import { Utils as lampUtils } from '@tuya/tuya-panel-lamp-sdk'
3
+ import { Image, Text, View } from 'react-native'
4
4
  import { Utils } from 'tuya-panel-kit'
5
- import SegmentControl from "@ledvance/base/src/components/segmentControl";
6
- import I18n from "@ledvance/base/src/i18n";
7
- import ManualSetting from "./ManualSetting";
8
- import { ScheduleItemDp } from "./TimeScheduleEditpage";
9
- import MoodSetting from "./MoodSetting";
10
- import { isPlug } from "@ledvance/base/src/utils/Support";
11
- import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
12
- import res from "@ledvance/base/src/res";
5
+ import SegmentControl from '@ledvance/base/src/components/segmentControl'
6
+ import I18n from '@ledvance/base/src/i18n'
7
+ import ManualSetting from './ManualSetting'
8
+ import { ScheduleItemDp } from './TimeScheduleEditpage'
9
+ import MoodSetting from './MoodSetting'
10
+ import { isPlug } from '@ledvance/base/src/utils/Support'
11
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean'
12
+ import res from '@ledvance/base/src/res'
13
+
13
14
  const { convertX: cx } = Utils.RatioUtils
14
15
  const { isSupportScene } = lampUtils.SupportUtils
16
+
15
17
  interface DeviceStateProps extends JudgeTimeScheduleProps {
16
- singleActions: any
17
- mixActions:any
18
- actionScene:any
19
- scheduleItem: any
20
- dps: ScheduleItemDp[]
21
- selectedDps: ScheduleItemDp[]
22
- dpCodes: Record<string, string>
23
- isManual: boolean
24
- setIsManual?: (isManual: boolean) => void
25
- setSendDps: (actions:any, type:string) => void
26
- changeSkillEnable: (dpId: string, enable: boolean) => void
18
+ singleActions: any
19
+ mixActions: any
20
+ actionScene: any
21
+ scheduleItem: any
22
+ dps: ScheduleItemDp[]
23
+ selectedDps: ScheduleItemDp[]
24
+ dpCodes: Record<string, string>
25
+ isManual: boolean
26
+ setIsManual?: (isManual: boolean) => void
27
+ setSendDps: (actions: any, type: string) => void
28
+ changeSkillEnable: (dpId: string, enable: boolean) => void
27
29
  }
28
30
 
29
31
  const DeviceState = (props: DeviceStateProps) => {
30
- const showSegmentControl = () => {
31
- return !!(isSupportScene() && !isPlug(props.dpCodes) && props.selectedDps.length)
32
- }
32
+ const showSegmentControl = () => {
33
+ return !!(isSupportScene() && !isPlug(props.dpCodes) && props.selectedDps.length)
34
+ }
33
35
 
34
- const showErrorText = () => {
35
- return !!props.dps.length
36
- }
37
- return (
36
+ const showErrorText = () => {
37
+ return !!props.dps.length
38
+ }
39
+ return (
40
+ <View>
41
+ {showSegmentControl() && <SegmentControl
42
+ title1={I18n.getLang('timeschedule_add_schedule_switch_tab_manual_text')}
43
+ title2={I18n.getLang('timeschedule_add_schedule_switch_tab_mood_text')}
44
+ isFirst={props.isManual}
45
+ setIsFirst={(v: boolean) => props.setIsManual && props.setIsManual(v)}
46
+ style={{ marginHorizontal: cx(0) }}
47
+ />}
48
+ {props.isManual ?
49
+ <ManualSetting
50
+ singleActions={props.singleActions}
51
+ mixActions={props.mixActions}
52
+ dpCodes={props.dpCodes}
53
+ dps={props.selectedDps}
54
+ scheduleItem={props.scheduleItem}
55
+ setSendDps={props.setSendDps}
56
+ changeSkillEnable={props.changeSkillEnable}
57
+ isDIMLamp={props.isDIMLamp}
58
+ isGARDOT={props.isGARDOT}
59
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
60
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
61
+ isRGBLamp={props.isRGBLamp}
62
+ isRGBWLamp={props.isRGBWLamp}
63
+ isMixRGBWLamp={props.isMixRGBWLamp}
64
+ isTWLamp={props.isTWLamp}
65
+ isFanLamp={props.isFanLamp}
66
+ isSupportMode={props.isSupportMode}
67
+ isSupportBrightness={props.isSupportBrightness}
68
+ isSupportTemperature={props.isSupportTemperature}
69
+ /> :
38
70
  <View>
39
- {showSegmentControl() && <SegmentControl
40
- title1={I18n.getLang('timeschedule_add_schedule_switch_tab_manual_text')}
41
- title2={I18n.getLang('timeschedule_add_schedule_switch_tab_mood_text')}
42
- isFirst={props.isManual}
43
- setIsFirst={(v: boolean) => props.setIsManual && props.setIsManual(v)}
44
- style={{ marginHorizontal: cx(0) }}
45
- />}
46
- {props.isManual ?
47
- <ManualSetting
48
- singleActions ={props.singleActions}
49
- mixActions = {props.mixActions}
50
- dpCodes={props.dpCodes}
51
- dps={props.selectedDps}
52
- scheduleItem={props.scheduleItem}
53
- setSendDps={props.setSendDps}
54
- changeSkillEnable={props.changeSkillEnable}
55
- isDIMLamp={props.isDIMLamp}
56
- isGARDOT={props.isGARDOT}
57
- isGlassRGBWLamp={props.isGlassRGBWLamp}
58
- isOnlyRGBLamp={props.isOnlyRGBLamp}
59
- isRGBLamp={props.isRGBLamp}
60
- isRGBWLamp={props.isRGBWLamp}
61
- isMixRGBWLamp={props.isMixRGBWLamp}
62
- isTWLamp={props.isTWLamp}
63
- isFanLamp={props.isFanLamp}
64
- isSupportMode={props.isSupportMode}
65
- isSupportBrightness={props.isSupportBrightness}
66
- isSupportTemperature={props.isSupportTemperature}
67
- /> :
68
- <View>
69
- {
70
- showErrorText() ?
71
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
72
- <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber} />
73
- <Text style={{ color: '#FF9500', marginLeft: cx(5) }}>{I18n.getLang('timeschedule_add_schedule_no_device_warning_text')}</Text>
74
- </View> :
75
- <MoodSetting
76
- actionScene={props.actionScene}
77
- dpCodes={props.dpCodes}
78
- dps={props.dps}
79
- scheduleItem={props.scheduleItem}
80
- setSendDps={props.setSendDps}
81
- changeSkillEnable={props.changeSkillEnable}
82
- />
83
- }
84
- </View>
85
- }
71
+ {
72
+ showErrorText() ?
73
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
74
+ <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber}/>
75
+ <Text style={{
76
+ color: '#FF9500',
77
+ marginLeft: cx(5),
78
+ }}>{I18n.getLang('timeschedule_add_schedule_no_device_warning_text')}</Text>
79
+ </View> :
80
+ <MoodSetting
81
+ actionScene={props.actionScene}
82
+ dpCodes={props.dpCodes}
83
+ dps={props.dps}
84
+ scheduleItem={props.scheduleItem}
85
+ setSendDps={props.setSendDps}
86
+ changeSkillEnable={props.changeSkillEnable}/>
87
+ }
86
88
  </View>
87
- )
89
+ }
90
+ </View>
91
+ )
88
92
  }
89
93
 
90
94
  export default DeviceState
@@ -1,74 +1,78 @@
1
- import React from "react";
2
- import { View } from "react-native";
3
- import SingleLightView from "./SingleLightView";
4
- import { ScheduleItemDp } from "./TimeScheduleEditpage";
5
- import MixLightView from "./mix/MixLightView";
6
- import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
7
- import { useReactive } from "ahooks";
1
+ import React from 'react'
2
+ import { View } from 'react-native'
3
+ import SingleLightView from './SingleLightView'
4
+ import { ScheduleItemDp } from './TimeScheduleEditpage'
5
+ import MixLightView from './mix/MixLightView'
6
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean'
7
+ import { useReactive, useUpdateEffect } from 'ahooks'
8
+ import { cloneDeep } from 'lodash'
8
9
 
9
10
 
10
- interface ManualSettingProps extends JudgeTimeScheduleProps{
11
- singleActions: any
12
- mixActions:any
13
- scheduleItem: any
14
- dps: ScheduleItemDp[]
15
- dpCodes: Record<string, string>
16
- isMixRGBWLamp?: boolean
17
- setSendDps: (actions: any, type:string) => void
18
- changeSkillEnable: (dpId:string, enable: boolean) => void
11
+ interface ManualSettingProps extends JudgeTimeScheduleProps {
12
+ singleActions: any
13
+ mixActions: any
14
+ scheduleItem: any
15
+ dps: ScheduleItemDp[]
16
+ dpCodes: Record<string, string>
17
+ isMixRGBWLamp?: boolean
18
+ setSendDps: (actions: any, type: string) => void
19
+ changeSkillEnable: (dpId: string, enable: boolean) => void
19
20
  }
20
21
 
21
22
  const ManualSetting = (props: ManualSettingProps) => {
22
- const state = useReactive({
23
- singleActions: props.singleActions,
24
- mixActions: props.mixActions,
25
- flag: Symbol()
26
- })
23
+ const state = useReactive({
24
+ singleActions: cloneDeep(props.singleActions),
25
+ mixActions: props.mixActions,
26
+ flag: Symbol(),
27
+ })
27
28
 
29
+ useUpdateEffect(() => {
30
+ state.singleActions = cloneDeep(props.singleActions)
31
+ }, [JSON.stringify(props.singleActions)])
28
32
 
29
- const renderContent = () => {
30
- if (props.isMixRGBWLamp) {
31
- return (
32
- <MixLightView
33
- mixActions={state.mixActions}
34
- dpCodes={props.dpCodes}
35
- setSendDps={props.setSendDps}
36
- scheduleItem={props.scheduleItem}
37
- />
38
- )
39
- }
40
- return (
41
- props.dps.map((item) => (
42
- <View key={item.dpId}>
43
- <SingleLightView
44
- singleActions={state.singleActions}
45
- dp={item}
46
- dpCodes={props.dpCodes}
47
- scheduleItem={props.scheduleItem}
48
- setSendDps={props.setSendDps}
49
- setEnable={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}
61
- />
62
- </View>
63
- ))
64
- )
65
-
33
+ const renderContent = () => {
34
+ if (props.isMixRGBWLamp) {
35
+ return (
36
+ <MixLightView
37
+ mixActions={state.mixActions}
38
+ dpCodes={props.dpCodes}
39
+ setSendDps={props.setSendDps}
40
+ scheduleItem={props.scheduleItem}
41
+ />
42
+ )
66
43
  }
67
44
  return (
68
- <View>
69
- {renderContent()}
45
+ props.dps.map((item) => (
46
+ <View key={item.dpId}>
47
+ <SingleLightView
48
+ singleActions={state.singleActions}
49
+ dp={item}
50
+ dpCodes={props.dpCodes}
51
+ scheduleItem={props.scheduleItem}
52
+ setSendDps={props.setSendDps}
53
+ setEnable={props.changeSkillEnable}
54
+ isDIMLamp={props.isDIMLamp}
55
+ isGARDOT={props.isGARDOT}
56
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
57
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
58
+ isRGBLamp={props.isRGBLamp}
59
+ isRGBWLamp={props.isRGBWLamp}
60
+ isTWLamp={props.isTWLamp}
61
+ isFanLamp={props.isFanLamp}
62
+ isSupportMode={props.isSupportMode}
63
+ isSupportBrightness={props.isSupportBrightness}
64
+ isSupportTemperature={props.isSupportTemperature}
65
+ />
70
66
  </View>
67
+ ))
71
68
  )
69
+
70
+ }
71
+ return (
72
+ <View>
73
+ {renderContent()}
74
+ </View>
75
+ )
72
76
  }
73
77
 
74
78
  export default ManualSetting
@@ -1,62 +1,27 @@
1
- import React, { useEffect } from "react";
2
- import { ScheduleItemDp } from "./TimeScheduleEditpage";
3
- import ScheduleScene from "./ScheduleScene";
4
- // import MixMoodScene from "../mood/MixScene";
5
- import { useReactive } from 'ahooks'
6
-
7
- interface MoodSettingProps{
8
- actionScene:any
9
- scheduleItem: any
10
- dps: ScheduleItemDp[]
11
- dpCodes: Record<string, string>
12
- setSendDps: (actions:any, type:string) => void
13
- changeSkillEnable: (dpId:string, enable: boolean) => void
1
+ import React from 'react'
2
+ import { ScheduleItemDp } from './TimeScheduleEditpage'
3
+ import ScheduleScene from './ScheduleScene'
4
+
5
+ interface MoodSettingProps {
6
+ actionScene: any
7
+ scheduleItem: any
8
+ dps: ScheduleItemDp[]
9
+ dpCodes: Record<string, string>
10
+ setSendDps: (actions: any, type: string) => void
11
+ changeSkillEnable: (dpId: string, enable: boolean) => void
14
12
  }
15
13
 
16
- const MoodSetting = (props: MoodSettingProps) =>{
17
- const { dpCodes, setSendDps} = props
18
- const state = useReactive({
19
- actionScene: props.actionScene,
20
- })
21
-
22
- // useEffect(() =>{
23
- // if(scheduleItem){
24
- // if(scheduleItem.dps[dpCodes.scene_data] !== undefined){
25
- // state.actionScene = sencePp2Obj(scheduleItem.dps[dpCodes.scene_data])
26
- // }
27
- // if (scheduleItem.dps[dpCodes.mix_light_scene] !== undefined) {
28
- // const sceneDp = scheduleItem.dps[dpCodes.mix_light_scene]
29
- // state.actionScene = Buffer.from(sceneDp, 'base64').toString('hex')
30
- // }
31
- // }
32
- // }, [])
33
-
34
- useEffect(() =>{
35
- setSendDps(state.actionScene, 'actionScene')
36
- }, [state.actionScene])
37
-
38
- // const getSendDps = () =>{
39
- // if (isMixRGBWLamp(dpCodes)) {
40
- // return {
41
- // [dpCodes.mix_light_scene]: Buffer.from(state.actionScene?.value, 'hex').toString('base64'),
42
- // [dpCodes.switch_led]: true,
43
- // [dpCodes.work_mode]: SCENE
44
- // }
45
- // } else {
46
- // return {
47
- // [dpCodes.switch_led]: true,
48
- // [dpCodes.scene_data]: senceObj2Dp({ id: Number(state?.actionScene?.id), nodes: state?.actionScene?.nodes, fanEnable: state.actionScene.fanEnable, fanSpeed: state.actionScene.fanSpeed }),
49
- // [dpCodes.work_mode]: SCENE,
50
- // };
51
- // }
52
- // }
53
-
54
- return (
55
- // isMixRGBWLamp(dpCodes) ?
56
- // <MixMoodScene setActionScene={v => state.actionScene = v} mixScene={state.actionScene} /> :
57
- <ScheduleScene dpCodes={dpCodes} scene={state.actionScene} setScene={s => (state.actionScene = s)} />
58
- )
59
-
14
+ const MoodSetting = (props: MoodSettingProps) => {
15
+ const { dpCodes, setSendDps } = props
16
+
17
+ return (
18
+ <ScheduleScene
19
+ dpCodes={dpCodes}
20
+ scene={props.actionScene}
21
+ setScene={s => {
22
+ setSendDps(s, 'actionScene')
23
+ }}/>
24
+ )
60
25
  }
61
26
 
62
27
  export default MoodSetting
@@ -11,131 +11,127 @@ import Tag from '@ledvance/base/src/components/Tag'
11
11
  import { Utils } from 'tuya-panel-kit'
12
12
  import InfoText from '@ledvance/base/src/components/InfoText'
13
13
  import MoodItem from '../mood/MoodItem'
14
- import { SCENE, useWorkMode } from '../../hooks/DeviceDpStateHooks'
15
14
  import { isEmpty } from 'lodash'
16
15
 
17
16
  const cx = Utils.RatioUtils.convertX
18
17
 
19
18
  interface MoodUIState extends ScenePageUIState {
20
- staticTagChecked: boolean
21
- dynamicTagChecked: boolean
22
- filteredMoods: SceneUIState[]
23
- // dpCodes: Record<string, string>
19
+ staticTagChecked: boolean
20
+ dynamicTagChecked: boolean
21
+ filteredMoods: SceneUIState[]
24
22
  }
25
23
 
26
24
 
27
25
  const ScheduleScene = ({ scene, setScene, dpCodes }) => {
28
- const deviceInfo = useDeviceInfo()
29
- const [workMode] = useWorkMode(dpCodes)
30
- const state = useReactive<MoodUIState>({
31
- currentScene: undefined,
32
- staticTagChecked: true,
33
- dynamicTagChecked: true,
34
- scenes: [],
35
- flag: Symbol(),
36
- // originScene: [],
37
- filteredMoods: [],
38
- })
26
+ const deviceInfo = useDeviceInfo()
27
+ const state = useReactive<MoodUIState>({
28
+ currentScene: undefined,
29
+ staticTagChecked: true,
30
+ dynamicTagChecked: true,
31
+ scenes: [],
32
+ flag: Symbol(),
33
+ filteredMoods: [],
34
+ })
39
35
 
40
- const getSceneList = useCallback(async () => {
41
- const res = await getRemoteSceneList(deviceInfo.devId, dpCodes)
42
- if (res.success) {
43
- state.scenes = res.data || []
44
- state.currentScene = isEmpty(scene) ? state.scenes[0] : scene
45
- setScene(state.currentScene)
46
- }
47
- }, [])
36
+ const getSceneList = useCallback(async () => {
37
+ const res = await getRemoteSceneList(deviceInfo.devId, dpCodes)
38
+ if (res.success) {
39
+ state.scenes = res.data || []
40
+ state.currentScene = isEmpty(scene) ? state.scenes[0] : scene
41
+ setScene(state.currentScene)
42
+ }
43
+ }, [])
48
44
 
49
- useEffect(() => {
50
- state.filteredMoods = state.scenes.filter(item => {
51
- return (state.staticTagChecked && state.dynamicTagChecked) ||
52
- (state.staticTagChecked && item.nodes.length < 2) ||
53
- (state.dynamicTagChecked && item.nodes.length > 1)
54
- })
55
- }, [state.staticTagChecked, state.dynamicTagChecked, state.scenes])
45
+ useEffect(() => {
46
+ state.filteredMoods = state.scenes.filter(item => {
47
+ return (state.staticTagChecked && state.dynamicTagChecked) ||
48
+ (state.staticTagChecked && item.nodes.length < 2) ||
49
+ (state.dynamicTagChecked && item.nodes.length > 1)
50
+ })
51
+ }, [state.staticTagChecked, state.dynamicTagChecked, state.scenes])
56
52
 
57
53
 
58
- useEffect(() => {
59
- getSceneList().then()
60
- }, [state.flag])
54
+ useEffect(() => {
55
+ getSceneList().then()
56
+ }, [state.flag])
61
57
 
62
- return (
63
- <>
64
- <View style={styles.tagLine}>
65
- <Tag
66
- checked={state.staticTagChecked}
67
- text={I18n.getLang('mood_overview_filter_name_text1')}
68
- onCheckedChange={checked => {
69
- state.staticTagChecked = checked
70
- }} />
71
- <Spacer width={cx(8)} height={0} />
72
- <Tag
73
- checked={state.dynamicTagChecked}
74
- text={I18n.getLang('mood_overview_filter_name_text2')}
75
- onCheckedChange={checked => {
76
- state.dynamicTagChecked = checked
77
- }} />
78
- </View>
79
- <Spacer height={cx(10)} />
80
- <FlatList
81
- data={state.filteredMoods}
82
- renderItem={({ item }) => {
83
- return (
84
- <MoodItem
85
- style={{marginHorizontal: cx(8)}}
86
- enable={workMode === SCENE && state.currentScene?.id === item.id}
87
- mood={item}
88
- onSwitch={async _ => {
89
- state.currentScene = item
90
- setScene(item)
91
- }} />
92
- )
93
- }}
94
- ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
95
- ItemSeparatorComponent={() => (<Spacer />)}
96
- ListFooterComponent={() => (
97
- <View style={styles.infoLine}>
98
- <Spacer />
99
- <InfoText
100
- icon={res.ic_info}
101
- text={I18n.getLang('mood_overview_information_text')} />
102
- <Spacer height={cx(40)} />
103
- </View>
104
- )}
105
- keyExtractor={item => `${item.id}`} />
106
- </>
107
- )
58
+ return (
59
+ <>
60
+ <View style={styles.tagLine}>
61
+ <Tag
62
+ checked={state.staticTagChecked}
63
+ text={I18n.getLang('mood_overview_filter_name_text1')}
64
+ onCheckedChange={checked => {
65
+ state.staticTagChecked = checked
66
+ }}/>
67
+ <Spacer width={cx(8)} height={0}/>
68
+ <Tag
69
+ checked={state.dynamicTagChecked}
70
+ text={I18n.getLang('mood_overview_filter_name_text2')}
71
+ onCheckedChange={checked => {
72
+ state.dynamicTagChecked = checked
73
+ }}/>
74
+ </View>
75
+ <Spacer height={cx(10)}/>
76
+ <FlatList
77
+ data={state.filteredMoods}
78
+ renderItem={({ item }) => {
79
+ return (
80
+ <MoodItem
81
+ style={{ marginHorizontal: cx(8) }}
82
+ enable={state.currentScene?.id === item.id}
83
+ mood={item}
84
+ onSwitch={async _ => {
85
+ state.currentScene = item
86
+ setScene(item)
87
+ }}/>
88
+ )
89
+ }}
90
+ ListHeaderComponent={() => (<Spacer height={cx(10)}/>)}
91
+ ItemSeparatorComponent={() => (<Spacer/>)}
92
+ ListFooterComponent={() => (
93
+ <View style={styles.infoLine}>
94
+ <Spacer/>
95
+ <InfoText
96
+ icon={res.ic_info}
97
+ text={I18n.getLang('mood_overview_information_text')}/>
98
+ <Spacer height={cx(40)}/>
99
+ </View>
100
+ )}
101
+ keyExtractor={item => `${item.id}`}/>
102
+ </>
103
+ )
108
104
  }
109
105
 
110
106
  const styles = StyleSheet.create({
111
- tagLine: {
112
- flexDirection: 'row',
113
- // marginHorizontal: cx(24),
114
- marginTop: cx(16)
115
- },
116
- infoLine: {
117
- // marginHorizontal: cx(24),
118
- },
119
- addMoodPopover: {
120
- width: cx(171),
121
- height: cx(90.5),
122
- marginStart: cx(156),
123
- marginTop: cx(105),
124
- backgroundColor: '#fff',
125
- },
126
- popoverItem: {
127
- width: cx(171),
128
- height: cx(45),
129
- alignItems: 'flex-start',
130
- },
131
- popoverItemText: {
132
- color: '#000',
133
- fontSize: cx(16),
134
- },
135
- line: {
136
- height: .5,
137
- backgroundColor: 'rgba(60,60,67,.36)',
138
- },
107
+ tagLine: {
108
+ flexDirection: 'row',
109
+ // marginHorizontal: cx(24),
110
+ marginTop: cx(16),
111
+ },
112
+ infoLine: {
113
+ // marginHorizontal: cx(24),
114
+ },
115
+ addMoodPopover: {
116
+ width: cx(171),
117
+ height: cx(90.5),
118
+ marginStart: cx(156),
119
+ marginTop: cx(105),
120
+ backgroundColor: '#fff',
121
+ },
122
+ popoverItem: {
123
+ width: cx(171),
124
+ height: cx(45),
125
+ alignItems: 'flex-start',
126
+ },
127
+ popoverItemText: {
128
+ color: '#000',
129
+ fontSize: cx(16),
130
+ },
131
+ line: {
132
+ height: .5,
133
+ backgroundColor: 'rgba(60,60,67,.36)',
134
+ },
139
135
  })
140
136
 
141
137
  export default ScheduleScene
@@ -1,178 +1,189 @@
1
- import React, { useCallback, useEffect } from 'react'
1
+ import React, { useCallback } from 'react'
2
2
  import { View } from 'react-native'
3
3
  import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
4
4
  import { Utils } from 'tuya-panel-kit'
5
5
  import { useReactive, useUpdateEffect } from 'ahooks'
6
- import { hsv2Hex } from '@ledvance/base/src/utils'
6
+ import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils'
7
7
  import I18n from '@ledvance/base/src/i18n'
8
8
  import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
9
9
  import Card from '@ledvance/base/src/components/Card'
10
10
  import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
11
- import { mapFloatToRange } from '@ledvance/base/src/utils'
12
11
  import { modeOptions } from '../../hooks/DeviceDpStateHooks'
13
12
  import { ScheduleItemDp } from './TimeScheduleEditpage'
14
13
  import FanAdjustView from '@ledvance/base/src/components/FanAdjustView'
15
14
  import { useFanMaxSpeed } from '@ledvance/base/src/models/modules/NativePropsSlice'
16
15
  import { JudgeTimeScheduleProps } from './TimeScheduleBean'
16
+ import { cloneDeep } from 'lodash'
17
17
 
18
18
  const { convertX: cx } = Utils.RatioUtils
19
19
 
20
20
  interface SingleLightViewProps extends JudgeTimeScheduleProps {
21
- singleActions: any
22
- scheduleItem: any
23
- dpCodes: Record<string, string>
24
- dp: ScheduleItemDp
25
- setSendDps: (actions: any,type: string) => void
26
- setEnable: (dpId: string, enable: boolean) => void
21
+ singleActions: any
22
+ scheduleItem: any
23
+ dpCodes: Record<string, string>
24
+ dp: ScheduleItemDp
25
+ setSendDps: (actions: any, type: string) => void
26
+ setEnable: (dpId: string, enable: boolean) => void
27
27
  }
28
28
 
29
29
  export default function SingleLightView(props: SingleLightViewProps) {
30
- const { dp, setSendDps, setEnable, isDIMLamp, isOnlyRGBLamp, isRGBLamp, isRGBWLamp, isTWLamp, isSupportBrightness, isSupportTemperature, isSupportMode } = props
31
- const state = useReactive({
32
- actions: props.singleActions,
33
- flag: Symbol()
34
- })
35
-
36
- useUpdateEffect(() =>{
37
- state.actions = props.singleActions
38
- }, [props.singleActions])
39
-
40
- useEffect(() => {
41
- setSendDps(state.actions, 'singleActions')
42
- }, [state.flag])
43
-
44
-
45
- const setHSVState = useCallback((h, s, v) => {
46
- state.actions.h = h
47
- state.actions.s = s
48
- state.actions.v = v
49
- }, [])
50
-
51
- const setTemperatureState = useCallback(temperature => {
52
- state.actions.temperature = temperature
53
- }, [])
54
-
55
- const setBrightnessState = useCallback(brightness => {
56
- state.actions.brightness = brightness
57
- }, [])
58
-
59
-
60
-
61
- const setEnableStateAction = useCallback(async (enable) => {
62
- state.actions.enable = enable
63
- setEnable(dp.dpId, enable)
64
- state.flag = Symbol()
65
- }, [])
66
-
67
- const setWorkModeStateAction = useCallback(async isColorMode => {
68
- state.actions.isColor = isColorMode
69
- state.flag = Symbol()
70
-
71
- }, [])
72
-
73
- const setColourStateAction = useCallback(async (h, s, v) => {
74
- setHSVState(h, s, v)
75
- state.flag = Symbol()
76
- }, [])
77
-
78
- const setTemperatureStateAction = useCallback(async (cct: number) => {
79
- setTemperatureState(cct)
80
- state.flag = Symbol()
81
- }, [])
82
-
83
- const setBrightnessStateAction = useCallback(async brightness => {
84
- setBrightnessState(brightness)
85
- state.flag = Symbol()
86
- }, [])
87
-
88
-
89
- const getColorBlockColor = useCallback(() => {
90
- const s = Math.round(mapFloatToRange(state.actions.s / 100, 30, 100))
91
- if (isOnlyRGBLamp) {
92
- return hsv2Hex(state.actions.h, s, 100)
93
- }
94
- if (isTWLamp) {
95
- return cctToColor(state.actions.temperature.toFixed())
96
- }
97
- if (isDIMLamp) {
98
- return '#fff'
99
- }
100
- if (state.actions.isColor) {
101
- return hsv2Hex(state.actions.h, s, 100)
102
- }
103
- if (isSupportTemperature) {
104
- return cctToColor(state.actions.temperature.toFixed())
105
- }
106
- }, [state.actions.temperature])
107
-
108
- return (
109
- <Card style={{ marginVertical: cx(12) }}>
110
- {props.dp.value.includes('light') ?
111
- <View>
112
- <LdvSwitch
113
- title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
114
- color={getColorBlockColor()}
115
- colorAlpha={1}
116
- enable={state.actions.enable}
117
- setEnable={setEnableStateAction} />
118
- {state.actions.enable &&
119
- <LampAdjustView
120
- isDIMLamp={isDIMLamp}
121
- isRGBLamp={isRGBLamp}
122
- isOnlyRGBLamp={isOnlyRGBLamp}
123
- isTWLamp={isTWLamp}
124
- isRGBWLamp={isRGBWLamp}
125
- isSupportBrightness={!!isSupportBrightness}
126
- isSupportTemperature={!!isSupportTemperature}
127
- isColorMode={state.actions.isColor}
128
- setIsColorMode={setWorkModeStateAction}
129
- h={state.actions.h}
130
- s={state.actions.s}
131
- v={state.actions.v}
132
- onHSVChange={setHSVState}
133
- onHSVChangeComplete={setColourStateAction}
134
- colorTemp={state.actions.temperature}
135
- brightness={state.actions.brightness}
136
- onCCTChange={setTemperatureState}
137
- onCCTChangeComplete={setTemperatureStateAction}
138
- onBrightnessChange={setBrightnessState}
139
- onBrightnessChangeComplete={setBrightnessStateAction}
140
- // min={1}
141
- />}
142
- </View> :
143
- props.dp.value.includes('fan') ?
144
- <FanAdjustView
145
- isSupportMode={isSupportMode}
146
- modeValue={state.actions.fanMode}
147
- fanEnable={state.actions.fanEnable}
148
- fanSpeed={state.actions.fanSpeed}
149
- maxFanSpeed={useFanMaxSpeed()}
150
- modeOptions={modeOptions}
151
- modeChange={mode => {
152
- state.actions.fanMode = mode
153
- state.flag = Symbol()
154
- }}
155
- onFanSwitch={fanEnable => {
156
- state.actions.fanEnable = fanEnable
157
- setEnable(dp.dpId, fanEnable)
158
- }}
159
- onFanSpeedChange={fanSpeed => {
160
- state.actions.fanSpeed = fanSpeed
161
- }}
162
- onFanSpeedChangeComplete={fanSpeed => {
163
- state.actions.fanSpeed = fanSpeed
164
- state.flag = Symbol()
165
- }}
166
-
167
- /> :
168
- <LdvSwitch
169
- title={dp.label}
170
- enable={dp.enable}
171
- setEnable={(v: boolean) => setEnable(dp.dpId, v)}
172
- color={''}
173
- colorAlpha={1}
174
- />
175
- }
176
- </Card>
177
- )
30
+ const {
31
+ dp,
32
+ setSendDps,
33
+ setEnable,
34
+ isDIMLamp,
35
+ isOnlyRGBLamp,
36
+ isRGBLamp,
37
+ isRGBWLamp,
38
+ isTWLamp,
39
+ isSupportBrightness,
40
+ isSupportTemperature,
41
+ isSupportMode,
42
+ } = props
43
+ const state = useReactive({
44
+ actions: cloneDeep(props.singleActions),
45
+ flag: Symbol(),
46
+ })
47
+
48
+ useUpdateEffect(() => {
49
+ state.actions = cloneDeep(props.singleActions)
50
+ }, [JSON.stringify(props.singleActions)])
51
+
52
+ useUpdateEffect(() => {
53
+ setSendDps(state.actions, 'singleActions')
54
+ }, [state.flag])
55
+
56
+
57
+ const setHSVState = useCallback((h, s, v) => {
58
+ state.actions.h = h
59
+ state.actions.s = s
60
+ state.actions.v = v
61
+ }, [])
62
+
63
+ const setTemperatureState = useCallback(temperature => {
64
+ state.actions.temperature = temperature
65
+ }, [])
66
+
67
+ const setBrightnessState = useCallback(brightness => {
68
+ state.actions.brightness = brightness
69
+ }, [])
70
+
71
+
72
+ const setEnableStateAction = useCallback(async (enable) => {
73
+ state.actions.enable = enable
74
+ setEnable(dp.dpId, enable)
75
+ state.flag = Symbol()
76
+ }, [])
77
+
78
+ const setWorkModeStateAction = useCallback(async isColorMode => {
79
+ state.actions.isColor = isColorMode
80
+ state.flag = Symbol()
81
+
82
+ }, [])
83
+
84
+ const setColourStateAction = useCallback(async (h, s, v) => {
85
+ setHSVState(h, s, v)
86
+ state.flag = Symbol()
87
+ }, [])
88
+
89
+ const setTemperatureStateAction = useCallback(async (cct: number) => {
90
+ setTemperatureState(cct)
91
+ state.flag = Symbol()
92
+ }, [])
93
+
94
+ const setBrightnessStateAction = useCallback(async brightness => {
95
+ setBrightnessState(brightness)
96
+ state.flag = Symbol()
97
+ }, [])
98
+
99
+
100
+ const getColorBlockColor = useCallback(() => {
101
+ const s = Math.round(mapFloatToRange(state.actions.s / 100, 30, 100))
102
+ if (isOnlyRGBLamp) {
103
+ return hsv2Hex(state.actions.h, s, 100)
104
+ }
105
+ if (isTWLamp) {
106
+ return cctToColor(state.actions.temperature.toFixed())
107
+ }
108
+ if (isDIMLamp) {
109
+ return '#fff'
110
+ }
111
+ if (state.actions.isColor) {
112
+ return hsv2Hex(state.actions.h, s, 100)
113
+ }
114
+ if (isSupportTemperature) {
115
+ return cctToColor(state.actions.temperature.toFixed())
116
+ }
117
+ }, [state.actions.temperature])
118
+
119
+ return (
120
+ <Card style={{ marginVertical: cx(12) }}>
121
+ {props.dp.value.includes('light') ?
122
+ <View>
123
+ <LdvSwitch
124
+ title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
125
+ color={getColorBlockColor()}
126
+ colorAlpha={1}
127
+ enable={state.actions.enable}
128
+ setEnable={setEnableStateAction}/>
129
+ {state.actions.enable &&
130
+ <LampAdjustView
131
+ isDIMLamp={!!isDIMLamp}
132
+ isRGBLamp={!!isRGBLamp}
133
+ isOnlyRGBLamp={!!isOnlyRGBLamp}
134
+ isTWLamp={!!isTWLamp}
135
+ isRGBWLamp={!!isRGBWLamp}
136
+ isSupportBrightness={!!isSupportBrightness}
137
+ isSupportTemperature={!!isSupportTemperature}
138
+ isColorMode={state.actions.isColor}
139
+ setIsColorMode={setWorkModeStateAction}
140
+ h={state.actions.h}
141
+ s={state.actions.s}
142
+ v={state.actions.v}
143
+ onHSVChange={setHSVState}
144
+ onHSVChangeComplete={setColourStateAction}
145
+ colorTemp={state.actions.temperature}
146
+ brightness={state.actions.brightness}
147
+ onCCTChange={setTemperatureState}
148
+ onCCTChangeComplete={setTemperatureStateAction}
149
+ onBrightnessChange={setBrightnessState}
150
+ onBrightnessChangeComplete={setBrightnessStateAction}
151
+ // min={1}
152
+ />}
153
+ </View> :
154
+ props.dp.value.includes('fan') ?
155
+ <FanAdjustView
156
+ isSupportMode={isSupportMode}
157
+ modeValue={state.actions.fanMode}
158
+ fanEnable={state.actions.fanEnable}
159
+ fanSpeed={state.actions.fanSpeed}
160
+ maxFanSpeed={useFanMaxSpeed()}
161
+ modeOptions={modeOptions}
162
+ modeChange={mode => {
163
+ state.actions.fanMode = mode
164
+ state.flag = Symbol()
165
+ }}
166
+ onFanSwitch={fanEnable => {
167
+ state.actions.fanEnable = fanEnable
168
+ setEnable(dp.dpId, fanEnable)
169
+ }}
170
+ onFanSpeedChange={fanSpeed => {
171
+ state.actions.fanSpeed = fanSpeed
172
+ }}
173
+ onFanSpeedChangeComplete={fanSpeed => {
174
+ state.actions.fanSpeed = fanSpeed
175
+ state.flag = Symbol()
176
+ }}
177
+
178
+ /> :
179
+ <LdvSwitch
180
+ title={dp.label}
181
+ enable={dp.enable}
182
+ setEnable={(v: boolean) => setEnable(dp.dpId, v)}
183
+ color={''}
184
+ colorAlpha={1}
185
+ />
186
+ }
187
+ </Card>
188
+ )
178
189
  }
@@ -1,14 +1,14 @@
1
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
- isMixRGBWLamp?: boolean
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
+ isMixRGBWLamp?: boolean
14
14
  }
@@ -15,10 +15,9 @@ import { NativeApi } from '@ledvance/base/src/api/native'
15
15
  import { useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
16
16
  import res from '@ledvance/base/src/res'
17
17
  import { useReactive } from 'ahooks'
18
- import { dpItem } from './TimeSchedulePage'
19
- import { differenceBy } from 'lodash'
18
+ import { dpItem, TimeSchedulePageRouteParams } from './TimeSchedulePage'
19
+ import { cloneDeep, differenceBy } from 'lodash'
20
20
  import DeviceState from './DeviceState'
21
- import { JudgeTimeScheduleProps } from './TimeScheduleBean'
22
21
  import { getHexByHSV, getHSVByHex } from '@ledvance/base/src/utils'
23
22
  import { Buffer } from 'buffer'
24
23
  import { dp2Obj, obj2Dp } from './mix/MixLightActions'
@@ -31,13 +30,12 @@ export interface ScheduleItemDp extends dpItem {
31
30
  enable: boolean
32
31
  }
33
32
 
34
- interface TimeScheduleEditPageParams extends JudgeTimeScheduleProps {
33
+ interface TimeScheduleEditPageParams extends TimeSchedulePageRouteParams {
35
34
  mode: 'add' | 'edit'
36
35
  scheduleItem: any,
37
36
  dps: ScheduleItemDp[]
38
37
  dpCodes: Record<any, any>
39
38
  reloadData: () => void
40
- getDpValue?: (v: any) => any
41
39
  deleteDialog: (item: any) => Promise<void>
42
40
  }
43
41
 
@@ -45,7 +43,7 @@ const TimeScheduleEditPage = () => {
45
43
  const navigation = useNavigation()
46
44
  const devId = useDeviceId()
47
45
  const route = useRoute()
48
- const props = route.params as TimeScheduleEditPageParams
46
+ const props = cloneDeep(route.params) as TimeScheduleEditPageParams
49
47
  const { scheduleItem, dps, reloadData, deleteDialog, dpCodes } = props
50
48
  const state = useReactive({
51
49
  loading: false,
@@ -83,7 +81,6 @@ const TimeScheduleEditPage = () => {
83
81
  dpsValue: {} as Record<string, any>,
84
82
  })
85
83
 
86
-
87
84
  useEffect(() => {
88
85
  // 设置功能列表
89
86
  if (props.mode === 'edit' && scheduleItem) {
@@ -101,6 +98,19 @@ const TimeScheduleEditPage = () => {
101
98
  }, [] as ScheduleItemDp[])
102
99
  state.skillList = differenceBy(dps, state.selectedSkill, 'dpId')
103
100
 
101
+ if (props.dps2lightData) {
102
+ const lightData = props.dps2lightData(scheduleItem.dps)
103
+ state.singleActions = {
104
+ ...state.singleActions,
105
+ ...lightData.singleActions,
106
+ }
107
+ state.isManual = lightData.isManual
108
+ state.actionScene = lightData.actionScene
109
+
110
+ console.log('singleActions', JSON.stringify(state.singleActions))
111
+ return
112
+ }
113
+
104
114
  // single
105
115
  if (scheduleItem.dps[dpCodes.switch_led] !== undefined) {
106
116
  state.singleActions.enable = scheduleItem.dps[dpCodes.switch_led]
@@ -155,7 +165,6 @@ const TimeScheduleEditPage = () => {
155
165
  }
156
166
  }, [])
157
167
 
158
-
159
168
  const selectWeekAction = (idx: number) => {
160
169
  state.loop = state.loop.map((item, tempIndex) => {
161
170
  if (tempIndex === idx - 1) {
@@ -220,7 +229,6 @@ const TimeScheduleEditPage = () => {
220
229
  }
221
230
 
222
231
  const getSendDps = () => {
223
-
224
232
  if (state.isManual) {
225
233
  if (props.isDIMLamp) {
226
234
  return {
@@ -341,7 +349,7 @@ const TimeScheduleEditPage = () => {
341
349
  }
342
350
 
343
351
  const getAllDps = () => {
344
- const incommingValue = props.getDpValue ? props.getDpValue({
352
+ const incommingValue = props.lightData2dps ? props.lightData2dps({
345
353
  singleActions: state.singleActions,
346
354
  mixActions: state.mixActions,
347
355
  actionScene: state.actionScene,
@@ -363,10 +371,10 @@ const TimeScheduleEditPage = () => {
363
371
  }
364
372
 
365
373
  const setSendDps = useCallback((actions, type) => {
374
+ console.log('setSendDps', actions, type)
366
375
  state[type] = actions
367
376
  }, [])
368
377
 
369
- // console.log(state?.actionScene, '< --- actionScenen')
370
378
  const renderItem = ({ item }) => {
371
379
  return (
372
380
  <View style={{
@@ -25,18 +25,35 @@ export type dpItem = {
25
25
  dpId: string
26
26
  }
27
27
 
28
+ export interface LightData {
29
+ singleActions?: {
30
+ enable: boolean
31
+ isColor: boolean
32
+ h: number
33
+ s: number
34
+ v: number
35
+ temperature: number
36
+ brightness: number
37
+ },
38
+ actionScene?: any
39
+ mixActions?: any
40
+ isManual: boolean
41
+ }
42
+
28
43
  export interface TimeSchedulePageRouteParams extends JudgeTimeScheduleProps {
29
44
  dps: dpItem[],
30
- dpCodes: Record<string, string>
31
- getDpValue?: (v: any) => any
45
+ lightData2dps?: (data: LightData) => any
46
+ dps2lightData?: (dps: any) => LightData
32
47
  }
33
48
 
34
-
35
49
  const TimeSchedulePage = () => {
36
50
  const deviceInfo = useDeviceInfo()
37
51
  const navigation = useNavigation()
38
52
  const props = useRoute().params as TimeSchedulePageRouteParams
39
- const { dps, dpCodes } = props
53
+
54
+ console.log('TimeSchedulePage params', props)
55
+
56
+ const { dps } = props
40
57
  const state = useReactive({
41
58
  timeScheduleList: [] as any[],
42
59
  filterScheduleList: [] as any[],
@@ -47,8 +64,8 @@ const TimeSchedulePage = () => {
47
64
  return pre
48
65
  }, {}) : {},
49
66
  })
50
- const [, setTimeSchedule] = useTimeSchedule()
51
67
 
68
+ const [, setTimeSchedule] = useTimeSchedule()
52
69
 
53
70
  useEffect(() => {
54
71
  getTimerScheduleList().then()
@@ -61,6 +78,7 @@ const TimeSchedulePage = () => {
61
78
  const checkedTags = Object.keys(state.filterTags).filter(tag => state.filterTags[tag])
62
79
  state.filterScheduleList = state.timeScheduleList.filter(item => checkedTags.every(tag => item.dps[tag] !== undefined))
63
80
  }
81
+ console.log('过滤后ScheduleList', state.filterScheduleList)
64
82
  }, [state.filterTags])
65
83
 
66
84
  const navigateToEdit = useCallback((mode: 'add' | 'edit', scheduleItem?: any) => {
@@ -82,21 +100,15 @@ const TimeSchedulePage = () => {
82
100
  if (res.result && res.value) {
83
101
  // 原生传过来的dps是json字符串。
84
102
  const originList = res.value.map((item: any) => {
85
- const itemDps = JSON.parse(item.dps)
86
-
87
- const dps = {}
88
- Object.keys(itemDps).forEach((dpCode: string) => {
89
- if (Object.values(dpCodes).findIndex(item => item === dpCode) !== -1) {
90
- dps[dpCode] = itemDps[dpCode]
91
- }
92
- })
93
103
  return {
94
104
  ...item,
95
- dps: dps,
105
+ dps: JSON.parse(item.dps),
96
106
  }
97
107
  })
98
108
  state.timeScheduleList = originList
99
109
  state.filterScheduleList = originList
110
+ console.log('获取TimerScheduleList', res)
111
+ console.log('获取TimerScheduleList', originList)
100
112
  setTimeSchedule(getScheduleRunning())
101
113
  }
102
114
  }