@ledvance/ui-biz-bundle 1.1.36 → 1.1.37

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.
@@ -1,4 +1,4 @@
1
- import React, { memo, useEffect } from 'react'
1
+ import React, { memo, useCallback, useEffect } from 'react'
2
2
  import { JudgeTimeScheduleProps } from './TimeScheduleBean'
3
3
  import { FlatList, View, StyleSheet } from 'react-native'
4
4
  import FantasyMoodItem from '../mood/FantasyMoodItem'
@@ -12,6 +12,9 @@ import MoodItem from '../mood/MoodItem'
12
12
  import { useReactive, useUpdateEffect } from 'ahooks'
13
13
  import { isUVCFanDevice, useDeviceId, useMoods } from '@ledvance/base/src/models/modules/NativePropsSlice'
14
14
  import { getRemoteFantasyScene, getRemoteSceneList } from '../scene/SceneAction'
15
+ import { getRemoteMixScene } from '../mood/MixMood/MixMoodActions'
16
+ import MixMoodItem from '../mood/MixMood/MixMoodItem'
17
+ import { MixSceneInfo } from '../mood/MixMood/MixSceneBeans'
15
18
  import { cloneDeep, isEmpty } from 'lodash'
16
19
 
17
20
  const cx = Utils.RatioUtils.convertX
@@ -23,8 +26,10 @@ interface MoodSettingProps extends JudgeTimeScheduleProps {
23
26
  }
24
27
 
25
28
  const MoodSetting = (props: MoodSettingProps) => {
26
- const { setSendDps, isStringLight, isStripLight, actionScene, fantasyFeatureId = '' } = props
29
+ const { setSendDps, isStringLight, isStripLight, actionScene, isCeilingLight, fantasyFeatureId = '' } = props
27
30
  const [moods, setMoods] = useMoods()
31
+ console.log(111)
32
+ console.log(moods[0], ' <-- moods[0')
28
33
  const devId = useDeviceId()
29
34
  const isUVCFan = isUVCFanDevice()
30
35
  const state = useReactive({
@@ -32,7 +37,7 @@ const MoodSetting = (props: MoodSettingProps) => {
32
37
  staticTagChecked: true,
33
38
  dynamicTagChecked: true,
34
39
  filteredMoods: cloneDeep(moods),
35
- currentScene: !isEmpty(actionScene) ? actionScene : moods[0]
40
+ currentScene: !isEmpty(actionScene) ? actionScene : cloneDeep(moods[0])
36
41
  })
37
42
 
38
43
  useUpdateEffect(() => {
@@ -44,9 +49,18 @@ const MoodSetting = (props: MoodSettingProps) => {
44
49
  if (isStringLight || isStripLight) {
45
50
  getRemoteFantasyScene(fantasyFeatureId, devId, { isStringLight, isStripLight }).then(res => {
46
51
  if (res.success && res.data) {
47
- state.scenes = cloneDeep(res.data)
48
- setMoods(res.data)
49
- if(isEmpty(actionScene)) state.currentScene = cloneDeep(res.data[0])
52
+ state.scenes = res.data
53
+ setMoods(res.data)
54
+ if (isEmpty(actionScene)) state.currentScene = res.data[0]
55
+ setSendDps(state.currentScene, 'actionScene')
56
+ }
57
+ })
58
+ } else if (isCeilingLight) {
59
+ getRemoteMixScene(devId).then(res => {
60
+ if (res.success && res.data) {
61
+ state.scenes = res.data
62
+ setMoods(cloneDeep(res.data))
63
+ if (isEmpty(actionScene)) state.currentScene = res.data[0]
50
64
  setSendDps(state.currentScene, 'actionScene')
51
65
  }
52
66
  })
@@ -62,71 +76,45 @@ const MoodSetting = (props: MoodSettingProps) => {
62
76
  if (res.success && res.data) {
63
77
  state.scenes = cloneDeep(res.data)
64
78
  setMoods(cloneDeep(res.data))
65
- if(isEmpty(actionScene)) state.currentScene = cloneDeep(res.data[0])
79
+ if (isEmpty(actionScene)) state.currentScene = res.data[0]
66
80
  setSendDps(state.currentScene, 'actionScene')
67
81
  }
68
82
  })
69
83
  }
70
-
71
- }else{
72
- setSendDps(cloneDeep(moods[0]), 'actionScene')
84
+
85
+ } else {
86
+ setSendDps(state.scenes[0], 'actionScene')
73
87
  }
74
88
  }, [])
75
89
 
76
90
  useEffect(() => {
77
- state.filteredMoods = state.scenes.filter(item => {
91
+ state.filteredMoods = cloneDeep(state.scenes).filter(item => {
78
92
  return (state.staticTagChecked && state.dynamicTagChecked) ||
79
93
  (state.staticTagChecked && item.nodes.length < 2) ||
80
94
  (state.dynamicTagChecked && item.nodes.length > 1)
81
95
  })
82
96
  }, [state.staticTagChecked, state.dynamicTagChecked, state.scenes])
83
97
 
98
+ const checkItemEnable = useCallback((mixMood: MixSceneInfo) => {
99
+ const { mainLamp, secondlyLamp } = mixMood
100
+ const cloneCurrentScene = cloneDeep(state.currentScene)
101
+ const isStatic = mainLamp.nodes.length === 1
102
+ return isStatic ? ((cloneCurrentScene?.mainLamp?.id === mainLamp.id) && mainLamp.id !== -1) :
103
+ ((cloneCurrentScene?.mainLamp?.id === mainLamp.id) && (cloneCurrentScene?.secondlyLamp?.id === secondlyLamp.id))
104
+ }, [state.currentScene])
105
+ console.log(state.scenes, '< --- state.cesee')
84
106
  return (
85
- (isStringLight || isStripLight) ?
86
- <FlatList
87
- data={state.scenes}
88
- renderItem={({ item }) => {
89
- return (
90
- <FantasyMoodItem
91
- style={{ marginHorizontal: cx(8) }}
92
- enable={state.currentScene?.id === item.id}
93
- mood={item}
94
- onPress={() => { }}
95
- onSwitch={async _ => {
96
- state.currentScene = item
97
- setSendDps(item, 'actionScene')
98
- }} />
99
- )
100
- }}
101
- ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
102
- ItemSeparatorComponent={() => (<Spacer />)}
103
- ListFooterComponent={() => (<Spacer />)}
104
- keyExtractor={item => `${item.id}`} /> :
105
- <>
106
- <View style={styles.tagLine}>
107
- <Tag
108
- checked={state.staticTagChecked}
109
- text={I18n.getLang('mood_overview_filter_name_text1')}
110
- onCheckedChange={checked => {
111
- state.staticTagChecked = checked
112
- }} />
113
- <Spacer width={cx(8)} height={0} />
114
- <Tag
115
- checked={state.dynamicTagChecked}
116
- text={I18n.getLang('mood_overview_filter_name_text2')}
117
- onCheckedChange={checked => {
118
- state.dynamicTagChecked = checked
119
- }} />
120
- </View>
121
- <Spacer height={cx(10)} />
107
+ <View style={{ marginHorizontal: -cx(24) }}>
108
+ {(isStringLight || isStripLight) ?
122
109
  <FlatList
123
- data={state.filteredMoods}
110
+ data={state.scenes}
124
111
  renderItem={({ item }) => {
125
112
  return (
126
- <MoodItem
127
- style={{ marginHorizontal: cx(8) }}
113
+ <FantasyMoodItem
114
+ style={{ marginHorizontal: cx(24) }}
128
115
  enable={state.currentScene?.id === item.id}
129
116
  mood={item}
117
+ onPress={() => { }}
130
118
  onSwitch={async _ => {
131
119
  state.currentScene = item
132
120
  setSendDps(item, 'actionScene')
@@ -135,17 +123,74 @@ const MoodSetting = (props: MoodSettingProps) => {
135
123
  }}
136
124
  ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
137
125
  ItemSeparatorComponent={() => (<Spacer />)}
138
- ListFooterComponent={() => (
139
- <View style={styles.infoLine}>
140
- <Spacer />
141
- <InfoText
142
- icon={res.ic_info}
143
- text={I18n.getLang('mood_overview_information_text')} />
144
- <Spacer height={cx(40)} />
126
+ ListFooterComponent={() => (<Spacer />)}
127
+ keyExtractor={item => `${item.id}`} /> :
128
+ isCeilingLight ?
129
+ <FlatList
130
+ data={state.filteredMoods}
131
+ renderItem={({ item }) => {
132
+ return (
133
+ <MixMoodItem
134
+ style={{ marginHorizontal: cx(24) }}
135
+ enable={checkItemEnable(item)}
136
+ mixMood={item}
137
+ onPress={() => { }}
138
+ onSwitch={async _ => {
139
+ state.currentScene = item
140
+ setSendDps(item, 'actionScene')
141
+ }}
142
+ />
143
+ )
144
+ }}
145
+ ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
146
+ ItemSeparatorComponent={() => (<Spacer />)}
147
+ ListFooterComponent={() => (<Spacer />)}
148
+ keyExtractor={item => `${item.name}`} /> :
149
+ <>
150
+ <View style={styles.tagLine}>
151
+ <Tag
152
+ checked={state.staticTagChecked}
153
+ text={I18n.getLang('mood_overview_filter_name_text1')}
154
+ onCheckedChange={checked => {
155
+ state.staticTagChecked = checked
156
+ }} />
157
+ <Spacer width={cx(8)} height={0} />
158
+ <Tag
159
+ checked={state.dynamicTagChecked}
160
+ text={I18n.getLang('mood_overview_filter_name_text2')}
161
+ onCheckedChange={checked => {
162
+ state.dynamicTagChecked = checked
163
+ }} />
145
164
  </View>
146
- )}
147
- keyExtractor={item => `${item.id}`} />
148
- </>
165
+ <Spacer height={cx(10)} />
166
+ <FlatList
167
+ data={state.filteredMoods}
168
+ renderItem={({ item }) => {
169
+ return (
170
+ <MoodItem
171
+ style={{ marginHorizontal: cx(24) }}
172
+ enable={state.currentScene?.id === item.id}
173
+ mood={item}
174
+ onSwitch={async _ => {
175
+ state.currentScene = item
176
+ setSendDps(item, 'actionScene')
177
+ }} />
178
+ )
179
+ }}
180
+ ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
181
+ ItemSeparatorComponent={() => (<Spacer />)}
182
+ ListFooterComponent={() => (
183
+ <View style={styles.infoLine}>
184
+ <Spacer />
185
+ <InfoText
186
+ icon={res.ic_info}
187
+ text={I18n.getLang('mood_overview_information_text')} />
188
+ <Spacer height={cx(40)} />
189
+ </View>
190
+ )}
191
+ keyExtractor={item => `${item.id}`} />
192
+ </>}
193
+ </View>
149
194
  )
150
195
  }
151
196
 
@@ -12,6 +12,7 @@ export interface JudgeTimeScheduleProps {
12
12
  isSupportMood?: boolean
13
13
  isStringLight?: boolean
14
14
  isStripLight?: boolean
15
+ isCeilingLight?: boolean
15
16
  isFanLamp?: boolean
16
17
  isSupportMode?: boolean
17
18
  isMixRGBWLamp?: boolean
@@ -16,7 +16,7 @@ import { isUVCFanDevice, useDeviceId } from '@ledvance/base/src/models/modules/N
16
16
  import res from '@ledvance/base/src/res'
17
17
  import { useReactive } from 'ahooks'
18
18
  import { dpItem, TimeSchedulePageRouteParams } from './TimeSchedulePage'
19
- import { cloneDeep, differenceBy, isEqual, isNumber } from 'lodash'
19
+ import { cloneDeep, differenceBy, isEmpty, isEqual } from 'lodash'
20
20
  import DeviceState from './DeviceState'
21
21
  import { getHexByHSV, getHSVByHex } from '@ledvance/base/src/utils'
22
22
  import { Buffer } from 'buffer'
@@ -58,7 +58,8 @@ const TimeScheduleEditPage = () => {
58
58
  skillList: [] as ScheduleItemDp[],
59
59
  isManual: true,
60
60
  singleActions: {
61
- enable: true,
61
+ enable: true, // colorLightSwitch
62
+ whiteLightSwitch: false,
62
63
  isColor: true,
63
64
  h: 0,
64
65
  s: 100,
@@ -85,7 +86,7 @@ const TimeScheduleEditPage = () => {
85
86
  actionScene: {} as any,
86
87
  dpsValue: {} as Record<string, any>,
87
88
  })
88
-
89
+ console.log(props, '< --- props')
89
90
  useEffect(() => {
90
91
  // 设置功能列表
91
92
  if (props.mode === 'edit' && scheduleItem) {
@@ -94,7 +95,7 @@ const TimeScheduleEditPage = () => {
94
95
  state.name = scheduleItem.aliasName
95
96
  state.isNotification = !!scheduleItem.isAppPush
96
97
  state.loop = scheduleItem.loops.split('').map((mItem: string) => parseInt(mItem))
97
- state.selectedSkill = dps.reduce((pre, cur) => {
98
+ state.selectedSkill = props.isCeilingLight ? props.dps : dps.reduce((pre, cur) => {
98
99
  if (scheduleItem.dps[cur.dpId] !== undefined) {
99
100
  const result = { ...cur, enable: scheduleItem.dps[cur.dpId] }
100
101
  pre.push(result)
@@ -104,7 +105,9 @@ const TimeScheduleEditPage = () => {
104
105
  state.skillList = differenceBy(dps, state.selectedSkill, 'dpId')
105
106
 
106
107
  if (props.dps2lightData) {
108
+ console.log(scheduleItem.dps, '< --- dps')
107
109
  const lightData = props.dps2lightData(scheduleItem.dps)
110
+ console.log(lightData, '< --- lightData')
108
111
  state.singleActions = {
109
112
  ...state.singleActions,
110
113
  ...lightData.singleActions,
@@ -183,6 +186,9 @@ const TimeScheduleEditPage = () => {
183
186
 
184
187
  // 只支持风扇灯跟普通灯
185
188
  const sceneCheck = () => {
189
+ if(props.isCeilingLight){
190
+ return (state.actionScene?.mainLamp?.nodes?.length) || (state.actionScene?.secondlyLamp?.nodes?.length)
191
+ }
186
192
  return !state.isManual && state.skillList.length === 0 && state.actionScene && (state?.actionScene?.nodes || state?.actionScene?.value)
187
193
  }
188
194
 
@@ -254,7 +260,7 @@ const TimeScheduleEditPage = () => {
254
260
  return props.lightData2dps({
255
261
  singleActions: state.singleActions,
256
262
  mixActions: state.mixActions,
257
- actionScene: isNumber(state.actionScene?.id) ? state.actionScene : undefined,
263
+ actionScene: !isEmpty(state.actionScene) ? state.actionScene : undefined,
258
264
  isManual: state.isManual,
259
265
  })
260
266
  }
@@ -361,6 +367,7 @@ const TimeScheduleEditPage = () => {
361
367
  } else {
362
368
  const v = {
363
369
  [dpCodes.switch_led]: true,
370
+ // @ts-ignore
364
371
  [dpCodes.scene_data]: senceObj2Dp({
365
372
  id: Number(state?.actionScene?.id),
366
373
  nodes: state?.actionScene?.nodes,
@@ -394,7 +401,6 @@ const TimeScheduleEditPage = () => {
394
401
  }
395
402
 
396
403
  const setSendDps = useCallback((actions, type) => {
397
- console.log('setSendDps --->', actions, type)
398
404
  state[type] = actions
399
405
  }, [])
400
406
 
@@ -448,7 +454,7 @@ const TimeScheduleEditPage = () => {
448
454
  }, [state.selectedSkill])
449
455
 
450
456
  const showClearIcon = () => {
451
- return dps.length > 1 && !props.isMixRGBWLamp
457
+ return dps.length > 1 && !props.isMixRGBWLamp && !props.isCeilingLight
452
458
  }
453
459
 
454
460
  return (
@@ -559,6 +565,7 @@ const TimeScheduleEditPage = () => {
559
565
  isStringLight={props.isStringLight}
560
566
  isStripLight={props.isStripLight}
561
567
  fantasyFeatureId={props.fantasyFeatureId}
568
+ isCeilingLight={props.isCeilingLight}
562
569
  />
563
570
  {!hasSelected() && <View style={{ flexDirection: 'row', alignItems: 'center' }}>
564
571
  <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber}/>
@@ -28,6 +28,7 @@ export type dpItem = {
28
28
  export interface LightData {
29
29
  singleActions?: {
30
30
  enable: boolean
31
+ whiteLightSwitch: boolean
31
32
  isColor: boolean
32
33
  h: number
33
34
  s: number
@@ -56,7 +57,6 @@ const TimeSchedulePage = () => {
56
57
  const deviceInfo = useDeviceInfo()
57
58
  const navigation = useNavigation()
58
59
  const props = useRoute().params as TimeSchedulePageRouteParams
59
-
60
60
  const { dps } = props
61
61
  const state = useReactive({
62
62
  timeScheduleList: [] as any[],
@@ -7,6 +7,9 @@ import AddMoodPage from '../modules/mood/AddMoodPage'
7
7
  import MoodPage from '../modules/mood/MoodPage'
8
8
  import FantasyMoodPage from '../modules/mood/FantasyMood'
9
9
  import FantasyMoodEditPage from '../modules/mood/FantasyMoodEditPage'
10
+ import MixMoodPage from '../modules/mood/MixMood/MixMoodPage'
11
+ import MixMoodEditPage from '../modules/mood/MixMood/MixMoodEditPage'
12
+ import AddMixMoodPage from '../modules/mood/MixMood/AddMixMoodPage'
10
13
  import TimerPage from '../modules/timer/TimerPage'
11
14
  import SleepWakeUpPage from 'modules/sleepWakeup/SleepWakeUpPage'
12
15
  import SleepWakeUpDetailPage from 'modules/sleepWakeup/SleepWakeUpDetailPage'
@@ -33,6 +36,9 @@ export const ui_biz_routerKey = {
33
36
  'ui_biz_mood_add': 'ui-biz_mood_add',
34
37
  'ui_biz_static_mood_edit': 'ui_biz_static_mood_edit',
35
38
  'ui_biz_dynamic_mood_edit': 'ui_biz_dynamic_mood_edit',
39
+ 'ui_biz_mix_mood': 'ui_biz_mix_mood',
40
+ 'ui_biz_mix_mood_edit': 'ui_biz_mix_mood_edit',
41
+ 'ui_biz_mix_mood_add': 'ui_biz_mix_mood_add',
36
42
  'ui_biz_timer': 'ui_biz_timer',
37
43
  'bi_biz_biological': 'bi_biz_biological',
38
44
  'bi_biz_biological_edit': 'bi_biz_biological_edit',
@@ -169,6 +175,42 @@ export const FantasyMoodRouters: NavigationRoute[] = [
169
175
  },
170
176
  ]
171
177
 
178
+ export const MixMoodRouters: NavigationRoute[] = [
179
+ {
180
+ name: ui_biz_routerKey.ui_biz_mix_mood,
181
+ component: MixMoodPage,
182
+ options: {
183
+ hideTopbar: true,
184
+ showOfflineView: false,
185
+ }
186
+ },
187
+ {
188
+ name: ui_biz_routerKey.ui_biz_mix_mood_edit,
189
+ component: MixMoodEditPage,
190
+ options: {
191
+ hideTopbar: true,
192
+ showOfflineView: false,
193
+ },
194
+ },
195
+ {
196
+ name: ui_biz_routerKey.ui_biz_mix_mood_add,
197
+ component: AddMixMoodPage,
198
+ options: {
199
+ hideTopbar: true,
200
+ showOfflineView: false,
201
+ },
202
+ },
203
+ {
204
+ name: ui_biz_routerKey.ui_biz_select_page,
205
+ component: SelectPage,
206
+ options: {
207
+ gesture: true,
208
+ hideTopbar: true,
209
+ ...TransitionPresets.ModalPresentationIOS,
210
+ },
211
+ },
212
+ ]
213
+
172
214
  export const TimerPageRouters: NavigationRoute[] = [
173
215
  {
174
216
  name: ui_biz_routerKey.ui_biz_timer,