@ledvance/ui-biz-bundle 1.1.133 → 1.1.134

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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/src/modules/mood/DynamicMoodEditorPage.tsx +1 -1
  3. package/src/modules/mood/FantasyMoodEditPage.tsx +1 -1
  4. package/src/modules/mood/MixMood/MixMoodEditPage.tsx +1 -1
  5. package/src/modules/mood/StaticMoodEditorPage.tsx +2 -2
  6. package/src/newModules/biorhythm/BiorhythmActions.ts +22 -8
  7. package/src/newModules/biorhythm/BiorhythmPage.tsx +117 -79
  8. package/src/newModules/biorhythm/circular/RhythmsCircle.tsx +483 -0
  9. package/src/newModules/biorhythm/circular/conical-gradient/Android.tsx +63 -0
  10. package/src/newModules/biorhythm/circular/conical-gradient/Ios.tsx +26 -0
  11. package/src/newModules/biorhythm/circular/conical-gradient/Normal.tsx +187 -0
  12. package/src/newModules/biorhythm/circular/conical-gradient/index.android.tsx +164 -0
  13. package/src/newModules/biorhythm/circular/conical-gradient/index.ios.tsx +124 -0
  14. package/src/newModules/biorhythm/circular/conical-gradient/index.tsx +3 -0
  15. package/src/newModules/biorhythm/circular/conical-gradient/index.web.tsx +94 -0
  16. package/src/newModules/biorhythm/circular/conical-gradient/interface.ts +19 -0
  17. package/src/newModules/biorhythm/circular/conical-gradient/utils.ts +25 -0
  18. package/src/newModules/biorhythm/circular/interface.ts +114 -0
  19. package/src/newModules/energyConsumption/component/EnergyModal.tsx +3 -0
  20. package/src/newModules/lightMode/LightModePage.tsx +52 -145
  21. package/src/newModules/mood/DynamicMoodEditorPage.tsx +1 -1
  22. package/src/newModules/mood/MixDynamicMoodEditor.tsx +1 -1
  23. package/src/newModules/mood/MoodInfo.ts +1 -1
  24. package/src/newModules/mood/MoodPage.tsx +4 -5
  25. package/src/newModules/mood/StaticMoodEditorPage.tsx +1 -1
  26. package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +37 -120
  27. package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +60 -141
  28. package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +13 -5
  29. package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +122 -59
  30. package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +10 -10
  31. package/src/newModules/biorhythm/circular/ItemIcon.d.ts +0 -22
  32. package/src/newModules/biorhythm/circular/ItemIcon.tsx +0 -173
  33. package/src/newModules/biorhythm/circular/Progress.d.ts +0 -24
  34. package/src/newModules/biorhythm/circular/Progress.tsx +0 -372
  35. package/src/newModules/biorhythm/circular/TimeCircular.d.ts +0 -11
  36. package/src/newModules/biorhythm/circular/TimeCircular.tsx +0 -64
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.133",
7
+ "version": "1.1.134",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -191,7 +191,7 @@ const DynamicMoodEditorPage = () => {
191
191
  maxLength={33}
192
192
  showError={state.mood.name.length > 32 || nameRepeat}
193
193
  tipColor={nameRepeat ? '#f00' : undefined}
194
- tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
194
+ tipIcon={nameRepeat ? { uri: res.ic_text_field_input_error } : undefined}
195
195
  errorText={Strings.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')}/>
196
196
  <Card style={styles.adjustCard}>
197
197
  <Spacer height={cx(16)}/>
@@ -227,7 +227,7 @@ const FantasyMoodEditPage = () => {
227
227
  showError={state.mood.name.length > 32 || nameRepeat}
228
228
  maxLength={33}
229
229
  tipColor={nameRepeat ? '#f00' : undefined}
230
- tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
230
+ tipIcon={nameRepeat ? { uri: res.ic_text_field_input_error } : undefined}
231
231
  errorText={I18n.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')} />
232
232
  <Card style={styles.adjustCard}>
233
233
  <Spacer height={cx(16)} />
@@ -191,7 +191,7 @@ const RgbcMoodEditPage = () => {
191
191
  showError={state.mood.name.length > 32 || nameRepeat}
192
192
  maxLength={33}
193
193
  tipColor={nameRepeat ? '#f00' : undefined}
194
- tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
194
+ tipIcon={nameRepeat ? { uri: res.ic_text_field_input_error } : undefined}
195
195
  errorText={I18n.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')} />
196
196
  {params.isStatic ? <Card style={styles.adjustCard}>
197
197
  <LdvSwitch
@@ -191,7 +191,7 @@ const StaticMoodEditorPage = () => {
191
191
  maxLength={33}
192
192
  showError={state.mood.name.length > 32 || nameRepeat}
193
193
  tipColor={nameRepeat ? '#f00' : undefined}
194
- tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
194
+ tipIcon={nameRepeat ? { uri: res.ic_text_field_input_error } : undefined}
195
195
  errorText={Strings.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')}/>
196
196
  <Card style={styles.adjustCard}>
197
197
  <Spacer height={cx(16)}/>
@@ -318,4 +318,4 @@ const styles = StyleSheet.create({
318
318
  },
319
319
  })
320
320
 
321
- export default StaticMoodEditorPage
321
+ export default StaticMoodEditorPage
@@ -10,7 +10,7 @@ import {
10
10
  Plan,
11
11
  RemoteBiorhythmBean,
12
12
  } from './BiorhythmBean'
13
- import { useCallback, useEffect, useState } from 'react'
13
+ import { useCallback, useEffect, useState, useRef } from 'react'
14
14
  import { NativeResult, Result } from '@ledvance/base/src/models/modules/Result'
15
15
  import { useDeviceId, useDp } from '@ledvance/base/src/models/modules/NativePropsSlice'
16
16
  import { getFeature, NativeApi, putFeature } from '@ledvance/base/src/api/native'
@@ -29,6 +29,8 @@ export const useBiorhythm: UseBiorhythmType = (dpKey: string, disabledFeature?:
29
29
  const [dp, setDp] = useDp<string, (v: string) => any>(dpKey)
30
30
  const deviceId = useDeviceId()
31
31
  const [biorhythmState, setBiorhythmState] = useState(dp2Obj(dp))
32
+ const isInternalUpdateRef = useRef(false)
33
+ const previousDpRef = useRef(dp)
32
34
 
33
35
  const getBiorhythm = useCallback(() => {
34
36
  const biorhythm = dp2Obj(dp)
@@ -46,27 +48,39 @@ export const useBiorhythm: UseBiorhythmType = (dpKey: string, disabledFeature?:
46
48
 
47
49
  useEffect(() => {
48
50
  if (disabledFeature) return
49
- biorhythmTimer = setTimeout(() => {
50
- getBiorhythm()
51
- }, 300)
52
-
53
- return () => {
54
- clearTimeout(biorhythmTimer)
55
- }
51
+ getBiorhythm()
56
52
  }, [])
57
53
 
58
54
  useUpdateEffect(() => {
55
+ if (isInternalUpdateRef.current || disabledFeature) {
56
+ if (isInternalUpdateRef.current) {
57
+ previousDpRef.current = dp
58
+ }
59
+ console.log('跳过更新', isInternalUpdateRef.current, disabledFeature)
60
+ isInternalUpdateRef.current = false
61
+ return
62
+ }
63
+ console.log('dp updateEffect', dp, previousDpRef.current, dp === previousDpRef.current)
64
+ if (dp?.toLocaleLowerCase() === previousDpRef.current?.toLocaleLowerCase()) {
65
+ return
66
+ }
59
67
  getBiorhythm()
60
68
  }, [dp])
61
69
 
62
70
  const setBiorhythmFn = async (biorhythmObj: BiorhythmBean, pushFeature: boolean = true) => {
63
71
  const dpValue = obj2Dp(biorhythmObj)
72
+ isInternalUpdateRef.current = true
73
+
64
74
  if (pushFeature) {
65
75
  const putFeatureRes = await putFeature(deviceId, biorhythmFeatureId, vo2Dto(biorhythmObj))
66
76
  if (putFeatureRes.result) {
77
+ setBiorhythmState(biorhythmObj)
67
78
  return setDp(dpValue)
79
+ } else {
80
+ isInternalUpdateRef.current = false
68
81
  }
69
82
  } else {
83
+ setBiorhythmState(biorhythmObj)
70
84
  return setDp(dpValue)
71
85
  }
72
86
  return { success: false }
@@ -25,7 +25,6 @@ import { setDataSource } from '@ledvance/base/src/components/weekSelect'
25
25
  import { BiorhythmEditPageParams } from './BiorhythmEditPage'
26
26
  import { useBiorhythm } from './BiorhythmActions'
27
27
  import { convertMinutesTo12HourFormat, showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
28
- import TimeCircular from './circular/TimeCircular'
29
28
  import Page from '@ledvance/base/src/components/Page'
30
29
  import Card from '@ledvance/base/src/components/Card'
31
30
  import Spacer from '@ledvance/base/src/components/Spacer'
@@ -33,6 +32,7 @@ import DeleteButton from '@ledvance/base/src/components/DeleteButton'
33
32
  import { useParams } from '@ledvance/base/src/hooks/Hooks'
34
33
  import ThemeType from '@ledvance/base/src/config/themeType'
35
34
  import { useConflictTask } from 'hooks/DeviceDpStateHooks'
35
+ import RhythmsCircle from './circular/RhythmsCircle'
36
36
 
37
37
  const cx = Utils.RatioUtils.convertX
38
38
  const { withTheme } = Utils.ThemeUtils
@@ -78,6 +78,14 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
78
78
  loading: false
79
79
  })
80
80
 
81
+ const timeImg = useMemo(() => {
82
+ if (is24Hour) {
83
+ return devicesJudge ? res.ic_warning_amber_sun : res.ic_warning_amber_new
84
+ } else {
85
+ return devicesJudge ? res.ic_warning_amber_sun_12 : res.ic_warning_amber_new_12
86
+ }
87
+ }, [is24Hour, devicesJudge])
88
+
81
89
  const showGradientTypeSelectModal = useCallback((show: boolean) => {
82
90
  state.showGradientTypeSelectModal = show
83
91
  }, [])
@@ -181,7 +189,7 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
181
189
  }
182
190
  }
183
191
 
184
- useEffect(() =>{
192
+ useEffect(() => {
185
193
  const weeks: string[] = setDataSource(
186
194
  biorhythm.repeatPeriod.map(item => {
187
195
  return item?.enabled ? 1 : 0
@@ -229,20 +237,20 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
229
237
  const sunHomeText = string => {
230
238
  const text = string.split('SUN@HOME')
231
239
  return text?.length === 1 && <Text style={{ fontSize: cx(14), color: props.theme?.global.fontColor }}>{text[0]}</Text> ||
232
- <Text style={{
233
- fontSize: cx(14),
234
- flexDirection: 'row',
235
- }}>
236
- <Text style={{color: props.theme?.global.fontColor }}>{text[0]}</Text>
237
- <Text onPress={openLink}
238
- style={{
239
- fontFamily: 'helvetica_neue_lt_std_roman',
240
- color: props.theme?.button.primary,
241
- textDecorationLine: 'underline',
242
- flexWrap: 'wrap',
243
- }}>SUN@HOME</Text>
244
- <Text style={{color: props.theme?.global.fontColor }}>{text[1]}</Text>
245
- </Text>
240
+ <Text style={{
241
+ fontSize: cx(14),
242
+ flexDirection: 'row',
243
+ }}>
244
+ <Text style={{ color: props.theme?.global.fontColor }}>{text[0]}</Text>
245
+ <Text onPress={openLink}
246
+ style={{
247
+ fontFamily: 'helvetica_neue_lt_std_roman',
248
+ color: props.theme?.button.primary,
249
+ textDecorationLine: 'underline',
250
+ flexWrap: 'wrap',
251
+ }}>SUN@HOME</Text>
252
+ <Text style={{ color: props.theme?.global.fontColor }}>{text[1]}</Text>
253
+ </Text>
246
254
  }
247
255
 
248
256
  const randomIcon = () => {
@@ -257,6 +265,17 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
257
265
  return availableChart[randomIndex]
258
266
  }
259
267
 
268
+ const convertPlandata = useCallback(() => {
269
+ return state.planList.map(item => {
270
+ return {
271
+ ...item,
272
+ noActiveColor: '#474e5d',
273
+ activeColor: '#F7EB2A',
274
+ color: item?.brightness === 0 ? '#000' : !params.isSupportTemperature && cctToColor(1) || cctToColor(item.colorTemperature.toFixed(), item?.brightness)
275
+ }
276
+ }).filter(plan => plan.enable)
277
+ }, [JSON.stringify(state.planList), params.isSupportTemperature])
278
+
260
279
  return (
261
280
  <>
262
281
  <Page
@@ -348,10 +367,10 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
348
367
  })}
349
368
  </View>
350
369
  <View style={{ marginHorizontal: cx(24), marginTop: cx(20) }}>
351
- <Text style={{color: props.theme?.global.fontColor}}>{state.weekString}</Text>
370
+ <Text style={{ color: props.theme?.global.fontColor }}>{state.weekString}</Text>
352
371
  </View>
353
372
  <View style={{ marginHorizontal: cx(24), marginTop: cx(16) }}>
354
- <Text style={{color: props.theme?.global.fontColor}}>
373
+ <Text style={{ color: props.theme?.global.fontColor }}>
355
374
  {I18n.getLang('bio_ryhthm_default_selectionfield_topic_text')}
356
375
  </Text>
357
376
  <TouchableOpacity
@@ -390,7 +409,7 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
390
409
  </TouchableOpacity>
391
410
  </View>
392
411
  <View style={{ height: cx(20) }} />
393
- <TimeCircular
412
+ {/* <TimeCircular
394
413
  planEdit={true}
395
414
  planList={state.planList}
396
415
  onPanMoved={(id, time) => {
@@ -404,7 +423,26 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
404
423
  }}
405
424
  replaceStatus={devicesJudge}
406
425
  gradient={state.gradient === BiorhythmGradientType.DirectGradient}
407
- isSupportTemperature={!params.isSupportTemperature} />
426
+ isSupportTemperature={!params.isSupportTemperature} /> */}
427
+ <View style={{ alignItems: 'center', justifyContent: 'center' }}>
428
+ <RhythmsCircle
429
+ size={250}
430
+ ringWidth={40}
431
+ thumbSize={36}
432
+ timeImg={timeImg}
433
+ gradientMode={state.gradient === BiorhythmGradientType.EntireGradient}
434
+ data={convertPlandata()}
435
+ onRelease={(planList) => {
436
+ state.planList = state.planList.map(item => {
437
+ return {
438
+ ...item,
439
+ time: planList.find(p => p.index === item.index)?.time
440
+ }
441
+ })
442
+ state.flag = Symbol()
443
+ }}
444
+ />
445
+ </View>
408
446
  <View
409
447
  style={{
410
448
  flexDirection: 'row',
@@ -414,66 +452,66 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
414
452
  marginTop: cx(26),
415
453
  }}>
416
454
  {state.planList.length === 8 && <View
417
- style={{ marginVertical: cx(10), flexDirection: 'row', alignItems: 'center', width: width - cx(48) }}>
418
- <Image style={{ width: cx(16), height: cx(16), tintColor: props.theme?.global.warning }} source={{uri: res.ic_warning_amber}} />
419
- <Text
420
- style={{
421
- flexWrap: 'wrap',
422
- fontSize: cx(12),
423
- color: props.theme?.global.fontColor
424
- }}>{I18n.getLang('add_new_trigger_time_warning_max_number_text')}</Text>
455
+ style={{ marginVertical: cx(10), flexDirection: 'row', alignItems: 'center', width: width - cx(48) }}>
456
+ <Image style={{ width: cx(16), height: cx(16), tintColor: props.theme?.global.warning }} source={{ uri: res.ic_warning_amber }} />
457
+ <Text
458
+ style={{
459
+ flexWrap: 'wrap',
460
+ fontSize: cx(12),
461
+ color: props.theme?.global.fontColor
462
+ }}>{I18n.getLang('add_new_trigger_time_warning_max_number_text')}</Text>
425
463
  </View>}
426
464
  {state.planList.length < 8 &&
427
- <>
428
- <Text
429
- style={{
430
- fontSize: cx(16),
431
- fontWeight: 'bold',
432
- color: props.theme?.global.fontColor,
433
- }}>{I18n.getLang('bio_ryhthm_default_subheadline_text')}</Text>
434
- <TouchableOpacity
435
- onPress={() => {
436
- const ids: number[] = state.planList.map(p => p.index)
437
- const newPlan: Plan = {
438
- index: Math.max(...ids) + 1,
439
- icon: res.rhythm_icon1,
440
- time: 0,
441
- name: '',
442
- colorTemperature: 0,
443
- brightness: 100,
444
- action: [
445
- {
446
- uri: 'model/attribute/set/LightCtrl/ColorTemperature',
447
- startValue: `${colorTemperatureValue(0)}`,
448
- },
449
- {
450
- uri: 'model/attribute/set/LightCtrl/Brightness',
451
- startValue: '100',
452
- },
453
- ],
454
- enable: true,
455
- iconId: randomIcon(),
456
- }
457
- const editPageParams: BiorhythmEditPageParams = {
458
- planData: newPlan,
459
- isAdd: true,
460
- onPlanEdited,
461
- onPlanDelete,
462
- minimumEnable,
463
- nameRepeat,
464
- iconIdList: state.planList?.map(item => {
465
- return item.iconId
466
- }),
467
- isMixRGBWLamp: !!params.isMixLight,
468
- isSupportTemperature: params.isSupportTemperature,
469
- isSupportBrightness: params.isSupportBrightness,
470
- showDeleteBtn
471
- }
472
- navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
473
- }}>
474
- <Image source={{uri: res.biorhythom_add}} style={{ height: cx(24), width: cx(24), tintColor: props.theme?.icon.primary }} />
475
- </TouchableOpacity>
476
- </>
465
+ <>
466
+ <Text
467
+ style={{
468
+ fontSize: cx(16),
469
+ fontWeight: 'bold',
470
+ color: props.theme?.global.fontColor,
471
+ }}>{I18n.getLang('bio_ryhthm_default_subheadline_text')}</Text>
472
+ <TouchableOpacity
473
+ onPress={() => {
474
+ const ids: number[] = state.planList.map(p => p.index)
475
+ const newPlan: Plan = {
476
+ index: Math.max(...ids) + 1,
477
+ icon: res.rhythm_icon1,
478
+ time: 0,
479
+ name: '',
480
+ colorTemperature: 0,
481
+ brightness: 100,
482
+ action: [
483
+ {
484
+ uri: 'model/attribute/set/LightCtrl/ColorTemperature',
485
+ startValue: `${colorTemperatureValue(0)}`,
486
+ },
487
+ {
488
+ uri: 'model/attribute/set/LightCtrl/Brightness',
489
+ startValue: '100',
490
+ },
491
+ ],
492
+ enable: true,
493
+ iconId: randomIcon(),
494
+ }
495
+ const editPageParams: BiorhythmEditPageParams = {
496
+ planData: newPlan,
497
+ isAdd: true,
498
+ onPlanEdited,
499
+ onPlanDelete,
500
+ minimumEnable,
501
+ nameRepeat,
502
+ iconIdList: state.planList?.map(item => {
503
+ return item.iconId
504
+ }),
505
+ isMixRGBWLamp: !!params.isMixLight,
506
+ isSupportTemperature: params.isSupportTemperature,
507
+ isSupportBrightness: params.isSupportBrightness,
508
+ showDeleteBtn
509
+ }
510
+ navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
511
+ }}>
512
+ <Image source={{ uri: res.biorhythom_add }} style={{ height: cx(24), width: cx(24), tintColor: props.theme?.icon.primary }} />
513
+ </TouchableOpacity>
514
+ </>
477
515
  }
478
516
  </View>
479
517
  <FlatList
@@ -522,7 +560,7 @@ const BiorhythmPage = (props: { theme?: ThemeType }) => {
522
560
  <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', marginTop: cx(16) }}>
523
561
  <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
524
562
  <Image
525
- source={{uri: setImg(item?.iconId)} || type && { uri: item?.icon } || item?.icon}
563
+ source={{ uri: setImg(item?.iconId) }}
526
564
  style={{
527
565
  width: cx(24),
528
566
  height: cx(24),