@ledvance/ui-biz-bundle 1.1.105 → 1.1.107

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/DeviceDpStateHooks.ts +156 -0
  3. package/src/modules/flags/FlagActions.ts +4 -1
  4. package/src/modules/flags/FlagPage.tsx +12 -42
  5. package/src/modules/music/MusicPage.tsx +13 -7
  6. package/src/modules/timer/TimerPage.tsx +4 -1
  7. package/src/modules/timer/TimerPageAction.ts +0 -1
  8. package/src/navigation/Routers.ts +3 -1
  9. package/src/newModules/biorhythm/BiorhythmBean.ts +1 -1
  10. package/src/newModules/biorhythm/BiorhythmPage.tsx +27 -4
  11. package/src/newModules/diyScene/DefaultScenes.ts +438 -0
  12. package/src/newModules/diyScene/DiySceneActions.ts +232 -0
  13. package/src/newModules/diyScene/DiySceneEditorPage.tsx +359 -0
  14. package/src/newModules/diyScene/DiyScenePage.tsx +297 -0
  15. package/src/newModules/diyScene/Router.ts +25 -0
  16. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +15 -2
  17. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +31 -10
  18. package/src/newModules/energyConsumption/component/DateSwitch.tsx +111 -0
  19. package/src/newModules/energyConsumption/component/DateTypeItem.tsx +1 -0
  20. package/src/newModules/energyConsumption/component/NewBarChart.tsx +16 -3
  21. package/src/newModules/fixedTime/FixedTimeActions.ts +3 -3
  22. package/src/newModules/fixedTime/FixedTimePage.tsx +58 -6
  23. package/src/newModules/mood/MoodActions.ts +4 -1
  24. package/src/newModules/mood/MoodItem.tsx +2 -1
  25. package/src/newModules/mood/MoodPage.tsx +4 -3
  26. package/src/newModules/randomTime/RandomTimeActions.ts +3 -3
  27. package/src/newModules/randomTime/RandomTimePage.tsx +60 -7
  28. package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +21 -11
  29. package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +108 -13
  30. package/src/newModules/switchGradient/SwitchGradientPage.tsx +7 -4
  31. package/src/newModules/swithInching/SwithInching.tsx +1 -0
  32. package/src/newModules/timeSchedule/Interface.ts +19 -7
  33. package/src/newModules/timeSchedule/TimeScheduleActions.ts +6 -0
  34. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +134 -57
  35. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +23 -6
  36. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +42 -9
  37. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +5 -1
@@ -22,6 +22,7 @@ import { ui_biz_routerKey } from '../../navigation/Routers';
22
22
  import Tag from '@ledvance/base/src/components/Tag';
23
23
  import { cloneDeep } from 'lodash';
24
24
  import ThemeType from '@ledvance/base/src/config/themeType'
25
+ import { showDialog } from '@ledvance/base/src/utils/common';
25
26
 
26
27
  const { convertX: cx } = Utils.RatioUtils;
27
28
  const { withTheme } = Utils.ThemeUtils
@@ -40,6 +41,7 @@ export interface TimeSchedulePageParams {
40
41
  isFanLight?: boolean;
41
42
  isUVCFan?: boolean;
42
43
  isPowerStrip?: boolean
44
+ isMoodStrip?: boolean
43
45
  featureId?: string
44
46
  applyForList: ApplyForItem[];
45
47
  applyForDisabled?: boolean; // 是否可以选择apply for
@@ -75,6 +77,8 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
75
77
  useEffect(() => {
76
78
  getTimeSchedule(devId).then(res => {
77
79
  state.originList = cloneDeep(res)
80
+ const status = res?.some(item => item.enable);
81
+ setTimeScheduleStatus(status);
78
82
  });
79
83
  }, [state.flag]);
80
84
 
@@ -214,6 +218,19 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
214
218
  onPress={() => {
215
219
  navigateToEdit('update', item);
216
220
  }}
221
+ onLongPress={() =>{
222
+ showDialog({
223
+ method: 'confirm',
224
+ title: I18n.getLang('cancel_dialog_delete_item_timeschedule_titel'),
225
+ subTitle: I18n.getLang('cancel_dialog_delete_item_timeschedule_description'),
226
+ onConfirm: async (_, { close }) => {
227
+ state.loading = true;
228
+ close();
229
+ await modDeleteTimeSchedule('delete', item);
230
+ state.loading = false;
231
+ },
232
+ });
233
+ }}
217
234
  />
218
235
  )}
219
236
  keyExtractor={item => item.id.toString()}
@@ -238,12 +255,12 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
238
255
  />
239
256
  <Spacer height={cx(16)} />
240
257
  {!state.originList.length && <DeleteButton
241
- style={styles.addBtn}
242
- text={`${I18n.getLang('timeschedule_overview_empty_button_add_text')}`}
243
- textStyle={{ fontSize: cx(12) }}
244
- onPress={() => {
245
- navigateToEdit('add');
246
- }}
258
+ style={styles.addBtn}
259
+ text={`${I18n.getLang('timeschedule_overview_empty_button_add_text')}`}
260
+ textStyle={{ fontSize: cx(12) }}
261
+ onPress={() => {
262
+ navigateToEdit('add');
263
+ }}
247
264
  />}
248
265
  </View>}
249
266
  </ScrollView>
@@ -1,19 +1,23 @@
1
- import React, { memo, useMemo } from 'react';
2
- import { DeviceType, directOptions, FanLightData, ManualSettingProps, modeOptions, StripLightData } from '../Interface';
3
- import { View } from 'react-native';
1
+ import React, {memo, useMemo} from 'react';
2
+ import {DeviceType, directOptions, FanLightData, ManualSettingProps, modeOptions, StripLightData} from '../Interface';
3
+ import {View} from 'react-native';
4
4
  import Card from '@ledvance/base/src/components/Card';
5
5
  import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
6
- import { Utils } from 'tuya-panel-kit';
7
- import { useCreation, useReactive, useUpdateEffect } from 'ahooks';
6
+ import {Utils} from 'tuya-panel-kit';
7
+ import {useCreation, useReactive, useUpdateEffect} from 'ahooks';
8
8
  import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
9
9
  import ColorTempAdjustView from '@ledvance/base/src/components/ColorTempAdjustView';
10
10
  import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
11
11
  import I18n from '@ledvance/base/src/i18n';
12
12
  import StripAdjustView from '@ledvance/base/src/components/StripAdjustView';
13
13
  import Spacer from '@ledvance/base/src/components/Spacer';
14
- import { FanAdjustViewContent } from '@ledvance/base/src/components/FanAdjustView';
14
+ import {FanAdjustViewContent} from '@ledvance/base/src/components/FanAdjustView';
15
15
  import SocketItem from '@ledvance/base/src/components/SocketItem'
16
16
  import res from '@ledvance/base/src/res';
17
+ import { cctToColor } from '@ledvance/base/src/utils/cctUtils';
18
+ import {hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
19
+ import {AdjustType} from "@ledvance/base/src/utils/interface";
20
+
17
21
  const { convertX: cx } = Utils.RatioUtils;
18
22
  const { withTheme } = Utils.ThemeUtils
19
23
 
@@ -66,6 +70,14 @@ function ManualSettings(props: ManualSettingProps) {
66
70
 
67
71
  const lightSourceCard = useMemo(() => {
68
72
  const { deviceData } = state;
73
+ const getBlockColor = () => {
74
+ if (!deviceData.isColorMode) return cctToColor(deviceData.temperature)
75
+ if (deviceData.isColorMode) {
76
+ const s = Math.round(mapFloatToRange(deviceData.s / 100, 30, 100))
77
+ return hsv2Hex(deviceData.h, s, 100)
78
+ }
79
+ return props.theme?.card?.background
80
+ };
69
81
  return (
70
82
  <View>
71
83
  {state.applyForList.map((item, idx) => (
@@ -73,7 +85,7 @@ function ManualSettings(props: ManualSettingProps) {
73
85
  <Card style={{ marginHorizontal: cx(24) }}>
74
86
  <LdvSwitch
75
87
  title={item.name || item.key}
76
- color={props.theme?.card.background}
88
+ color={getBlockColor()}
77
89
  colorAlpha={1}
78
90
  enable={item.enable}
79
91
  setEnable={(enable: boolean) => {
@@ -99,6 +111,7 @@ function ManualSettings(props: ManualSettingProps) {
99
111
  state.deviceData = {
100
112
  ...state.deviceData,
101
113
  isColorMode: mode,
114
+ adjustType: mode ? AdjustType.COLOUR : AdjustType.WHITE
102
115
  };
103
116
  state.manualFlag = Symbol()
104
117
  }}
@@ -190,6 +203,15 @@ function ManualSettings(props: ManualSettingProps) {
190
203
  }, [state.deviceData, state.applyForList, props.theme?.type]);
191
204
 
192
205
  const mixLightCard = useMemo(() => {
206
+ const {deviceData} = state;
207
+ const getBlockColor = ((type: string) => {
208
+ if (type === 'mainLight') return cctToColor(deviceData.temperature);
209
+ if (type === 'secondaryLight') {
210
+ const s = Math.round(mapFloatToRange(deviceData.s / 100, 30, 100));
211
+ return hsv2Hex(deviceData.h, s, 100);
212
+ }
213
+ return props.theme?.card?.background;
214
+ });
193
215
  return (
194
216
  <View>
195
217
  {state.applyForList.map((item, idx) => (
@@ -197,7 +219,7 @@ function ManualSettings(props: ManualSettingProps) {
197
219
  <Card style={{ marginHorizontal: cx(24) }}>
198
220
  <LdvSwitch
199
221
  title={item.key}
200
- color={props.theme?.card.background}
222
+ color={getBlockColor(item.type)}
201
223
  colorAlpha={1}
202
224
  enable={item.enable}
203
225
  setEnable={(enable: boolean) => {
@@ -318,6 +340,17 @@ function ManualSettings(props: ManualSettingProps) {
318
340
 
319
341
  const ceilingLightCard = useMemo(() => {
320
342
  const deviceData = state.deviceData as StripLightData
343
+ const getBlockColor = (type: string) => {
344
+ if (type === 'mainLight') {
345
+ return cctToColor(deviceData.temperature);
346
+ }
347
+ // deviceData.activeKey === 3为combination
348
+ if (type === 'secondaryLight' && deviceData.activeKey !== 3) {
349
+ const s = Math.round(mapFloatToRange(deviceData.s / 100, 30, 100));
350
+ return hsv2Hex(deviceData.h, s, 100);
351
+ }
352
+ return props.theme?.card.background;
353
+ }
321
354
  return (
322
355
  <View>
323
356
  {state.applyForList.map((item, idx) => (
@@ -325,7 +358,7 @@ function ManualSettings(props: ManualSettingProps) {
325
358
  <Card style={{ marginHorizontal: cx(24) }}>
326
359
  <LdvSwitch
327
360
  title={item.key}
328
- color={props.theme?.card.background}
361
+ color={getBlockColor(item.type)}
329
362
  colorAlpha={1}
330
363
  enable={item.enable}
331
364
  setEnable={(enable: boolean) => {
@@ -18,10 +18,11 @@ interface ScheduleCardProps {
18
18
  tags: ApplyForItem[]
19
19
  onEnableChange: (enable: boolean) => void
20
20
  onPress: (item: any) => void
21
+ onLongPress?: (item: any) => void
21
22
  }
22
23
 
23
24
  const ScheduleCard = (props: ScheduleCardProps) => {
24
- const { item, style, showTag, tags, onEnableChange, onPress } = props;
25
+ const { item, style, showTag, tags, onEnableChange, onPress, onLongPress } = props;
25
26
  const is24HourClock = useSystemTimeFormate()
26
27
  const showTags = useMemo(() => {
27
28
  return tags.filter(tag => item.dps.hasOwnProperty(tag.dp))
@@ -93,6 +94,9 @@ const ScheduleCard = (props: ScheduleCardProps) => {
93
94
  onPress={() => {
94
95
  onPress(item);
95
96
  }}
97
+ onLongPress={() =>{
98
+ onLongPress && onLongPress(item)
99
+ }}
96
100
  >
97
101
  <View style={styles.infoContainer}>
98
102
  <Text style={styles.time}>{is24HourClock ? item.time : convertTo12HourFormat(item.time)}</Text>