@ledvance/ui-biz-bundle 1.1.133 → 1.1.135

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 (38) 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 +34 -8
  7. package/src/newModules/biorhythm/BiorhythmPage.tsx +58 -24
  8. package/src/newModules/biorhythm/circular/RhythmsCircle.tsx +488 -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/swithInching/SwithInching.tsx +23 -20
  32. package/src/newModules/swithInching/SwithInchingAction.ts +21 -15
  33. package/src/newModules/biorhythm/circular/ItemIcon.d.ts +0 -22
  34. package/src/newModules/biorhythm/circular/ItemIcon.tsx +0 -173
  35. package/src/newModules/biorhythm/circular/Progress.d.ts +0 -24
  36. package/src/newModules/biorhythm/circular/Progress.tsx +0 -372
  37. package/src/newModules/biorhythm/circular/TimeCircular.d.ts +0 -11
  38. package/src/newModules/biorhythm/circular/TimeCircular.tsx +0 -64
@@ -23,7 +23,7 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
23
23
  const navigation = useNavigation()
24
24
  const [switchInching, setSwitchInching] = useSwitchInching(params.switchIngCode)
25
25
  const [checkConflict, resolveConflict] = useConflictTask(params.conflictDps, true)
26
- const [countdowns, setCountdowns] = useCountdowns(params.countdownCode || params.channelConfig.map(item => item.countdownCode))
26
+ const [countdowns, setCountdowns] = useCountdowns(params.countdownCode || params.channelConfig?.map(item => item.countdownCode) || [])
27
27
  const timeRef = useRef({
28
28
  minute: '00',
29
29
  second: '00',
@@ -41,23 +41,23 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
41
41
  const updateTime = (minute?: string, second?: string) => {
42
42
  if (minute !== undefined) timeRef.current.minute = minute;
43
43
  if (second !== undefined) timeRef.current.second = second;
44
-
44
+
45
45
  if (!Number(timeRef.current.minute) && Number(timeRef.current.second) < 1) {
46
46
  timeRef.current.second = '01';
47
47
  }
48
-
48
+
49
49
  if (Number(timeRef.current.minute) === 60) {
50
50
  timeRef.current.second = '00';
51
51
  }
52
-
52
+
53
53
  const time = Number(timeRef.current.minute) * 60 + Number(timeRef.current.second);
54
54
  const newSwitchInchingItem = {
55
55
  ...state.switchInchingItem,
56
56
  time
57
57
  };
58
-
58
+
59
59
  updateState({ switchInchingItem: newSwitchInchingItem });
60
-
60
+
61
61
  };
62
62
 
63
63
  const switchInchingItem = useMemo(() => {
@@ -73,8 +73,11 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
73
73
  const saveInchingConfig = async (item: SwitchInchingItem) => {
74
74
  const updatedSwitchInching = [...switchInching];
75
75
  const existingItemIndex = updatedSwitchInching.findIndex(item => item.channel === state.channel);
76
- updatedSwitchInching[existingItemIndex] = item;
77
- console.log('updatedSwitchInching', updatedSwitchInching)
76
+ if (existingItemIndex === -1) {
77
+ updatedSwitchInching.push(item);
78
+ } else {
79
+ updatedSwitchInching[existingItemIndex] = item;
80
+ }
78
81
  await setSwitchInching(updatedSwitchInching)
79
82
  }
80
83
 
@@ -143,18 +146,18 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
143
146
  >
144
147
  <ScrollView nestedScrollEnabled={true}>
145
148
  {params.channelConfig && params.channelConfig.length > 1 && <>
146
- <Segmented
147
- style={{ marginHorizontal: cx(24) }}
148
- options={params.channelConfig.map(item => ({
149
- label: item.channelTitle,
150
- value: item.channel
151
- }))}
152
- value={state.channel}
153
- onChange={v => {
154
- updateState({ channel: Number(v) })
155
- }}
156
- />
157
- <Spacer />
149
+ <Segmented
150
+ style={{ marginHorizontal: cx(24) }}
151
+ options={params.channelConfig.map(item => ({
152
+ label: item.channelTitle,
153
+ value: item.channel
154
+ }))}
155
+ value={state.channel}
156
+ onChange={v => {
157
+ updateState({ channel: Number(v) })
158
+ }}
159
+ />
160
+ <Spacer />
158
161
  </>}
159
162
  <View style={styles.switchContainer}>
160
163
  <View style={styles.switchCardContainer}>
@@ -3,14 +3,15 @@ import { Result } from "@ledvance/base/src/models/modules/Result"
3
3
  import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice";
4
4
  import { spliceByStep } from '@ledvance/base/src/utils/common';
5
5
  import { Utils } from '@tuya/tuya-panel-lamp-sdk'
6
+ import {useEffect, useState} from "react";
6
7
 
7
8
  const { to16 } = Utils
8
9
  export interface SwitchInchingPageParams {
9
10
  switchIngCode: string
10
11
  countdownCode?: string
11
12
  channelConfig?: {
12
- countdownCode: string
13
- channelTitle: string
13
+ countdownCode: string
14
+ channelTitle: string
14
15
  channel: number
15
16
  }[]
16
17
  conflictDps: {
@@ -31,20 +32,20 @@ export function useCountdowns(countdownCodes: string | string[]): [Record<string
31
32
  const codes = Array.isArray(countdownCodes) ? countdownCodes : [countdownCodes];
32
33
  const countdownValues: Record<string, number> = {};
33
34
  const dpSetters: Record<string, (value: number) => Promise<Result<any>>> = {};
34
-
35
+
35
36
  for (const code of codes) {
36
37
  const [value, setDp] = useDp<number, any>(code);
37
38
  countdownValues[code] = value;
38
39
  dpSetters[code] = setDp;
39
40
  }
40
-
41
+
41
42
  const setCountdown = async (countdownCode: string, value: number) => {
42
43
  if (dpSetters[countdownCode]) {
43
44
  return await dpSetters[countdownCode](value);
44
45
  }
45
46
  return { success: false, msg: 'Countdown code not found' } as Result<any>;
46
47
  };
47
-
48
+
48
49
  return [countdownValues, setCountdown];
49
50
  }
50
51
 
@@ -56,15 +57,19 @@ export const defSwitchInching = [{ enable: false, channel: 0, time: 1 }]
56
57
 
57
58
  export const useSwitchInching = (switchInchingCode: string) => {
58
59
  const [hex, setHex] = useSwitchInchingHex(switchInchingCode)
59
- const switching = hex ? spliceByStep(Buffer.from(hex, 'base64').toString('hex'), 6).map(item => {
60
- const powerInfo = parseInt(`${item.slice(0, 2)}`, 16).toString(2).padStart(8, '0');
61
- const powerBits = powerInfo.split('');
62
- const enable = !!Number(powerBits[powerBits.length - 1]);
63
- // 通道号
64
- const channel = parseInt(powerBits.slice(1, powerBits.length - 1).join(''), 2);
65
- const time = parseInt(item.slice(2, 6), 16)
66
- return { enable, channel, time }
67
- }) : defSwitchInching
60
+ const [value, setValue] = useState(defSwitchInching)
61
+ useEffect(() => {
62
+ const switching = hex ? spliceByStep(Buffer.from(hex, 'base64').toString('hex'), 6).map(item => {
63
+ const powerInfo = parseInt(`${item.slice(0, 2)}`, 16).toString(2).padStart(8, '0');
64
+ const powerBits = powerInfo.split('');
65
+ const enable = !!Number(powerBits[powerBits.length - 1]);
66
+ // 通道号
67
+ const channel = parseInt(powerBits.slice(1, powerBits.length - 1).join(''), 2);
68
+ const time = parseInt(item.slice(2, 6), 16)
69
+ return { enable, channel, time }
70
+ }) : defSwitchInching
71
+ setValue(switching)
72
+ }, [hex]);
68
73
 
69
74
  const setSwitchInching = (switching: SwitchInchingItem[]) => {
70
75
  const inchingString = switching.map(item => {
@@ -75,8 +80,9 @@ export const useSwitchInching = (switchInchingCode: string) => {
75
80
  return powerChannelStr + timeHex
76
81
  }).join('')
77
82
  const inchingHex = Buffer.from(inchingString, 'hex').toString('base64')
83
+ setValue(switching)
78
84
  return setHex(inchingHex)
79
85
  }
80
- return [switching, setSwitchInching] as const
86
+ return [value, setSwitchInching] as const
81
87
  }
82
88
 
@@ -1,22 +0,0 @@
1
- import { PureComponent } from "react";
2
- import { PanResponderInstance } from "react-native";
3
- export default class ItemIcon extends PureComponent<any> {
4
- lastX: any;
5
- lastY: any;
6
- _panResponder: PanResponderInstance;
7
- state: any;
8
- constructor(props: any);
9
- componentWillMount(): void;
10
- onMoveShouldSetPanResponder(): boolean;
11
- onPanResponderMove(evt: any, gestureState: any): void;
12
- onPanResponderEnd(evt: any, gestureState: any): void;
13
- handlerData(_evt: any, ges: any, moving: any): void;
14
- getPointValues(locationX: any, locationY: any): {
15
- angle: number;
16
- maxX: number;
17
- maxY: number;
18
- length: number;
19
- };
20
- getPointAngle(x: any, y: any): number;
21
- render(): any;
22
- }
@@ -1,173 +0,0 @@
1
- import React, { PureComponent } from "react";
2
- import { Image, PanResponder, PanResponderInstance, StyleSheet, View } from "react-native";
3
-
4
- const timeIconSize = 40; //时间图标ding
5
- const deviationSize = 0;
6
-
7
- export default class ItemIcon extends PureComponent<any> {
8
- lastX: any;
9
- lastY: any;
10
- _panResponder: PanResponderInstance;
11
- state: any;
12
-
13
- constructor(props) {
14
- super(props);
15
-
16
- this.onMoveShouldSetPanResponder = this.onMoveShouldSetPanResponder.bind(this);
17
- this.onPanResponderMove = this.onPanResponderMove.bind(this);
18
- this.onPanResponderEnd = this.onPanResponderEnd.bind(this);
19
- const { leftValeu, topValue, circularRadius } = this.props;
20
-
21
- this.lastX = leftValeu;
22
- this.lastY = topValue;
23
- this.state = { radius: circularRadius };
24
- }
25
-
26
- componentWillMount() {
27
- this._panResponder = PanResponder.create({
28
-
29
- onMoveShouldSetPanResponder: this.onMoveShouldSetPanResponder,
30
- onPanResponderMove: this.onPanResponderMove,
31
- onPanResponderRelease: this.onPanResponderEnd
32
- });
33
- }
34
-
35
- //触摸点开始移动的时候,是否响应触摸交互
36
- onMoveShouldSetPanResponder() {
37
- return true;
38
- }
39
-
40
- // 最近一次的移动距离为gestureState.move{X,Y}
41
- onPanResponderMove(evt, gestureState) {
42
-
43
- this.handlerData(evt, gestureState, true);
44
-
45
- }
46
-
47
- // 停止移动
48
- onPanResponderEnd(evt, gestureState) {
49
- this.handlerData(evt, gestureState, false);
50
- }
51
-
52
- handlerData(_evt, ges, moving) {
53
-
54
- //此时视图的坐标
55
- let locationX = this.lastX + ges.dx + deviationSize;
56
- let locationY = this.lastY + ges.dy + deviationSize;
57
-
58
- // 获取在父元素的实际坐标点值
59
- let result = this.getPointValues(locationX, locationY);
60
- let maxX = result.maxX;
61
- let maxY = result.maxY;
62
-
63
- this.setState({
64
- offset: {
65
- x: maxX,
66
- y: maxY
67
- }
68
- });
69
-
70
- const { onPanMoving, onPanMoveEnd } = this.props;
71
- onPanMoving && onPanMoving(maxX, maxY, result.angle);
72
-
73
- if (!(!!moving)) {
74
- // 记录滑动前 图表的位置
75
- if (this.state.offset) {
76
- this.lastX = this.state.offset.x;
77
- this.lastY = this.state.offset.y;
78
- }
79
-
80
- onPanMoveEnd && onPanMoveEnd();
81
- }
82
- }
83
-
84
- // 获取实际坐标的 角度 坐标值 步长
85
- getPointValues(locationX, locationY) {
86
- //半径
87
- let radius = this.state.radius;
88
- // 求斜边的长度
89
- let offsetX = Math.abs(radius - locationX);
90
- let offsetY = Math.abs(radius - locationY);
91
- // 斜边长度
92
- let length = Math.sqrt(offsetX * offsetX + offsetY * offsetY);
93
-
94
- //求角度
95
- let angle = this.getPointAngle(radius - locationX, radius - locationY);
96
-
97
- // 最终的坐标
98
- let maxX = locationX - deviationSize;
99
- let maxY = locationY - deviationSize;
100
-
101
- //超出边界: 在圆环滑动
102
- if (length !== radius) {
103
- let maxOffsetX = radius * (locationX - radius) / length;
104
- let maxOffsetY = radius * (radius - locationY) / length;
105
- // maxX = radius + maxOffsetX - deviationSize + 1.5
106
- // maxY = radius - maxOffsetY - deviationSize + 1.5
107
- maxX = radius + maxOffsetX - deviationSize;
108
- maxY = radius - maxOffsetY - deviationSize;
109
- length = radius;
110
- }
111
-
112
- return {
113
- angle: angle,
114
- maxX: maxX,
115
- maxY: maxY,
116
- length: length
117
- };
118
- }
119
-
120
- getPointAngle(x, y) {
121
- // 此时的角度是从左边为 0°开始 顺时针 到右边为 180° 逆时针到最右边为 -180°
122
- let angle = Math.atan2(y, x) * (180 / Math.PI);
123
- //改为正常坐标的角度(表盘中心为圆形)
124
- if (angle > 0) {
125
- //第四象限
126
- if (angle < 90) {
127
- angle = 270 + angle;
128
- } else {
129
- //第一象限
130
- angle = angle - 90;
131
- }
132
- } else if (angle == 0) {
133
- angle = 270;
134
- } else if (angle < 0) {
135
- //第三象限
136
- if (angle > -90) {
137
- angle = 270 + angle;
138
-
139
- } else {
140
- //第二象限
141
- angle = 90 + (180 + angle);
142
- }
143
- }
144
-
145
- return angle;
146
- }
147
- render() {
148
- const { leftValeu, topValue, imageSource } = this.props;
149
- return (
150
- <View style={[styles.timeIconView, { left: leftValeu, top: topValue, alignItems: 'center', justifyContent: 'center' }]} {...this._panResponder.panHandlers}>
151
- <Image source={imageSource}
152
- style={{
153
- width: 30,
154
- height: 30,
155
- marginLeft: 0,
156
- tintColor: '#474e5d'
157
- }} />
158
- </View>
159
- );
160
- }
161
- }
162
-
163
- const styles = StyleSheet.create({
164
- timeIconView: {
165
- position: "absolute",
166
- height: timeIconSize,
167
- width: timeIconSize,
168
- flexDirection: "row",
169
- alignItems: "center",
170
- backgroundColor: "#FFFFFF",
171
- borderRadius: Math.round(timeIconSize / 2)
172
- }
173
- });
@@ -1,24 +0,0 @@
1
- import { Component } from 'react';
2
- export default class Progress extends Component<any> {
3
- timeIconList: any[];
4
- timer: any;
5
- state: any;
6
- constructor(props: any);
7
- UNSAFE_componentWillReceiveProps(nextProps: any): void;
8
- componentWillUnmount(): void;
9
- render(): any;
10
- playTimeChangeCallBack(id: number, time: string): void;
11
- getTimeIntVale(time: any): number;
12
- createFormTime(totalMinutes: any): string;
13
- checkTimesFormat(newTimeMinutes: any): {
14
- ret: boolean;
15
- failMinutes: number;
16
- } | {
17
- ret: boolean;
18
- failMinutes?: undefined;
19
- };
20
- getColorTempStringVale(colorTempInt: any): {
21
- rgbColor: number[];
22
- normalColor: string;
23
- };
24
- }