@ledvance/group-ui-biz-bundle 1.0.121 → 1.0.123

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 (33) hide show
  1. package/package.json +1 -1
  2. package/src/modules/biorhythm/BiorhythmActions.ts +7 -2
  3. package/src/modules/biorhythm/BiorhythmPage.tsx +51 -16
  4. package/src/modules/biorhythm/circular/RhythmsCircle.tsx +488 -0
  5. package/src/modules/biorhythm/circular/conical-gradient/Android.tsx +63 -0
  6. package/src/modules/biorhythm/circular/conical-gradient/Ios.tsx +26 -0
  7. package/src/modules/biorhythm/circular/conical-gradient/Normal.tsx +187 -0
  8. package/src/modules/biorhythm/circular/conical-gradient/index.android.tsx +164 -0
  9. package/src/modules/biorhythm/circular/conical-gradient/index.ios.tsx +124 -0
  10. package/src/modules/biorhythm/circular/conical-gradient/index.tsx +3 -0
  11. package/src/modules/biorhythm/circular/conical-gradient/index.web.tsx +94 -0
  12. package/src/modules/biorhythm/circular/conical-gradient/interface.ts +19 -0
  13. package/src/modules/biorhythm/circular/conical-gradient/utils.ts +25 -0
  14. package/src/modules/biorhythm/circular/interface.ts +114 -0
  15. package/src/modules/energyConsumption/component/EnergyModal.tsx +3 -0
  16. package/src/modules/lightMode/LightModePage.tsx +50 -144
  17. package/src/modules/mood/DynamicMoodEditorPage.tsx +1 -1
  18. package/src/modules/mood/StaticMoodEditorPage.tsx +1 -1
  19. package/src/modules/mood_new/DynamicMoodEditorPage.tsx +1 -1
  20. package/src/modules/mood_new/MixDynamicMoodEditor.tsx +1 -1
  21. package/src/modules/mood_new/MoodInfo.ts +1 -1
  22. package/src/modules/mood_new/StaticMoodEditorPage.tsx +1 -1
  23. package/src/modules/powerOnBehavior/LightBehaviorPage.tsx +208 -0
  24. package/src/modules/powerOnBehavior/PlugBehaviorPage.tsx +99 -0
  25. package/src/modules/powerOnBehavior/PowerOnBehaviorActions.ts +131 -0
  26. package/src/modules/powerOnBehavior/Router.ts +27 -0
  27. package/src/navigation/Routers.ts +3 -1
  28. package/src/modules/biorhythm/circular/ItemIcon.d.ts +0 -22
  29. package/src/modules/biorhythm/circular/ItemIcon.tsx +0 -173
  30. package/src/modules/biorhythm/circular/Progress.d.ts +0 -24
  31. package/src/modules/biorhythm/circular/Progress.tsx +0 -372
  32. package/src/modules/biorhythm/circular/TimeCircular.d.ts +0 -11
  33. package/src/modules/biorhythm/circular/TimeCircular.tsx +0 -64
@@ -0,0 +1,99 @@
1
+ import React from 'react'
2
+ import {ScrollView, StyleSheet} from 'react-native'
3
+ import Page from '@ledvance/base/src/components/Page'
4
+ import {useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
5
+ import I18n from '@ledvance/base/src/i18n'
6
+ import {PowerBehaviorPageParams, usePowerBehavior} from './PowerOnBehaviorActions'
7
+ import {Utils} from 'tuya-panel-kit'
8
+ import Spacer from '@ledvance/base/src/components/Spacer'
9
+ import {useReactive, useUpdateEffect} from 'ahooks'
10
+ import {useParams} from '@ledvance/base/src/hooks/Hooks'
11
+ import Segmented from "@ledvance/base/src/components/Segmented";
12
+ import OptionGroup from "@ledvance/base/src/components/OptionGroup";
13
+ import {cloneDeep} from "lodash";
14
+
15
+ const { convertX: cx } = Utils.RatioUtils
16
+ const { withTheme } = Utils.ThemeUtils
17
+
18
+ const RELAY_STATUS_OFF = 'off'
19
+ const RELAY_STATUS_ON = 'on'
20
+ const RELAY_STATUS_MEMORY = 'memory'
21
+
22
+ const PlugBehaviorPage = () => {
23
+ const params = useParams<PowerBehaviorPageParams>()
24
+ const deviceInfo = useDeviceInfo()
25
+ const [powerMemories, setPowerMemories] = usePowerBehavior(params.powerBehaviorKeys)
26
+
27
+ const state = useReactive({
28
+ channel: 0,
29
+ powerMemories: powerMemories,
30
+ loading: false,
31
+ })
32
+
33
+ useUpdateEffect(() => {
34
+ state.powerMemories = cloneDeep(powerMemories)
35
+ }, [JSON.stringify(powerMemories)])
36
+
37
+ const styles = StyleSheet.create({
38
+ root: {
39
+ flex: 1,
40
+ },
41
+ })
42
+
43
+ return (
44
+ <Page
45
+ backText={deviceInfo.name}
46
+ headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
47
+ loading={state.loading}>
48
+ <ScrollView style={styles.root} nestedScrollEnabled={true}>
49
+ {params.powerBehaviorKeys.length > 1 && <>
50
+ <Spacer height={cx(16)} />
51
+ <Segmented
52
+ style={{ marginHorizontal: cx(24) }}
53
+ options={params.powerBehaviorKeys.map((_, index) => ({
54
+ // @ts-ignore
55
+ label: I18n.getLang(`switchmodule_switch${index + 1}title`),
56
+ value: index
57
+ }))}
58
+ value={state.channel}
59
+ onChange={v => {
60
+ state.channel = Number(v)
61
+ }}
62
+ />
63
+ </>}
64
+ <Spacer />
65
+ <OptionGroup
66
+ tips={I18n.getLang('socket_settings_firstbox_topic')}
67
+ selected={state.powerMemories[state.channel]}
68
+ options={[{
69
+ title: I18n.getLang('feature_summary_action_txt_2'),
70
+ content: I18n.getLang('socket_settings_firstbox_status1_description'),
71
+ value: RELAY_STATUS_OFF,
72
+ onPress: (value) => {
73
+ state.powerMemories[state.channel] = value
74
+ setPowerMemories[state.channel](value).then()
75
+ }
76
+ }, {
77
+ title: I18n.getLang('feature_summary_action_txt_1'),
78
+ content: I18n.getLang('socket_settings_firstbox_status2_description'),
79
+ value: RELAY_STATUS_ON,
80
+ onPress: (value) => {
81
+ state.powerMemories[state.channel] = value
82
+ setPowerMemories[state.channel](value).then()
83
+ }
84
+ }, {
85
+ title: I18n.getLang('sockets_specific_settings_relay_status_remember'),
86
+ content: I18n.getLang('socket_settings_firstbox_status3_description'),
87
+ value: RELAY_STATUS_MEMORY,
88
+ onPress: (value) => {
89
+ state.powerMemories[state.channel] = value
90
+ setPowerMemories[state.channel](value).then()
91
+ }
92
+ }]}
93
+ />
94
+ </ScrollView>
95
+ </Page>
96
+ )
97
+ }
98
+
99
+ export default withTheme(PlugBehaviorPage)
@@ -0,0 +1,131 @@
1
+ import {useFeatureHook} from "@ledvance/base/src/models/modules/NativePropsSlice"
2
+ import {Result} from "@ledvance/base/src/models/modules/Result"
3
+ import {Utils} from 'tuya-panel-kit';
4
+ import {spliceByStep} from "@ledvance/base/src/utils/common";
5
+
6
+ const { hexStringToNumber } = Utils.StringUtils;
7
+
8
+ // plug
9
+ export interface PowerBehaviorPageParams {
10
+ powerBehaviorKeys: string[]
11
+ }
12
+
13
+ type PowerBehaviorType = 'off' | 'on' | 'memory'
14
+
15
+ interface PlugPowerBehaviorConfig {
16
+ [key: string]: PowerBehaviorType
17
+ }
18
+
19
+ export const usePowerBehavior = (keys: string[]): [PowerBehaviorType[], ((v: PowerBehaviorType) => Promise<Result<any>>)[]] => {
20
+ return keys.reduce(
21
+ (acc, key) => {
22
+ const [behavior, handler] = useFeatureHook<PlugPowerBehaviorConfig, PowerBehaviorType>(key, 'memory');
23
+ acc[0].push(behavior);
24
+ acc[1].push(handler);
25
+ return acc;
26
+ },
27
+ [[], []] as [PowerBehaviorType[], ((v: PowerBehaviorType) => Promise<Result<any>>)[]]
28
+ );
29
+ };
30
+
31
+
32
+
33
+ // light source
34
+ export interface LightBehaviorPageParams {
35
+ isSupportDoNotDisturb?: boolean
36
+ isSupportBrightness: boolean
37
+ isSupportTemperature: boolean
38
+ isSupportColor: boolean
39
+ }
40
+
41
+ export interface PowerOffMemoryModel {
42
+ type: number; // 0 => default, 1 => memory, 2 => custom
43
+ hue: number;
44
+ sat: number;
45
+ val: number;
46
+ bright: number;
47
+ temperature: number;
48
+ isColor: boolean
49
+ }
50
+
51
+ type SetPowerOffMemoryResultType = (
52
+ powerOffMemory: PowerOffMemoryModel
53
+ ) => Promise<Result<any>>;
54
+
55
+ interface LightPowerBehaviorConfig {
56
+ powerMemory: PowerOffMemoryModel
57
+ }
58
+
59
+ export function usePowerOffMemory(): [PowerOffMemoryModel, SetPowerOffMemoryResultType] {
60
+ return useFeatureHook<LightPowerBehaviorConfig, PowerOffMemoryModel>('powerMemory', {
61
+ type: 0,
62
+ hue: 0,
63
+ sat: 100,
64
+ val: 100,
65
+ bright: 100,
66
+ temperature: 100,
67
+ isColor: false
68
+ }, (powerMemory) => obj2Dp(powerMemory))
69
+ }
70
+
71
+
72
+ interface DoNotDisturbConfig {
73
+ doNotDisturb: boolean
74
+ }
75
+
76
+ export const useDoNotDisturbControl = (): [boolean, (v: boolean) => Promise<Result<any>>] => {
77
+ return useFeatureHook<DoNotDisturbConfig, boolean>('doNotDisturb', false)
78
+ };
79
+
80
+
81
+ export function dp2Obj(dp: string): PowerOffMemoryModel {
82
+ if (!dp || dp === '') {
83
+ return {
84
+ type: 0,
85
+ hue: 0,
86
+ sat: 100,
87
+ val: 100,
88
+ bright: 100,
89
+ temperature: 100,
90
+ isColor: false
91
+ };
92
+ }
93
+ const dpValueArray = hexStringToNumber(dp);
94
+ const dpStepArray = spliceByStep(dp, 4);
95
+ const hue = parseInt(dpStepArray[1], 16)
96
+ const sat = Math.trunc(parseInt(dpStepArray[2], 16) / 10)
97
+ const val = Math.trunc(parseInt(dpStepArray[3], 16) / 10)
98
+ const bright = Math.trunc(parseInt(dpStepArray[4], 16) / 10)
99
+ const temperature = Math.trunc(parseInt(dpStepArray[5], 16) / 10)
100
+ const isColor = !!(hue || sat || val)
101
+ return {
102
+ type: dpValueArray[1],
103
+ isColor,
104
+ hue: isColor ? hue : 0,
105
+ sat: isColor ? sat : 100,
106
+ val: isColor ? val : 100,
107
+ bright: isColor ? 100 : bright,
108
+ temperature: isColor ? 100 : temperature,
109
+ };
110
+ }
111
+
112
+ export function obj2Dp(obj: PowerOffMemoryModel): string {
113
+ const version = '00';
114
+ if (obj.isColor) {
115
+ obj.bright = 0
116
+ obj.temperature = 0
117
+ } else {
118
+ obj.hue = 0
119
+ obj.sat = 0
120
+ obj.val = 0
121
+ }
122
+ const type = obj.type.toString(16).padStart(2, '0');
123
+ const hueDpValue = obj.hue.toString(16).padStart(4, '0');
124
+ const satDpValue = (obj.sat * 10).toString(16).padStart(4, '0');
125
+ const valDpValue = (obj.val * 10).toString(16).padStart(4, '0');
126
+ const brightnessDpValue = (obj.bright * 10).toString(16).padStart(4, '0');
127
+ const colorTempDpValue = (obj.temperature * 10).toString(16).padStart(4, '0');
128
+ return (
129
+ version + type + hueDpValue + satDpValue + valDpValue + brightnessDpValue + colorTempDpValue
130
+ );
131
+ }
@@ -0,0 +1,27 @@
1
+ import {NavigationRoute} from "tuya-panel-kit";
2
+ import PlugBehaviorPage from "./PlugBehaviorPage";
3
+ import LightBehaviorPage from "./LightBehaviorPage";
4
+ import {ui_biz_routerKey} from "../../navigation/Routers";
5
+
6
+ export const PlugPowerOnBehaviorPageRouters: NavigationRoute[] = [
7
+ {
8
+ name: ui_biz_routerKey.group_ui_biz_power_behavior_plug,
9
+ component: PlugBehaviorPage,
10
+ options: {
11
+ hideTopbar: true,
12
+ showOfflineView: false,
13
+ }
14
+ }
15
+ ]
16
+
17
+ export const LightPowerOnBehaviorPageRouters: NavigationRoute[] = [
18
+ {
19
+ name: ui_biz_routerKey.group_ui_biz_power_behavior_light,
20
+ component: LightBehaviorPage,
21
+ options: {
22
+ hideTopbar: true,
23
+ showOfflineView: false,
24
+ }
25
+ }
26
+ ]
27
+
@@ -34,5 +34,7 @@ export const ui_biz_routerKey = {
34
34
  'group_ui_biz_energy_consumption_detail': 'group_ui_biz_energy_consumption_detail',
35
35
  'group_ui_biz_energy_consumption_chart': 'group_ui_biz_energy_consumption_chart',
36
36
  'group_ui_biz_diy_scene_page': 'group_ui_biz_diy_scene_page',
37
- 'group_ui_biz_diy_scene_edit_page': 'group_ui_biz_diy_scene_edit_page'
37
+ 'group_ui_biz_diy_scene_edit_page': 'group_ui_biz_diy_scene_edit_page',
38
+ 'group_ui_biz_power_behavior_plug': 'group_ui_biz_power_behavior_plug',
39
+ 'group_ui_biz_power_behavior_light': 'group_ui_biz_power_behavior_light',
38
40
  }
@@ -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
- }