@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.
- package/package.json +1 -1
- package/src/modules/mood/DynamicMoodEditorPage.tsx +1 -1
- package/src/modules/mood/FantasyMoodEditPage.tsx +1 -1
- package/src/modules/mood/MixMood/MixMoodEditPage.tsx +1 -1
- package/src/modules/mood/StaticMoodEditorPage.tsx +2 -2
- package/src/newModules/biorhythm/BiorhythmActions.ts +22 -8
- package/src/newModules/biorhythm/BiorhythmPage.tsx +117 -79
- package/src/newModules/biorhythm/circular/RhythmsCircle.tsx +483 -0
- package/src/newModules/biorhythm/circular/conical-gradient/Android.tsx +63 -0
- package/src/newModules/biorhythm/circular/conical-gradient/Ios.tsx +26 -0
- package/src/newModules/biorhythm/circular/conical-gradient/Normal.tsx +187 -0
- package/src/newModules/biorhythm/circular/conical-gradient/index.android.tsx +164 -0
- package/src/newModules/biorhythm/circular/conical-gradient/index.ios.tsx +124 -0
- package/src/newModules/biorhythm/circular/conical-gradient/index.tsx +3 -0
- package/src/newModules/biorhythm/circular/conical-gradient/index.web.tsx +94 -0
- package/src/newModules/biorhythm/circular/conical-gradient/interface.ts +19 -0
- package/src/newModules/biorhythm/circular/conical-gradient/utils.ts +25 -0
- package/src/newModules/biorhythm/circular/interface.ts +114 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +3 -0
- package/src/newModules/lightMode/LightModePage.tsx +52 -145
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +1 -1
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +1 -1
- package/src/newModules/mood/MoodInfo.ts +1 -1
- package/src/newModules/mood/MoodPage.tsx +4 -5
- package/src/newModules/mood/StaticMoodEditorPage.tsx +1 -1
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +37 -120
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +60 -141
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +13 -5
- package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +122 -59
- package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +10 -10
- package/src/newModules/biorhythm/circular/ItemIcon.d.ts +0 -22
- package/src/newModules/biorhythm/circular/ItemIcon.tsx +0 -173
- package/src/newModules/biorhythm/circular/Progress.d.ts +0 -24
- package/src/newModules/biorhythm/circular/Progress.tsx +0 -372
- package/src/newModules/biorhythm/circular/TimeCircular.d.ts +0 -11
- package/src/newModules/biorhythm/circular/TimeCircular.tsx +0 -64
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {ScrollView, StyleSheet} from 'react-native'
|
|
3
3
|
import Page from '@ledvance/base/src/components/Page'
|
|
4
|
-
import {
|
|
4
|
+
import {useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
5
5
|
import I18n from '@ledvance/base/src/i18n'
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import {PowerBehaviorPageParams, usePowerBehavior} from './PowerOnBehaviorActions'
|
|
7
|
+
import {Utils} from 'tuya-panel-kit'
|
|
8
8
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
9
|
+
import OptionGroup from '@ledvance/base/src/components/OptionGroup'
|
|
10
|
+
import {useReactive, useUpdateEffect} from 'ahooks'
|
|
11
|
+
import {useParams} from '@ledvance/base/src/hooks/Hooks'
|
|
12
|
+
import {cloneDeep} from "lodash";
|
|
13
|
+
import Segmented from "@ledvance/base/src/components/Segmented";
|
|
14
14
|
|
|
15
15
|
const { convertX: cx } = Utils.RatioUtils
|
|
16
16
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -19,76 +19,25 @@ const RELAY_STATUS_OFF = 'off'
|
|
|
19
19
|
const RELAY_STATUS_ON = 'on'
|
|
20
20
|
const RELAY_STATUS_MEMORY = 'memory'
|
|
21
21
|
|
|
22
|
-
const PlugBehaviorPage = (
|
|
22
|
+
const PlugBehaviorPage = () => {
|
|
23
23
|
const params = useParams<PowerBehaviorPageParams>()
|
|
24
24
|
const deviceInfo = useDeviceInfo()
|
|
25
|
-
const [
|
|
25
|
+
const [powerMemories, setPowerMemories] = usePowerBehavior(params.powerBehaviorKeys)
|
|
26
26
|
|
|
27
27
|
const state = useReactive({
|
|
28
|
-
|
|
28
|
+
channel: 0,
|
|
29
|
+
powerMemories: powerMemories,
|
|
29
30
|
loading: false,
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
useUpdateEffect(() => {
|
|
33
|
-
state.
|
|
34
|
-
}, [
|
|
34
|
+
state.powerMemories = cloneDeep(powerMemories)
|
|
35
|
+
}, [JSON.stringify(powerMemories)])
|
|
35
36
|
|
|
36
37
|
const styles = StyleSheet.create({
|
|
37
38
|
root: {
|
|
38
39
|
flex: 1,
|
|
39
40
|
},
|
|
40
|
-
tipText: {
|
|
41
|
-
marginHorizontal: cx(24),
|
|
42
|
-
color: props.theme?.global.fontColor,
|
|
43
|
-
fontSize: cx(14),
|
|
44
|
-
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
45
|
-
},
|
|
46
|
-
modeSelectGroup: {
|
|
47
|
-
marginHorizontal: cx(24),
|
|
48
|
-
backgroundColor: props.theme?.container.background,
|
|
49
|
-
borderRadius: cx(4),
|
|
50
|
-
},
|
|
51
|
-
modeTip: {
|
|
52
|
-
marginHorizontal: cx(8),
|
|
53
|
-
color: props.theme?.global.fontColor,
|
|
54
|
-
fontSize: cx(14),
|
|
55
|
-
fontWeight: 'bold',
|
|
56
|
-
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
57
|
-
},
|
|
58
|
-
modeSelectCard: {
|
|
59
|
-
marginHorizontal: cx(8),
|
|
60
|
-
},
|
|
61
|
-
line: {
|
|
62
|
-
height: cx(1),
|
|
63
|
-
marginHorizontal: cx(12),
|
|
64
|
-
backgroundColor: props.theme?.container.divider,
|
|
65
|
-
},
|
|
66
|
-
itemRoot: {
|
|
67
|
-
flexDirection: 'row',
|
|
68
|
-
alignItems: 'center',
|
|
69
|
-
paddingHorizontal: cx(12),
|
|
70
|
-
paddingBottom: cx(8),
|
|
71
|
-
},
|
|
72
|
-
itemTextGroup: {
|
|
73
|
-
flex: 1,
|
|
74
|
-
marginEnd: cx(12),
|
|
75
|
-
justifyContent: 'center',
|
|
76
|
-
},
|
|
77
|
-
itemTitle: {
|
|
78
|
-
color: props.theme?.global.fontColor,
|
|
79
|
-
fontSize: cx(14),
|
|
80
|
-
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
81
|
-
},
|
|
82
|
-
itemContent: {
|
|
83
|
-
color: props.theme?.global.secondFontColor,
|
|
84
|
-
fontSize: cx(14),
|
|
85
|
-
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
86
|
-
},
|
|
87
|
-
itemCheckedIcon: {
|
|
88
|
-
width: cx(32),
|
|
89
|
-
height: cx(32),
|
|
90
|
-
marginEnd: cx(4),
|
|
91
|
-
},
|
|
92
41
|
})
|
|
93
42
|
|
|
94
43
|
return (
|
|
@@ -97,84 +46,54 @@ const PlugBehaviorPage = (props: { theme?: ThemeType }) => {
|
|
|
97
46
|
headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
|
|
98
47
|
loading={state.loading}>
|
|
99
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
|
+
</>}
|
|
100
64
|
<Spacer />
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<Spacer height={cx(8)} />
|
|
131
|
-
<PowerOnBehaviorModeItem
|
|
132
|
-
styles={styles}
|
|
133
|
-
enable={state.powerMemory === RELAY_STATUS_MEMORY}
|
|
134
|
-
title={I18n.getLang('sockets_specific_settings_relay_status_remember')}
|
|
135
|
-
content={I18n.getLang('socket_settings_firstbox_status3_description')}
|
|
136
|
-
onPress={async () => {
|
|
137
|
-
state.powerMemory = RELAY_STATUS_MEMORY
|
|
138
|
-
await setPowerMemory(state.powerMemory)
|
|
139
|
-
}} />
|
|
140
|
-
<Spacer height={cx(4)} />
|
|
141
|
-
</Card>
|
|
142
|
-
<Spacer height={cx(8)} />
|
|
143
|
-
</View>
|
|
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
|
+
/>
|
|
144
94
|
</ScrollView>
|
|
145
95
|
</Page>
|
|
146
96
|
)
|
|
147
97
|
}
|
|
148
98
|
|
|
149
|
-
interface PowerOnBehaviorModeItemProps extends PropsWithChildren<ViewProps> {
|
|
150
|
-
onPress: () => void
|
|
151
|
-
title: string
|
|
152
|
-
content: string
|
|
153
|
-
enable: boolean
|
|
154
|
-
styles: StyleSheet.NamedStyles<any>
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function PowerOnBehaviorModeItem(props: PowerOnBehaviorModeItemProps) {
|
|
158
|
-
const { styles } = props
|
|
159
|
-
return (
|
|
160
|
-
<TouchableOpacity onPress={props.onPress}>
|
|
161
|
-
<View style={styles.itemRoot}>
|
|
162
|
-
<View style={styles.itemTextGroup}>
|
|
163
|
-
<Text style={styles.itemTitle}>{props.title}</Text>
|
|
164
|
-
<Spacer height={cx(4)} />
|
|
165
|
-
<Text style={styles.itemContent}>{props.content}</Text>
|
|
166
|
-
</View>
|
|
167
|
-
<Image
|
|
168
|
-
source={{ uri: res.ic_check }}
|
|
169
|
-
style={[
|
|
170
|
-
styles.itemCheckedIcon,
|
|
171
|
-
{
|
|
172
|
-
display: props.enable ? 'flex' : 'none',
|
|
173
|
-
},
|
|
174
|
-
]} />
|
|
175
|
-
</View>
|
|
176
|
-
</TouchableOpacity>
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
99
|
export default withTheme(PlugBehaviorPage)
|
|
@@ -2,21 +2,29 @@ import { useState } from 'react';
|
|
|
2
2
|
import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
3
3
|
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
4
4
|
import { Utils } from 'tuya-panel-kit';
|
|
5
|
-
import { spliceByStep
|
|
5
|
+
import {getGlobalParamsDp, spliceByStep} from "@ledvance/base/src/utils/common";
|
|
6
6
|
import { useUpdateEffect } from 'ahooks';
|
|
7
7
|
|
|
8
8
|
const { hexStringToNumber } = Utils.StringUtils;
|
|
9
9
|
|
|
10
10
|
// plug
|
|
11
11
|
export interface PowerBehaviorPageParams {
|
|
12
|
-
|
|
12
|
+
powerBehaviorKeys: string[]
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
type PowerBehaviorType = 'off' | 'on' | 'memory'
|
|
16
16
|
|
|
17
|
-
export const usePowerBehavior = (
|
|
18
|
-
return
|
|
19
|
-
|
|
17
|
+
export const usePowerBehavior = (keys: string[]): [PowerBehaviorType[], ((v: PowerBehaviorType) => Promise<Result<any>>)[]] => {
|
|
18
|
+
return keys.reduce(
|
|
19
|
+
(acc, key) => {
|
|
20
|
+
const [behavior, handler] = useDp<PowerBehaviorType, any>(getGlobalParamsDp(key));
|
|
21
|
+
acc[0].push(behavior);
|
|
22
|
+
acc[1].push(handler);
|
|
23
|
+
return acc;
|
|
24
|
+
},
|
|
25
|
+
[[], []] as [PowerBehaviorType[], ((v: PowerBehaviorType) => Promise<Result<any>>)[]]
|
|
26
|
+
);
|
|
27
|
+
};
|
|
20
28
|
|
|
21
29
|
|
|
22
30
|
// light source
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { useDp, useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
3
3
|
import { getFeature, putFeature } from '@ledvance/base/src/api/native'
|
|
4
4
|
import { hex2Int, spliceByStep } from '@ledvance/base/src/utils/common'
|
|
@@ -7,6 +7,7 @@ import { cloneDeep, padStart } from 'lodash'
|
|
|
7
7
|
import { parseJSON, to16 } from '@tuya/tuya-panel-lamp-sdk/lib/utils'
|
|
8
8
|
import { Result } from '@ledvance/base/src/models/modules/Result'
|
|
9
9
|
import I18n from '@ledvance/base/src/i18n'
|
|
10
|
+
import { useUpdateEffect } from 'ahooks'
|
|
10
11
|
const sleepPlanFeatureId = 'SleepPlan'
|
|
11
12
|
const wakeUpPlanFeatureId = 'WakeUpPlan'
|
|
12
13
|
|
|
@@ -44,40 +45,69 @@ export const useWakeUp: WakeUpType = (wakeUpDp, disableFeature) => {
|
|
|
44
45
|
const devId = useDeviceId()
|
|
45
46
|
const [wakeUp, setWakeUp]: [string, (wakeUp: string) => Promise<Result<any>>] = useDp(wakeUpDp)
|
|
46
47
|
const [wakeUpList, setWakeUpList] = useState(wakeUpDp2Obj(wakeUp)?.nodes || [])
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const isInternalUpdateRef = useRef(false)
|
|
49
|
+
const previousDpRef = useRef(wakeUp)
|
|
50
|
+
|
|
51
|
+
const getWakeUp = () => {
|
|
52
|
+
if (wakeUpTimerId) {
|
|
53
|
+
clearTimeout(wakeUpTimerId)
|
|
54
|
+
wakeUpTimerId = undefined
|
|
53
55
|
}
|
|
54
56
|
wakeUpTimerId = setTimeout(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
getFeature(devId, wakeUpPlanFeatureId).then(res => {
|
|
58
|
+
if (res.result) {
|
|
59
|
+
const nodes = wakeUpDp2Obj(wakeUp)?.nodes || []
|
|
60
|
+
const uiPlan = nodes.map((item, idx) => {
|
|
61
|
+
const plan = res.data[idx]
|
|
62
|
+
const dp = parseJSON(plan?.startTime)?.dp
|
|
63
|
+
const featureItem = (plan && dp) ? plan : res.data.find(p => parseJSON(p?.startTime)?.dp)?.includes(item.nodeHex)
|
|
64
|
+
return {
|
|
65
|
+
...item,
|
|
66
|
+
id: idx,
|
|
67
|
+
name: featureItem ? featureItem?.name : `${I18n.getLang('sleepwakeschedule_field_3_Times_chips_text')} ${idx + 1}`
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
setWakeUpList(uiPlan || [])
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}, 150)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (disableFeature) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
if (wakeUp && wakeUp.length > 6) {
|
|
81
|
+
getWakeUp()
|
|
82
|
+
}
|
|
83
|
+
return () => {
|
|
84
|
+
if (wakeUpTimerId) {
|
|
85
|
+
clearTimeout(wakeUpTimerId)
|
|
86
|
+
wakeUpTimerId = undefined
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [])
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
useUpdateEffect(() => {
|
|
92
|
+
if (isInternalUpdateRef.current || disableFeature) {
|
|
93
|
+
isInternalUpdateRef.current = false
|
|
94
|
+
if (isInternalUpdateRef.current) {
|
|
95
|
+
previousDpRef.current = wakeUp
|
|
96
|
+
}
|
|
97
|
+
if (disableFeature) {
|
|
98
|
+
setWakeUpList(wakeUpDp2Obj(wakeUp)?.nodes || [])
|
|
99
|
+
}
|
|
100
|
+
return
|
|
77
101
|
}
|
|
102
|
+
if (wakeUp.toLocaleLowerCase() === previousDpRef.current?.toLocaleLowerCase()) {
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
previousDpRef.current = wakeUp
|
|
106
|
+
getWakeUp()
|
|
78
107
|
}, [wakeUp])
|
|
79
108
|
|
|
80
109
|
const setWakeUpFn = async (wakeUp: WakeUpUIItem[], pushFeature = true) => {
|
|
110
|
+
isInternalUpdateRef.current = true
|
|
81
111
|
const featureData = wakeUp.map(item => {
|
|
82
112
|
return {
|
|
83
113
|
name: item.name,
|
|
@@ -86,7 +116,7 @@ export const useWakeUp: WakeUpType = (wakeUpDp, disableFeature) => {
|
|
|
86
116
|
})
|
|
87
117
|
}
|
|
88
118
|
})
|
|
89
|
-
const res = pushFeature ? await putFeature(devId, wakeUpPlanFeatureId, featureData || []) : {result: true}
|
|
119
|
+
const res = pushFeature ? await putFeature(devId, wakeUpPlanFeatureId, featureData || []) : { result: true }
|
|
90
120
|
const wakeUpData = {
|
|
91
121
|
version: 0,
|
|
92
122
|
num: wakeUp.length,
|
|
@@ -98,11 +128,13 @@ export const useWakeUp: WakeUpType = (wakeUpDp, disableFeature) => {
|
|
|
98
128
|
success: true
|
|
99
129
|
}
|
|
100
130
|
}
|
|
131
|
+
console.log('==== wakeUp running 444444====')
|
|
132
|
+
isInternalUpdateRef.current = false
|
|
101
133
|
return {
|
|
102
134
|
success: false
|
|
103
135
|
}
|
|
104
136
|
}
|
|
105
|
-
return [wakeUpList, setWakeUpFn
|
|
137
|
+
return [wakeUpList, setWakeUpFn]
|
|
106
138
|
}
|
|
107
139
|
|
|
108
140
|
|
|
@@ -175,7 +207,7 @@ const wakeUpObj2Dp = (wakeUp: WakeUpData) => {
|
|
|
175
207
|
return versionHex + numHex + nodeHex
|
|
176
208
|
}
|
|
177
209
|
|
|
178
|
-
export const wakeUpNode2Dp = (node: WakeUpItem) =>{
|
|
210
|
+
export const wakeUpNode2Dp = (node: WakeUpItem) => {
|
|
179
211
|
const enableHex = node.enable ? '01' : '00'
|
|
180
212
|
const cloneWeek = cloneDeep(node.weeks)
|
|
181
213
|
cloneWeek.pop()
|
|
@@ -203,40 +235,70 @@ export const useSleepMode: SleepModeType = (sleepDp, disableFeature) => {
|
|
|
203
235
|
const devId = useDeviceId()
|
|
204
236
|
const [sleepMode, setSleepMode]: [string, (sleep: string) => Promise<Result<any>>] = useDp(sleepDp)
|
|
205
237
|
const [sleepPlan, setSleepPlan] = useState(sleepDp2Obj(sleepMode)?.nodes || [])
|
|
206
|
-
const
|
|
238
|
+
const isInternalUpdateRef = useRef(false)
|
|
239
|
+
const previousDpRef = useRef(sleepMode)
|
|
240
|
+
|
|
241
|
+
const getSleepPlan = () => {
|
|
242
|
+
if (sleepTimerId) {
|
|
243
|
+
clearTimeout(sleepTimerId)
|
|
244
|
+
sleepTimerId = undefined
|
|
245
|
+
}
|
|
246
|
+
sleepTimerId = setTimeout(() => {
|
|
247
|
+
getFeature(devId, sleepPlanFeatureId).then(res => {
|
|
248
|
+
if (res.result) {
|
|
249
|
+
const nodes = sleepDp2Obj(sleepMode)?.nodes || []
|
|
250
|
+
const uiPlan = nodes.map((item, idx) => {
|
|
251
|
+
const plan = res.data[idx]
|
|
252
|
+
const dp = parseJSON(plan?.startTime)?.dp
|
|
253
|
+
const featureItem = (plan && dp) ? plan : res.data.find(p => parseJSON(p?.startTime)?.dp)?.includes(item.nodeHex)
|
|
254
|
+
return {
|
|
255
|
+
...item,
|
|
256
|
+
id: idx,
|
|
257
|
+
name: featureItem ? featureItem?.name : `${I18n.getLang('sleepwakeschedule_field_3_Times_chips2_text')} ${idx + 1}`
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
setSleepPlan(uiPlan || [])
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
}, 150)
|
|
264
|
+
}
|
|
265
|
+
|
|
207
266
|
useEffect(() => {
|
|
208
|
-
if(disableFeature) {
|
|
209
|
-
setIsComplete(true)
|
|
267
|
+
if (disableFeature) {
|
|
210
268
|
setSleepPlan(sleepDp2Obj(sleepMode)?.nodes || [])
|
|
211
|
-
return
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
if (sleepMode && sleepMode.length > 6) {
|
|
272
|
+
getSleepPlan()
|
|
273
|
+
}
|
|
274
|
+
return () => {
|
|
275
|
+
if (sleepTimerId) {
|
|
276
|
+
clearTimeout(sleepTimerId)
|
|
277
|
+
sleepTimerId = undefined
|
|
278
|
+
}
|
|
212
279
|
}
|
|
213
|
-
|
|
214
|
-
setIsComplete(false)
|
|
215
|
-
getFeature(devId, sleepPlanFeatureId).then(res => {
|
|
216
|
-
setIsComplete(true)
|
|
217
|
-
if (res.result) {
|
|
218
|
-
const nodes = sleepDp2Obj(sleepMode)?.nodes || []
|
|
219
|
-
const uiPlan = nodes.map((item, idx) => {
|
|
220
|
-
const plan = res.data[idx]
|
|
221
|
-
const dp = parseJSON(plan?.startTime)?.dp
|
|
222
|
-
const featureItem = (plan && dp) ? plan : res.data.find(p => parseJSON(p?.startTime)?.dp)?.includes(item.nodeHex)
|
|
223
|
-
return {
|
|
224
|
-
...item,
|
|
225
|
-
id: idx,
|
|
226
|
-
name: featureItem ? featureItem?.name : `${I18n.getLang('sleepwakeschedule_field_3_Times_chips2_text')} ${idx + 1}`
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
setSleepPlan(uiPlan || [])
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
}, 250)
|
|
280
|
+
}, [])
|
|
233
281
|
|
|
234
|
-
|
|
235
|
-
|
|
282
|
+
useUpdateEffect(() => {
|
|
283
|
+
if (isInternalUpdateRef.current || disableFeature) {
|
|
284
|
+
isInternalUpdateRef.current = false
|
|
285
|
+
if (isInternalUpdateRef.current) {
|
|
286
|
+
previousDpRef.current = sleepMode
|
|
287
|
+
}
|
|
288
|
+
if (disableFeature) {
|
|
289
|
+
setSleepPlan(sleepDp2Obj(sleepMode)?.nodes || [])
|
|
290
|
+
}
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
if (sleepMode.toLocaleLowerCase() === previousDpRef.current?.toLocaleLowerCase()) {
|
|
294
|
+
return
|
|
236
295
|
}
|
|
296
|
+
previousDpRef.current = sleepMode
|
|
297
|
+
getSleepPlan()
|
|
237
298
|
}, [sleepMode])
|
|
238
299
|
|
|
239
300
|
const setSleepPlanFn = async (sleep: SleepUIItem[], pushFeature = true) => {
|
|
301
|
+
isInternalUpdateRef.current = true
|
|
240
302
|
const featureData = sleep.map(item => {
|
|
241
303
|
return {
|
|
242
304
|
name: item.name,
|
|
@@ -245,7 +307,7 @@ export const useSleepMode: SleepModeType = (sleepDp, disableFeature) => {
|
|
|
245
307
|
})
|
|
246
308
|
}
|
|
247
309
|
})
|
|
248
|
-
const res = pushFeature ? await putFeature(devId, sleepPlanFeatureId, featureData || []) : {result: true}
|
|
310
|
+
const res = pushFeature ? await putFeature(devId, sleepPlanFeatureId, featureData || []) : { result: true }
|
|
249
311
|
const sleepData = {
|
|
250
312
|
version: 0,
|
|
251
313
|
num: sleep.length,
|
|
@@ -257,11 +319,12 @@ export const useSleepMode: SleepModeType = (sleepDp, disableFeature) => {
|
|
|
257
319
|
success: true
|
|
258
320
|
}
|
|
259
321
|
}
|
|
322
|
+
isInternalUpdateRef.current = false
|
|
260
323
|
return {
|
|
261
324
|
success: false
|
|
262
325
|
}
|
|
263
326
|
}
|
|
264
|
-
return [sleepPlan, setSleepPlanFn
|
|
327
|
+
return [sleepPlan, setSleepPlanFn]
|
|
265
328
|
}
|
|
266
329
|
|
|
267
330
|
export const sleepDp2Obj = (dp: string): SleepData | undefined => {
|
|
@@ -49,8 +49,8 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
49
49
|
const navigation = useNavigation()
|
|
50
50
|
const is24HourClock = useSystemTimeFormate()
|
|
51
51
|
const params = useParams<SleepWakeUpPageRouteParams>()
|
|
52
|
-
const [wakeUpList, setWakeUpList
|
|
53
|
-
const [sleepList, setSleepList
|
|
52
|
+
const [wakeUpList, setWakeUpList] = useWakeUp(params.wakeUpDpCode)
|
|
53
|
+
const [sleepList, setSleepList] = useSleepMode(params.sleepDpCode)
|
|
54
54
|
const [checkConflict, resolveConflict] = useConflictTask(params.conflictDps)
|
|
55
55
|
const state = useReactive({
|
|
56
56
|
showAddSchedulePopover: false,
|
|
@@ -60,7 +60,7 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
60
60
|
wakeUpScheduleList: cloneDeep(wakeUpList),
|
|
61
61
|
filteredScheduleList: [] as any[],
|
|
62
62
|
flag: Symbol(),
|
|
63
|
-
loading:
|
|
63
|
+
loading: false
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
const isMaxNum = useMemo(() => {
|
|
@@ -75,9 +75,6 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
75
75
|
state.wakeUpScheduleList = cloneDeep(wakeUpList)
|
|
76
76
|
}, [JSON.stringify(wakeUpList)])
|
|
77
77
|
|
|
78
|
-
useUpdateEffect(() => {
|
|
79
|
-
state.loading = !wakeupComplete && !sleepComplete
|
|
80
|
-
}, [wakeupComplete, sleepComplete])
|
|
81
78
|
|
|
82
79
|
const onAddScheduleDialogItemClick = (isSleep: boolean, mode: 'add' | 'edit', scheduleItem?: any) => {
|
|
83
80
|
if (mode === 'add' && isSleep && state.sleepScheduleList.length === MAX_SCHEDULE) return
|
|
@@ -118,8 +115,8 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
118
115
|
if ((mode === 'edit' && sleepWakeUp.enable) || mode === 'add') {
|
|
119
116
|
let sleepConflict = false
|
|
120
117
|
let wakeUpConflict = false
|
|
121
|
-
const cloneSleepPlan = isSleep ? cloneSleepWakeUp : cloneDeep(
|
|
122
|
-
const cloneWakeUpPlan = isSleep ? cloneDeep(
|
|
118
|
+
const cloneSleepPlan = isSleep ? cloneSleepWakeUp : cloneDeep(state.sleepScheduleList)
|
|
119
|
+
const cloneWakeUpPlan = isSleep ? cloneDeep(state.wakeUpScheduleList) : cloneSleepWakeUp
|
|
123
120
|
const currentSleepWakeUp = {
|
|
124
121
|
...sleepWakeUp,
|
|
125
122
|
startTime: getStartTime(sleepWakeUp),
|
|
@@ -131,7 +128,8 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
131
128
|
if (!itself && item.enable && isConflictTask({
|
|
132
129
|
...item,
|
|
133
130
|
startTime: getStartTime(item),
|
|
134
|
-
endTime: getEndTime(item)
|
|
131
|
+
endTime: getEndTime(item),
|
|
132
|
+
channel: 1
|
|
135
133
|
}, currentSleepWakeUp)){
|
|
136
134
|
sleepConflict = true
|
|
137
135
|
item.enable = false
|
|
@@ -144,7 +142,8 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
144
142
|
if (!itself && item.enable && isConflictTask({
|
|
145
143
|
...item,
|
|
146
144
|
startTime: getStartTime(item),
|
|
147
|
-
endTime: getEndTime(item)
|
|
145
|
+
endTime: getEndTime(item),
|
|
146
|
+
channel: 1
|
|
148
147
|
}, currentSleepWakeUp)){
|
|
149
148
|
wakeUpConflict = true
|
|
150
149
|
item.enable = false
|
|
@@ -153,6 +152,7 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
|
|
|
153
152
|
return item
|
|
154
153
|
})
|
|
155
154
|
const isConflict = checkConflict(currentSleepWakeUp) || sleepConflict || wakeUpConflict
|
|
155
|
+
|
|
156
156
|
if (isConflict) {
|
|
157
157
|
return new Promise((resolve) => {
|
|
158
158
|
showDialog({
|
|
@@ -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
|
-
}
|