@ledvance/ui-biz-bundle 1.1.64 → 1.1.66

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.64",
7
+ "version": "1.1.66",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -7,6 +7,7 @@ export const ui_biz_routerKey = {
7
7
  'ui_biz_mood_add': 'ui-biz_mood_add',
8
8
  'ui_biz_static_mood_edit': 'ui_biz_static_mood_edit',
9
9
  'ui_biz_dynamic_mood_edit': 'ui_biz_dynamic_mood_edit',
10
+ 'ui_biz_dynamic_mix_mood_edit': 'ui_biz_dynamic_mix_mood_edit',
10
11
  'ui_biz_mix_mood': 'ui_biz_mix_mood',
11
12
  'ui_biz_mix_mood_edit': 'ui_biz_mix_mood_edit',
12
13
  'ui_biz_mix_mood_add': 'ui_biz_mix_mood_add',
@@ -122,7 +122,8 @@ export const useFixedTime: UseFixedTimeType = (dpKey, isPlug, disableFeature) =>
122
122
  length: isPlug ? 10 : 16,
123
123
  nodes: fixedTimeList
124
124
  }
125
- const hex = fixedTimeObj2Dp(fixedTimerData, isPlug)
125
+ let hex = fixedTimeObj2Dp(fixedTimerData, isPlug)
126
+ if(isPlug) hex = Buffer.from(hex, 'hex').toString('base64')
126
127
  const res = await setFixedTimeDp(hex)
127
128
  if (res.success) {
128
129
  return {
@@ -174,10 +174,10 @@ const FixedTimeDetailPage = () => {
174
174
  </View>
175
175
  <Spacer />
176
176
  {/* Devices */}
177
- <View style={styles.cardContainer}>
177
+ {state.fixedTime.color && !params.isPlug && <View style={styles.cardContainer}>
178
178
  <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
179
179
  <Spacer height={cx(10)} />
180
- {state.fixedTime.color && !params.isPlug && <Card>
180
+ <Card>
181
181
  <LdvSwitch
182
182
  title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
183
183
  color={'#fff'}
@@ -219,9 +219,9 @@ const FixedTimeDetailPage = () => {
219
219
  }
220
220
  }}
221
221
  />
222
- </Card>}
222
+ </Card>
223
223
  <Spacer />
224
- </View>
224
+ </View>}
225
225
  {/* Settings */}
226
226
  <View style={styles.cardContainer}>
227
227
  <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}</Text>
@@ -77,17 +77,14 @@ const FixedTimePage = () => {
77
77
  }, [state.originList.length])
78
78
 
79
79
  const onPost = useCallback(async (mode: 'add' | 'edit' | 'del', fixedTime: FixedTimerUiItem) => {
80
- console.log(fixedTime, '< --- fixedTimeeeeee')
81
80
  const cloneFixedTimeList = cloneDeep(state.originList)
82
81
  const idx = state.originList.findIndex(f => f.index === fixedTime.index)
83
- console.log(idx, '< --- idxxxxx')
84
82
  if (mode === 'edit') {
85
83
  cloneFixedTimeList.splice(idx, 1, fixedTime)
86
84
  }
87
85
  if (mode === 'del') cloneFixedTimeList.splice(idx, 1)
88
86
  const newFixedTimeList = mode === 'add' ? [...state.originList, fixedTime] : cloneFixedTimeList
89
87
  const res = await setFixedTime(newFixedTimeList)
90
- console.log(res, '< ---== resss')
91
88
  if (res.success) {
92
89
  state.originList = cloneDeep(newFixedTimeList)
93
90
  }
@@ -35,7 +35,7 @@ import {
35
35
  } from './Interface';
36
36
  import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton';
37
37
  import FanAdjustView from '@ledvance/base/src/components/FanAdjustView';
38
- import { RouterKey } from 'navigation/Router';
38
+ import { ui_biz_routerKey } from '../../navigation/Routers'
39
39
  import { SelectPageParams } from '@ledvance/ui-biz-bundle/src/modules/select/SelectPage';
40
40
  import I18n from '@ledvance/base/src/i18n';
41
41
  import Segmented from '@ledvance/base/src/components/Segmented';
@@ -94,15 +94,6 @@ const DynamicMoodEditorPage = () => {
94
94
  return cctToColor(node.colorTemp.toFixed());
95
95
  }, []);
96
96
 
97
- const getButtonStatus = () => {
98
- return (
99
- (params.mode === 'edit' && isEqual(state.mood, routeParams.currentMood)) ||
100
- !!!state.mood.name ||
101
- nameRepeat ||
102
- state.mood.name.length > 32
103
- );
104
- };
105
-
106
97
  const createSelectModeData = useCallback(
107
98
  (mode: number, moodMode?: StripLightMoodMode) => {
108
99
  return Object.values(moodMode ? moodMode : state.sceneMode).map(scene => {
@@ -132,17 +123,21 @@ const DynamicMoodEditorPage = () => {
132
123
  }, []);
133
124
 
134
125
  const nameRepeat = useMemo(() => {
135
- return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
126
+ return params.nameRepeat(state.mood)
136
127
  }, [state.mood.name]);
137
128
 
138
- const showBackDialog = (): boolean => {
139
- return !isEqual(state.mood, routeParams.currentMood);
140
- }
129
+ const checkMoodChanged = useMemo(() =>{
130
+ return isEqual(state.mood, params.currentMood)
131
+ }, [JSON.stringify(state.mood), params.currentMood])
132
+
133
+ const canSaveMoodData = useMemo(() =>{
134
+ return state.mood.name.length > 0 && state.mood.name.length < 33 && !nameRepeat && (params.mode === 'add' || !checkMoodChanged)
135
+ }, [nameRepeat, state.mood.name, checkMoodChanged, params.mode])
141
136
 
142
137
  return (
143
138
  <Page
144
139
  backText={Strings.getLang('mesh_device_detail_mode')}
145
- showBackDialog={showBackDialog()}
140
+ showBackDialog={!checkMoodChanged}
146
141
  backDialogTitle={Strings.getLang(
147
142
  params.mode === 'add'
148
143
  ? 'string_light_pp_dialog_sm_add_headline_c'
@@ -154,16 +149,13 @@ const DynamicMoodEditorPage = () => {
154
149
  : 'strip_light_static_mood_editor_step_2_dialog_text'
155
150
  )}
156
151
  headlineText={state.headline}
157
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
152
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
158
153
  rightButtonIconClick={async () => {
159
- if (getButtonStatus()) {
160
- return
161
- }
162
- if (state.loading) return;
154
+ if (state.loading || !canSaveMoodData) return;
163
155
  state.loading = true;
164
156
  const res = await params.modDeleteMood(params.mode, cloneDeep(state.mood));
165
157
  if (res.success) {
166
- navigation.navigate(RouterKey.ui_biz_mood);
158
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
167
159
  }
168
160
  state.loading = false;
169
161
  }}
@@ -206,7 +198,7 @@ const DynamicMoodEditorPage = () => {
206
198
  state.mood.mainLamp.mode = selectPageData.value;
207
199
  },
208
200
  };
209
- navigation.navigate(RouterKey.ui_biz_select_page, paramsSelect);
201
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect);
210
202
  }}
211
203
  />
212
204
  <Spacer height={cx(10)} />
@@ -281,7 +273,7 @@ const DynamicMoodEditorPage = () => {
281
273
  state.mood.mainLamp.expand = selectPageData.value;
282
274
  },
283
275
  };
284
- navigation.navigate(RouterKey.ui_biz_select_page, paramsSelect);
276
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect);
285
277
  }}
286
278
  />
287
279
  <Spacer />
@@ -544,7 +536,7 @@ const DynamicMoodEditorPage = () => {
544
536
  const res = await params.modDeleteMood('del', state.mood);
545
537
  state.loading = false
546
538
  if (res.success) {
547
- navigation.navigate(RouterKey.ui_biz_mood);
539
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
548
540
  }
549
541
  }
550
542
  })
@@ -95,6 +95,7 @@ export interface DefMoodOption extends LightCategory{
95
95
  }
96
96
 
97
97
  export interface MoodDps {
98
+ switchLedDp: string
98
99
  mainDp: string;
99
100
  mainWorkMode: string;
100
101
  mainSwitch: string;
@@ -30,8 +30,7 @@ import {
30
30
  StripLightMoodMode,
31
31
  } from './Interface';
32
32
  import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton';
33
- import { showDeleteMoodDialog } from './tools';
34
- import { RouterKey } from 'navigation/Router';
33
+ import {ui_biz_routerKey} from '../../navigation/Routers'
35
34
  import { SelectPageParams } from '@ledvance/ui-biz-bundle/src/modules/select/SelectPage';
36
35
  import I18n from '@ledvance/base/src/i18n';
37
36
  import Segmented from '@ledvance/base/src/components/Segmented';
@@ -39,6 +38,7 @@ import { MoodNodeInfo } from './Interface';
39
38
  import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
40
39
  import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
41
40
  import ColorTempAdjustView from '@ledvance/base/src/components/ColorTempAdjustView';
41
+ import { showDialog } from '@ledvance/base/src/utils/common';
42
42
 
43
43
  const cx = Utils.RatioUtils.convertX;
44
44
  interface MixDynamicMoodEditorPageState extends StaticMoodEditorPageState {
@@ -91,15 +91,6 @@ const MixDynamicMoodEditorPage = () => {
91
91
  return cctToColor(node.colorTemp.toFixed());
92
92
  }, []);
93
93
 
94
- const getButtonStatus = () => {
95
- return (
96
- (params.mode === 'edit' && isEqual(state.mood, routeParams.currentMood)) ||
97
- !!!state.mood.name ||
98
- nameRepeat ||
99
- state.mood.name.length > 32
100
- );
101
- };
102
-
103
94
  const createSelectModeData = useCallback(
104
95
  (mode: number, moodMode: StripLightMoodMode) => {
105
96
  return Object.values(moodMode).map(scene => {
@@ -129,17 +120,21 @@ const MixDynamicMoodEditorPage = () => {
129
120
  }, []);
130
121
 
131
122
  const nameRepeat = useMemo(() => {
132
- return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
123
+ return params.nameRepeat(state.mood)
133
124
  }, [state.mood.name]);
134
125
 
135
- const showBackDialog = (): boolean => {
136
- return !isEqual(state.mood, routeParams.currentMood);
137
- }
126
+ const checkMoodChanged = useMemo(() =>{
127
+ return isEqual(state.mood, params.currentMood)
128
+ }, [JSON.stringify(state.mood), params.currentMood])
129
+
130
+ const canSaveMoodData = useMemo(() =>{
131
+ return state.mood.name.length > 0 && state.mood.name.length < 33 && !nameRepeat && (params.mode === 'add' || !checkMoodChanged)
132
+ }, [nameRepeat, state.mood.name, checkMoodChanged, params.mode])
138
133
 
139
134
  return (
140
135
  <Page
141
136
  backText={Strings.getLang('mesh_device_detail_mode')}
142
- showBackDialog={showBackDialog()}
137
+ showBackDialog={!checkMoodChanged}
143
138
  backDialogTitle={Strings.getLang(
144
139
  params.mode === 'add'
145
140
  ? 'string_light_pp_dialog_sm_add_headline_c'
@@ -151,26 +146,25 @@ const MixDynamicMoodEditorPage = () => {
151
146
  : 'strip_light_static_mood_editor_step_2_dialog_text'
152
147
  )}
153
148
  headlineText={state.headline}
154
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
149
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
155
150
  rightButtonIconClick={async () => {
156
- if (getButtonStatus()) {
157
- return
158
- }
159
- if (state.loading) return;
151
+ if (state.loading || !canSaveMoodData) return;
160
152
  state.loading = true;
161
153
  const newMood = cloneDeep(state.mood)
162
- if(moduleParams.isSupportBrightness){
163
- newMood.mainLamp.type = 1
164
- }
165
- if(moduleParams.isSupportBrightness && moduleParams.isSupportTemperature){
166
- newMood.mainLamp.type = 2
167
- }
168
- if(moduleParams.isSupportColor){
169
- newMood.secondaryLamp.type = 3
154
+ if(moduleParams.isMixLight){
155
+ if(moduleParams.isSupportBrightness){
156
+ newMood.mainLamp.type = 1
157
+ }
158
+ if(moduleParams.isSupportBrightness && moduleParams.isSupportTemperature){
159
+ newMood.mainLamp.type = 2
160
+ }
161
+ if(moduleParams.isSupportColor){
162
+ newMood.secondaryLamp.type = 3
163
+ }
170
164
  }
171
165
  const res = await params.modDeleteMood(params.mode, newMood);
172
166
  if (res.success) {
173
- navigation.navigate(RouterKey.ui_biz_mood);
167
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
174
168
  }
175
169
  state.loading = false;
176
170
  }}
@@ -243,7 +237,7 @@ const MixDynamicMoodEditorPage = () => {
243
237
  state.mood.mainLamp.mode = selectPageData.value;
244
238
  },
245
239
  };
246
- navigation.navigate(RouterKey.ui_biz_select_page, paramsSelect);
240
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect);
247
241
  }}
248
242
  />
249
243
  <Spacer height={cx(10)} />
@@ -440,7 +434,7 @@ const MixDynamicMoodEditorPage = () => {
440
434
  state.mood.secondaryLamp.mode = selectPageData.value;
441
435
  },
442
436
  };
443
- navigation.navigate(RouterKey.ui_biz_select_page, paramsSelect);
437
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect);
444
438
  }}
445
439
  />
446
440
  <Spacer height={cx(10)} />
@@ -515,7 +509,7 @@ const MixDynamicMoodEditorPage = () => {
515
509
  state.mood.secondaryLamp.expand = selectPageData.value;
516
510
  },
517
511
  };
518
- navigation.navigate(RouterKey.ui_biz_select_page, paramsSelect);
512
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect);
519
513
  }}
520
514
  />
521
515
  <Spacer />
@@ -668,15 +662,20 @@ const MixDynamicMoodEditorPage = () => {
668
662
  textStyle={styles.deleteBtnText}
669
663
  text={Strings.getLang('edit_static_mood_button_delete_text')}
670
664
  onPress={() => {
671
- showDeleteMoodDialog(async (_, { close }) => {
672
- state.loading = true;
673
- close();
674
- const res = await params.modDeleteMood('del', state.mood);
675
- if (res.success) {
676
- navigation.navigate(RouterKey.ui_biz_mood);
665
+ showDialog({
666
+ method: 'confirm',
667
+ title: I18n.getLang('string_light_pp_dialog_sm_ed_headline_d'),
668
+ subTitle: I18n.getLang(`strip_light_static_mood_edit_dialog_text`),
669
+ onConfirm: async (_, {close})=>{
670
+ close();
671
+ state.loading = true;
672
+ const res = await params.modDeleteMood('del', state.mood);
673
+ state.loading = false;
674
+ if (res.success) {
675
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
676
+ }
677
677
  }
678
- state.loading = false;
679
- });
678
+ })
680
679
  }}
681
680
  />
682
681
  </View>
@@ -3,8 +3,8 @@ import {
3
3
  DefMoodOption,
4
4
  LightCategory,
5
5
  MixRemoteMoodInfo,
6
- MoodDps,
7
6
  MoodInfo,
7
+ MoodPageParams,
8
8
  MoodUIInfo,
9
9
  RemoteMoodInfo,
10
10
  } from './Interface';
@@ -55,10 +55,10 @@ const getMoodInfo = (mainDp: string, option: LightCategory, secondaryDp: string)
55
55
  const moodInfo = !!(option.isStringLight || option.isStripLight)
56
56
  ? stripDp2Obj(mainDp, option.isStringLight)
57
57
  : option.isMixLight
58
- ? MixDp2Obj(mainDp)
59
- : option.isCeilingLight
60
- ? MixCeilingDpObj(mainDp, secondaryDp)
61
- : dp2Obj(mainDp, option.isFanLight, option.isUVCFan);
58
+ ? MixDp2Obj(mainDp)
59
+ : option.isCeilingLight
60
+ ? MixCeilingDpObj(mainDp, secondaryDp)
61
+ : dp2Obj(mainDp, option.isFanLight, option.isUVCFan);
62
62
  return moodInfo;
63
63
  };
64
64
 
@@ -66,8 +66,8 @@ const getMoodDp = (moodInfo: MoodUIInfo, option: LightCategory) => {
66
66
  const moodDp = !!(option.isStringLight || option.isStripLight)
67
67
  ? stripObj2Dp(moodInfo, option.isStringLight)
68
68
  : option.isMixLight
69
- ? MixObj2Dp(moodInfo)
70
- : obj2Dp(moodInfo, option.isFanLight, option.isUVCFan);
69
+ ? MixObj2Dp(moodInfo)
70
+ : obj2Dp(moodInfo, option.isFanLight, option.isUVCFan);
71
71
  return moodDp;
72
72
  };
73
73
 
@@ -96,6 +96,7 @@ export const getRemoteMoodList = async (
96
96
  const moodFeatureId = option.isMixLight ? MixLightSceneListFeatureId : SceneFeatureId;
97
97
  // await setRemoteMoodList(devId, isFeature, getDefMoodList(option), moodFeatureId);
98
98
  const res = await getFeature(devId, moodFeatureId);
99
+ console.log(res, '< --- res=====')
99
100
  if (!res.result) {
100
101
  return { success: false };
101
102
  }
@@ -148,46 +149,41 @@ export const getRemoteMoodList = async (
148
149
  }
149
150
  };
150
151
 
151
- export const useMoodScene = (
152
- mainDp: string,
153
- option: LightCategory,
154
- secondaryDp?: string
155
- ): [MoodInfo, (moodInfo: MoodUIInfo, moodDps: MoodDps) => Promise<Result<any>>] => {
152
+ export const useMoodScene = (params: MoodPageParams): [MoodInfo, (moodInfo: MoodUIInfo) => Promise<Result<any>>] => {
156
153
  const [dps, setDps] = useDps();
157
- const main = dps[mainDp];
158
- const secondary = secondaryDp ? dps[secondaryDp] : '';
159
- const [moodState, setMoodState] = useState(getMoodInfo(main, option, secondary));
154
+ const main = dps[params.mainDp];
155
+ const secondary = params.secondaryDp ? dps[params.secondaryDp] : '';
156
+ const [moodState, setMoodState] = useState(getMoodInfo(main, params, secondary));
160
157
 
161
158
  useUpdateEffect(() => {
162
- setMoodState(getMoodInfo(main, option, secondary));
159
+ setMoodState(getMoodInfo(main, params, secondary));
163
160
  }, [main, secondary]);
164
161
 
165
- const setMoodFn = (moodInfo: MoodUIInfo, moodDps: MoodDps) => {
166
- const dps = {};
167
- if (
168
- (option.isCeilingLight && moodInfo.mainLamp && moodInfo.mainLamp.nodes.length) ||
169
- !option.isCeilingLight
170
- ) {
171
- const mainHex = getMoodDp(moodInfo, option);
172
- dps[moodDps.mainDp] = mainHex;
173
- dps[moodDps.mainWorkMode] = WorkMode.Scene;
174
- dps[moodDps.mainSwitch] = true;
175
- }
176
- if (
177
- option.isCeilingLight &&
178
- moodInfo.secondaryLamp &&
179
- moodInfo.secondaryLamp.nodes.length &&
180
- moodDps.secondaryDp
181
- ) {
182
- const secondaryHex = stripObj2Dp({
183
- ...moodInfo,
184
- mainLamp: moodInfo.secondaryLamp,
185
- });
186
- dps[moodDps.secondaryDp] = secondaryHex;
187
- if (moodDps.secondaryWorkMode) dps[moodDps.secondaryWorkMode] = WorkMode.Scene;
188
- if (moodDps.secondarySwitch) dps[moodDps.secondarySwitch] = true;
162
+ const setMoodFn = (moodInfo: MoodUIInfo) => {
163
+ const beforeDps = {}
164
+ const afterDps = {}
165
+ if (moodInfo) {
166
+ const { mainLamp, secondaryLamp } = moodInfo
167
+ if (mainLamp?.nodes?.length) {
168
+ const mainHex = getMoodDp(params.isCeilingLight ? {...moodInfo, id: mainLamp.id!} : moodInfo, params);
169
+ beforeDps[params.mainDp] = mainHex
170
+ afterDps[params.mainWorkMode] = WorkMode.Scene;
171
+ afterDps[params.mainSwitch] = true;
172
+ }
173
+ if (params.isCeilingLight && secondaryLamp.nodes?.length && params.secondaryDp) {
174
+ const secondaryHex = stripObj2Dp({
175
+ ...moodInfo,
176
+ mainLamp: moodInfo.secondaryLamp,
177
+ id: secondaryLamp.id!
178
+ });
179
+ beforeDps[params.secondaryDp] = secondaryHex
180
+ afterDps[params.secondaryWorkMode!] = WorkMode.Scene
181
+ afterDps[params.secondarySwitch!] = true
182
+ }
183
+ afterDps[params.switchLedDp] = true
189
184
  }
190
- return setDps(dps);
185
+ setDps(afterDps).then()
186
+ return setDps(beforeDps)
191
187
  };
192
188
  return [moodState, setMoodFn];
193
189
  };
@@ -208,12 +204,13 @@ export const saveMoodList = (
208
204
  }
209
205
  return {
210
206
  n: s.name,
211
- i: getMoodDp(s, option),
212
- s: option.isCeilingLight
207
+ i: getMoodDp(option.isCeilingLight ? { ...s, id: s.mainLamp.id! } : s, option),
208
+ s: s.secondaryLamp?.nodes?.length && option.isCeilingLight
213
209
  ? stripObj2Dp({
214
- ...s,
215
- mainLamp: s.secondaryLamp,
216
- })
210
+ ...s,
211
+ mainLamp: s.secondaryLamp,
212
+ id: s.secondaryLamp.id!
213
+ })
217
214
  : '',
218
215
  t: 0,
219
216
  e: false,
@@ -229,7 +226,7 @@ export const saveMoodList = (
229
226
  const moodFeatureId = !!(option.isStringLight || option.isStripLight)
230
227
  ? featureId
231
228
  : option.isMixLight
232
- ? MixLightSceneListFeatureId
233
- : SceneFeatureId;
229
+ ? MixLightSceneListFeatureId
230
+ : SceneFeatureId;
234
231
  return setRemoteMoodList(devId, isFeature, remoteMoods, moodFeatureId);
235
232
  };