@ledvance/ui-biz-bundle 1.1.55 → 1.1.57
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 +2 -1
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTime/Router.ts +26 -0
- package/src/modules/flags/FlagActions.ts +12 -4
- package/src/modules/flags/FlagPage.tsx +31 -11
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/history/Router.ts +16 -0
- package/src/modules/mood/FantasyRouter.ts +35 -0
- package/src/modules/mood/MixMood/Router.ts +44 -0
- package/src/modules/mood/Router.ts +53 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/powerOnBehavior/Router.ts +16 -0
- package/src/modules/randomTime/Router.ts +25 -0
- package/src/modules/sleepWakeup/Router.ts +25 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.d.ts +0 -7
- package/src/navigation/Routers.ts +15 -304
- package/src/newModules/childLock/ChildLockPage.tsx +97 -0
- package/src/newModules/childLock/Router.ts +16 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
- package/src/newModules/energyConsumption/Router.ts +34 -0
- package/src/newModules/energyConsumption/co2Data.ts +23655 -0
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
- package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
- package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
- package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
- package/src/newModules/fixedTime/Router.ts +25 -0
- package/src/newModules/lightMode/LightModePage.tsx +204 -0
- package/src/newModules/lightMode/Router.ts +16 -0
- package/src/newModules/mood/AddMoodPage.tsx +178 -0
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
- package/src/newModules/mood/Interface.ts +219 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
- package/src/newModules/mood/MoodActions.ts +235 -0
- package/src/newModules/mood/MoodInfo.ts +2151 -0
- package/src/newModules/mood/MoodItem.tsx +148 -0
- package/src/newModules/mood/MoodPage.tsx +385 -0
- package/src/newModules/mood/MoodParse.ts +442 -0
- package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
- package/src/newModules/mood/Router.ts +53 -0
- package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
- package/src/newModules/mood/tools.ts +12 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
- package/src/newModules/overchargeSwitch/Router.ts +16 -0
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
- package/src/newModules/powerOnBehavior/Router.ts +16 -0
- package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
- package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
- package/src/newModules/randomTime/Router.ts +25 -0
- package/src/newModules/randomTime/Summary.tsx +116 -0
- package/src/newModules/swithInching/Router.ts +16 -0
- package/src/newModules/swithInching/SwithInching.tsx +231 -0
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
- package/src/newModules/swithInching/pickerView.tsx +91 -0
- package/src/newModules/timeSchedule/Interface.ts +111 -0
- package/src/newModules/timeSchedule/Router.ts +25 -0
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react'
|
|
2
|
+
import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View, ViewProps } from 'react-native'
|
|
3
|
+
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
4
|
+
import { Utils } from 'tuya-panel-kit'
|
|
5
|
+
import Page from '@ledvance/base/src/components/Page'
|
|
6
|
+
import { useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
7
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
8
|
+
import { usePowerOffMemory, useDoNotDisturbControl } from './PowerOnBehaviorActions'
|
|
9
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
10
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
11
|
+
import res from '@ledvance/base/src/res'
|
|
12
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
13
|
+
import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
|
|
14
|
+
import { cloneDeep } from 'lodash'
|
|
15
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
16
|
+
|
|
17
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
18
|
+
|
|
19
|
+
export interface LightBehaviorPageParams {
|
|
20
|
+
memoryDpCode: string
|
|
21
|
+
disturbDpCode: string
|
|
22
|
+
isSupportDoNotDisturb?: boolean
|
|
23
|
+
isSupportBrightness: boolean
|
|
24
|
+
isSupportTemperature: boolean
|
|
25
|
+
isSupportColor: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum PowerMemoryMode {
|
|
29
|
+
Default = 0,
|
|
30
|
+
Last = 1,
|
|
31
|
+
Custom = 2
|
|
32
|
+
}
|
|
33
|
+
const LightBehaviorPage = () => {
|
|
34
|
+
const params = useParams<LightBehaviorPageParams>()
|
|
35
|
+
const deviceInfo = useDeviceInfo()
|
|
36
|
+
const [powerMemory, setPowerMemory] = usePowerOffMemory(params.memoryDpCode)
|
|
37
|
+
const [doNotDisturb, setDoNotDisturb] = useDoNotDisturbControl(params.disturbDpCode)
|
|
38
|
+
const state = useReactive({
|
|
39
|
+
loading: false,
|
|
40
|
+
powerMemory: cloneDeep(powerMemory),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
useUpdateEffect(() => {
|
|
44
|
+
state.powerMemory = powerMemory
|
|
45
|
+
}, [JSON.stringify(powerMemory)])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Page
|
|
49
|
+
backText={deviceInfo.name}
|
|
50
|
+
headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
|
|
51
|
+
loading={state.loading}>
|
|
52
|
+
<ScrollView style={styles.root} nestedScrollEnabled={true}>
|
|
53
|
+
<View>
|
|
54
|
+
<Text style={styles.tipText}>
|
|
55
|
+
{I18n.getLang('light_settings_default_secondtopic')}
|
|
56
|
+
</Text>
|
|
57
|
+
<Spacer />
|
|
58
|
+
<View style={styles.modeSelectGroup}>
|
|
59
|
+
<Spacer height={cx(8)} />
|
|
60
|
+
<Text style={styles.modeTip}>
|
|
61
|
+
{I18n.getLang('groups_settings_power_on_behavior_secondbox_topic')}
|
|
62
|
+
</Text>
|
|
63
|
+
<Spacer height={cx(8)} />
|
|
64
|
+
<Card style={styles.modeSelectCard}>
|
|
65
|
+
<Spacer height={cx(12)} />
|
|
66
|
+
<PowerOnBehaviorModeItem
|
|
67
|
+
enable={state.powerMemory.type === PowerMemoryMode.Default}
|
|
68
|
+
title={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value1_topic')}
|
|
69
|
+
content={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value1_description')}
|
|
70
|
+
onPress={async () => {
|
|
71
|
+
state.powerMemory.type = PowerMemoryMode.Default
|
|
72
|
+
await setPowerMemory(state.powerMemory)
|
|
73
|
+
}} />
|
|
74
|
+
<View style={styles.line} />
|
|
75
|
+
<Spacer height={cx(8)} />
|
|
76
|
+
<PowerOnBehaviorModeItem
|
|
77
|
+
enable={state.powerMemory.type === PowerMemoryMode.Last}
|
|
78
|
+
title={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value2_topic')}
|
|
79
|
+
content={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value2_description')}
|
|
80
|
+
onPress={async () => {
|
|
81
|
+
state.powerMemory.type = PowerMemoryMode.Last
|
|
82
|
+
await setPowerMemory(state.powerMemory)
|
|
83
|
+
}} />
|
|
84
|
+
<View style={styles.line} />
|
|
85
|
+
<Spacer height={cx(8)} />
|
|
86
|
+
<PowerOnBehaviorModeItem
|
|
87
|
+
enable={state.powerMemory.type === PowerMemoryMode.Custom}
|
|
88
|
+
title={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value3_topic')}
|
|
89
|
+
content={I18n.getLang('groups_settings_power_on_behavior_secondbox_status_value3_description')}
|
|
90
|
+
onPress={async () => {
|
|
91
|
+
state.powerMemory.type = PowerMemoryMode.Custom
|
|
92
|
+
await setPowerMemory(state.powerMemory)
|
|
93
|
+
}} />
|
|
94
|
+
<Spacer height={cx(4)} />
|
|
95
|
+
</Card>
|
|
96
|
+
<Spacer height={cx(8)} />
|
|
97
|
+
</View>
|
|
98
|
+
<Spacer />
|
|
99
|
+
{state.powerMemory.type === PowerMemoryMode.Custom &&
|
|
100
|
+
<Card style={{ marginHorizontal: cx(24) }}>
|
|
101
|
+
<View>
|
|
102
|
+
<Spacer />
|
|
103
|
+
<LampAdjustView
|
|
104
|
+
isSupportColor={params.isSupportColor}
|
|
105
|
+
isSupportTemperature={params.isSupportTemperature}
|
|
106
|
+
isSupportBrightness={params.isSupportBrightness}
|
|
107
|
+
isColorMode={state.powerMemory.isColor}
|
|
108
|
+
reserveSV={true}
|
|
109
|
+
setIsColorMode={async isColorMode => {
|
|
110
|
+
state.powerMemory.isColor = isColorMode
|
|
111
|
+
}}
|
|
112
|
+
h={state.powerMemory.hue} s={state.powerMemory.sat} v={state.powerMemory.val}
|
|
113
|
+
onHSVChange={(h, s, v) => {
|
|
114
|
+
state.powerMemory.hue = h
|
|
115
|
+
state.powerMemory.sat = s
|
|
116
|
+
state.powerMemory.val = v
|
|
117
|
+
}}
|
|
118
|
+
onHSVChangeComplete={async (h, s, v) => {
|
|
119
|
+
state.powerMemory.hue = h
|
|
120
|
+
state.powerMemory.sat = s
|
|
121
|
+
state.powerMemory.val = v
|
|
122
|
+
await setPowerMemory(state.powerMemory)
|
|
123
|
+
}}
|
|
124
|
+
colorTemp={state.powerMemory.temperature}
|
|
125
|
+
brightness={state.powerMemory.bright}
|
|
126
|
+
onCCTChange={cct => {
|
|
127
|
+
state.powerMemory.temperature = cct
|
|
128
|
+
}}
|
|
129
|
+
onCCTChangeComplete={async cct => {
|
|
130
|
+
state.powerMemory.temperature = cct
|
|
131
|
+
await setPowerMemory(state.powerMemory)
|
|
132
|
+
}}
|
|
133
|
+
onBrightnessChange={brightness => {
|
|
134
|
+
state.powerMemory.bright = brightness
|
|
135
|
+
}}
|
|
136
|
+
onBrightnessChangeComplete={async brightness => {
|
|
137
|
+
state.powerMemory.bright = brightness
|
|
138
|
+
await setPowerMemory(state.powerMemory)
|
|
139
|
+
}} />
|
|
140
|
+
</View>
|
|
141
|
+
</Card>
|
|
142
|
+
}
|
|
143
|
+
<Spacer />
|
|
144
|
+
{!!params.isSupportDoNotDisturb && <View style={styles.modeSelectGroup}>
|
|
145
|
+
<Spacer height={cx(8)} />
|
|
146
|
+
<View style={{ marginHorizontal: cx(8) }}>
|
|
147
|
+
<Card style={{ borderRadius: cx(4) }}>
|
|
148
|
+
<LdvSwitch
|
|
149
|
+
title={I18n.getLang('light_settings_default_secondbox_text')}
|
|
150
|
+
color={'#fffffff'}
|
|
151
|
+
colorAlpha={1}
|
|
152
|
+
enable={doNotDisturb}
|
|
153
|
+
setEnable={async (enable: boolean) => {
|
|
154
|
+
state.loading = true
|
|
155
|
+
await setDoNotDisturb(enable)
|
|
156
|
+
state.loading = false
|
|
157
|
+
}} />
|
|
158
|
+
</Card>
|
|
159
|
+
</View>
|
|
160
|
+
<Spacer height={cx(8)} />
|
|
161
|
+
<Text
|
|
162
|
+
style={{
|
|
163
|
+
marginHorizontal: cx(8),
|
|
164
|
+
color: '#000',
|
|
165
|
+
fontSize: cx(12),
|
|
166
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
167
|
+
}}>
|
|
168
|
+
{I18n.getLang('groups_settings_power_on_behavior_disturbbox_note')}
|
|
169
|
+
</Text>
|
|
170
|
+
<Spacer height={cx(8)} />
|
|
171
|
+
</View>}
|
|
172
|
+
<Spacer />
|
|
173
|
+
</View>
|
|
174
|
+
</ScrollView>
|
|
175
|
+
</Page>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
interface PowerOnBehaviorModeItemProps extends PropsWithChildren<ViewProps> {
|
|
180
|
+
onPress: () => void
|
|
181
|
+
title: string
|
|
182
|
+
content: string
|
|
183
|
+
enable: boolean
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function PowerOnBehaviorModeItem(props: PowerOnBehaviorModeItemProps) {
|
|
187
|
+
return (
|
|
188
|
+
<TouchableOpacity onPress={props.onPress}>
|
|
189
|
+
<View style={styles.itemRoot}>
|
|
190
|
+
<View style={styles.itemTextGroup}>
|
|
191
|
+
<Text style={styles.itemTitle}>{props.title}</Text>
|
|
192
|
+
<Spacer height={cx(4)} />
|
|
193
|
+
<Text style={styles.itemContent}>{props.content}</Text>
|
|
194
|
+
</View>
|
|
195
|
+
<Image
|
|
196
|
+
source={{ uri: res.ic_check }}
|
|
197
|
+
style={[
|
|
198
|
+
styles.itemCheckedIcon,
|
|
199
|
+
{
|
|
200
|
+
display: props.enable ? 'flex' : 'none',
|
|
201
|
+
},
|
|
202
|
+
]} />
|
|
203
|
+
</View>
|
|
204
|
+
</TouchableOpacity>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const styles = StyleSheet.create({
|
|
209
|
+
root: {
|
|
210
|
+
flex: 1,
|
|
211
|
+
},
|
|
212
|
+
tipText: {
|
|
213
|
+
marginHorizontal: cx(24),
|
|
214
|
+
color: '#000',
|
|
215
|
+
fontSize: cx(14),
|
|
216
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
217
|
+
},
|
|
218
|
+
modeSelectGroup: {
|
|
219
|
+
marginHorizontal: cx(24),
|
|
220
|
+
backgroundColor: '#f6f6f6',
|
|
221
|
+
borderRadius: cx(4),
|
|
222
|
+
},
|
|
223
|
+
modeTip: {
|
|
224
|
+
marginHorizontal: cx(8),
|
|
225
|
+
color: '#000',
|
|
226
|
+
fontSize: cx(14),
|
|
227
|
+
fontWeight: 'bold',
|
|
228
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
229
|
+
},
|
|
230
|
+
modeSelectCard: {
|
|
231
|
+
marginHorizontal: cx(8),
|
|
232
|
+
},
|
|
233
|
+
line: {
|
|
234
|
+
height: cx(1),
|
|
235
|
+
marginHorizontal: cx(12),
|
|
236
|
+
backgroundColor: '#3C3C435B',
|
|
237
|
+
},
|
|
238
|
+
itemRoot: {
|
|
239
|
+
flexDirection: 'row',
|
|
240
|
+
alignItems: 'center',
|
|
241
|
+
paddingHorizontal: cx(12),
|
|
242
|
+
paddingBottom: cx(8),
|
|
243
|
+
},
|
|
244
|
+
itemTextGroup: {
|
|
245
|
+
flex: 1,
|
|
246
|
+
marginEnd: cx(12),
|
|
247
|
+
justifyContent: 'center',
|
|
248
|
+
},
|
|
249
|
+
itemTitle: {
|
|
250
|
+
color: '#000',
|
|
251
|
+
fontSize: cx(14),
|
|
252
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
253
|
+
},
|
|
254
|
+
itemContent: {
|
|
255
|
+
color: '#666',
|
|
256
|
+
fontSize: cx(14),
|
|
257
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
258
|
+
},
|
|
259
|
+
itemCheckedIcon: {
|
|
260
|
+
width: cx(32),
|
|
261
|
+
height: cx(32),
|
|
262
|
+
marginEnd: cx(4),
|
|
263
|
+
},
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
export default LightBehaviorPage
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react'
|
|
2
|
+
import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View, ViewProps } 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 Card from '@ledvance/base/src/components/Card'
|
|
10
|
+
import res from '@ledvance/base/src/res'
|
|
11
|
+
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
12
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
13
|
+
|
|
14
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
15
|
+
|
|
16
|
+
const RELAY_STATUS_OFF = 'off'
|
|
17
|
+
const RELAY_STATUS_ON = 'on'
|
|
18
|
+
const RELAY_STATUS_MEMORY = 'memory'
|
|
19
|
+
|
|
20
|
+
const PlugBehaviorPage = () => {
|
|
21
|
+
const params = useParams<PowerBehaviorPageParams>()
|
|
22
|
+
const deviceInfo = useDeviceInfo()
|
|
23
|
+
const [powerMemory, setPowerMemory] = usePowerBehavior(params.powerBehaviorCode)
|
|
24
|
+
|
|
25
|
+
const state = useReactive({
|
|
26
|
+
powerMemory,
|
|
27
|
+
loading: false,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
useUpdateEffect(() => {
|
|
31
|
+
state.powerMemory = powerMemory
|
|
32
|
+
}, [powerMemory])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Page
|
|
36
|
+
backText={deviceInfo.name}
|
|
37
|
+
headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
|
|
38
|
+
loading={state.loading}>
|
|
39
|
+
<ScrollView style={styles.root} nestedScrollEnabled={true}>
|
|
40
|
+
<Spacer />
|
|
41
|
+
<View style={styles.modeSelectGroup}>
|
|
42
|
+
<Spacer height={cx(8)} />
|
|
43
|
+
<Text style={styles.modeTip}>
|
|
44
|
+
{I18n.getLang('socket_settings_firstbox_topic')}
|
|
45
|
+
</Text>
|
|
46
|
+
<Spacer height={cx(8)} />
|
|
47
|
+
<Card style={styles.modeSelectCard}>
|
|
48
|
+
<Spacer height={cx(12)} />
|
|
49
|
+
<PowerOnBehaviorModeItem
|
|
50
|
+
enable={state.powerMemory === RELAY_STATUS_OFF}
|
|
51
|
+
title={I18n.getLang('feature_summary_action_txt_2')}
|
|
52
|
+
content={I18n.getLang('socket_settings_firstbox_status1_description')}
|
|
53
|
+
onPress={async () => {
|
|
54
|
+
state.powerMemory = RELAY_STATUS_OFF
|
|
55
|
+
await setPowerMemory(state.powerMemory)
|
|
56
|
+
}} />
|
|
57
|
+
<View style={styles.line} />
|
|
58
|
+
<Spacer height={cx(8)} />
|
|
59
|
+
<PowerOnBehaviorModeItem
|
|
60
|
+
enable={state.powerMemory === RELAY_STATUS_ON}
|
|
61
|
+
title={I18n.getLang('feature_summary_action_txt_1')}
|
|
62
|
+
content={I18n.getLang('socket_settings_firstbox_status2_description')}
|
|
63
|
+
onPress={async () => {
|
|
64
|
+
state.powerMemory = RELAY_STATUS_ON
|
|
65
|
+
await setPowerMemory(state.powerMemory)
|
|
66
|
+
}} />
|
|
67
|
+
<View style={styles.line} />
|
|
68
|
+
<Spacer height={cx(8)} />
|
|
69
|
+
<PowerOnBehaviorModeItem
|
|
70
|
+
enable={state.powerMemory === RELAY_STATUS_MEMORY}
|
|
71
|
+
title={I18n.getLang('sockets_specific_settings_relay_status_remember')}
|
|
72
|
+
content={I18n.getLang('socket_settings_firstbox_status3_description')}
|
|
73
|
+
onPress={async () => {
|
|
74
|
+
state.powerMemory = RELAY_STATUS_MEMORY
|
|
75
|
+
await setPowerMemory(state.powerMemory)
|
|
76
|
+
}} />
|
|
77
|
+
<Spacer height={cx(4)} />
|
|
78
|
+
</Card>
|
|
79
|
+
<Spacer height={cx(8)} />
|
|
80
|
+
</View>
|
|
81
|
+
</ScrollView>
|
|
82
|
+
</Page>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface PowerOnBehaviorModeItemProps extends PropsWithChildren<ViewProps> {
|
|
87
|
+
onPress: () => void
|
|
88
|
+
title: string
|
|
89
|
+
content: string
|
|
90
|
+
enable: boolean
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function PowerOnBehaviorModeItem(props: PowerOnBehaviorModeItemProps) {
|
|
94
|
+
return (
|
|
95
|
+
<TouchableOpacity onPress={props.onPress}>
|
|
96
|
+
<View style={styles.itemRoot}>
|
|
97
|
+
<View style={styles.itemTextGroup}>
|
|
98
|
+
<Text style={styles.itemTitle}>{props.title}</Text>
|
|
99
|
+
<Spacer height={cx(4)} />
|
|
100
|
+
<Text style={styles.itemContent}>{props.content}</Text>
|
|
101
|
+
</View>
|
|
102
|
+
<Image
|
|
103
|
+
source={{ uri: res.ic_check }}
|
|
104
|
+
style={[
|
|
105
|
+
styles.itemCheckedIcon,
|
|
106
|
+
{
|
|
107
|
+
display: props.enable ? 'flex' : 'none',
|
|
108
|
+
},
|
|
109
|
+
]} />
|
|
110
|
+
</View>
|
|
111
|
+
</TouchableOpacity>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const styles = StyleSheet.create({
|
|
116
|
+
root: {
|
|
117
|
+
flex: 1,
|
|
118
|
+
},
|
|
119
|
+
tipText: {
|
|
120
|
+
marginHorizontal: cx(24),
|
|
121
|
+
color: '#000',
|
|
122
|
+
fontSize: cx(14),
|
|
123
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
124
|
+
},
|
|
125
|
+
modeSelectGroup: {
|
|
126
|
+
marginHorizontal: cx(24),
|
|
127
|
+
backgroundColor: '#f6f6f6',
|
|
128
|
+
borderRadius: cx(4),
|
|
129
|
+
},
|
|
130
|
+
modeTip: {
|
|
131
|
+
marginHorizontal: cx(8),
|
|
132
|
+
color: '#000',
|
|
133
|
+
fontSize: cx(14),
|
|
134
|
+
fontWeight: 'bold',
|
|
135
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
136
|
+
},
|
|
137
|
+
modeSelectCard: {
|
|
138
|
+
marginHorizontal: cx(8),
|
|
139
|
+
},
|
|
140
|
+
line: {
|
|
141
|
+
height: cx(1),
|
|
142
|
+
marginHorizontal: cx(12),
|
|
143
|
+
backgroundColor: '#3C3C435B',
|
|
144
|
+
},
|
|
145
|
+
itemRoot: {
|
|
146
|
+
flexDirection: 'row',
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
paddingHorizontal: cx(12),
|
|
149
|
+
paddingBottom: cx(8),
|
|
150
|
+
},
|
|
151
|
+
itemTextGroup: {
|
|
152
|
+
flex: 1,
|
|
153
|
+
marginEnd: cx(12),
|
|
154
|
+
justifyContent: 'center',
|
|
155
|
+
},
|
|
156
|
+
itemTitle: {
|
|
157
|
+
color: '#000',
|
|
158
|
+
fontSize: cx(14),
|
|
159
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
160
|
+
},
|
|
161
|
+
itemContent: {
|
|
162
|
+
color: '#666',
|
|
163
|
+
fontSize: cx(14),
|
|
164
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
165
|
+
},
|
|
166
|
+
itemCheckedIcon: {
|
|
167
|
+
width: cx(32),
|
|
168
|
+
height: cx(32),
|
|
169
|
+
marginEnd: cx(4),
|
|
170
|
+
},
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export default PlugBehaviorPage
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
3
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
4
|
+
import { Utils } from 'tuya-panel-kit';
|
|
5
|
+
import { spliceByStep } from "@ledvance/base/src/utils/common";
|
|
6
|
+
import { useUpdateEffect } from 'ahooks';
|
|
7
|
+
|
|
8
|
+
const { hexStringToNumber } = Utils.StringUtils;
|
|
9
|
+
|
|
10
|
+
// plug
|
|
11
|
+
export interface PowerBehaviorPageParams {
|
|
12
|
+
powerBehaviorCode: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type PowerBehaviorType = 'off' | 'on' | 'memory'
|
|
16
|
+
|
|
17
|
+
export const usePowerBehavior = (code: string): [PowerBehaviorType, (v: PowerBehaviorType) => Promise<Result<any>>] => {
|
|
18
|
+
return useDp(code)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// light source
|
|
23
|
+
export interface PowerOffMemoryModel {
|
|
24
|
+
type: number; // 0 => default, 1 => memory, 2 => custom
|
|
25
|
+
hue: number;
|
|
26
|
+
sat: number;
|
|
27
|
+
val: number;
|
|
28
|
+
bright: number;
|
|
29
|
+
temperature: number;
|
|
30
|
+
isColor: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SetPowerOffMemoryResultType = (
|
|
34
|
+
powerOffMemory: PowerOffMemoryModel
|
|
35
|
+
) => Promise<Result<any>>;
|
|
36
|
+
|
|
37
|
+
export function usePowerOffMemory(memoryCode: string): [PowerOffMemoryModel, SetPowerOffMemoryResultType] {
|
|
38
|
+
const [memory, setMemory]: [string, (v: string) => Promise<Result<any>>] = useDp(memoryCode);
|
|
39
|
+
const [powerOffMemoryState, setPowerOffMemoryState] = useState(dp2Obj(memory));
|
|
40
|
+
const setPowerOffMemoryFn = (powerMemory: PowerOffMemoryModel) =>{
|
|
41
|
+
const dpValue = obj2Dp(powerMemory);
|
|
42
|
+
return setMemory(dpValue)
|
|
43
|
+
}
|
|
44
|
+
useUpdateEffect(() => {
|
|
45
|
+
setPowerOffMemoryState(dp2Obj(memory));
|
|
46
|
+
}, [memory]);
|
|
47
|
+
return [powerOffMemoryState, setPowerOffMemoryFn];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
export const useDoNotDisturbControl = (disturbCode: string): [boolean, (v: boolean) => Promise<Result<any>>] => {
|
|
52
|
+
return useDp(disturbCode)
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export function dp2Obj(dp: string): PowerOffMemoryModel {
|
|
57
|
+
if (!dp || dp === '') {
|
|
58
|
+
return {
|
|
59
|
+
type: 0,
|
|
60
|
+
hue: 0,
|
|
61
|
+
sat: 100,
|
|
62
|
+
val: 100,
|
|
63
|
+
bright: 100,
|
|
64
|
+
temperature: 100,
|
|
65
|
+
isColor: false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const dpValueArray = hexStringToNumber(dp);
|
|
69
|
+
const dpStepArray = spliceByStep(dp, 4);
|
|
70
|
+
const hue = parseInt(dpStepArray[1], 16)
|
|
71
|
+
const sat = Math.trunc(parseInt(dpStepArray[2], 16) / 10)
|
|
72
|
+
const val = Math.trunc(parseInt(dpStepArray[3], 16) / 10)
|
|
73
|
+
const bright = Math.trunc(parseInt(dpStepArray[4], 16) / 10)
|
|
74
|
+
const temperature = Math.trunc(parseInt(dpStepArray[5], 16) / 10)
|
|
75
|
+
const isColor = !!(hue || sat || val)
|
|
76
|
+
return {
|
|
77
|
+
type: dpValueArray[1],
|
|
78
|
+
isColor,
|
|
79
|
+
hue: isColor ? hue : 0,
|
|
80
|
+
sat: isColor ? sat : 100,
|
|
81
|
+
val: isColor ? val : 100,
|
|
82
|
+
bright: isColor ? 100 : bright,
|
|
83
|
+
temperature: isColor ? 100 : temperature,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function obj2Dp(obj: PowerOffMemoryModel): string {
|
|
88
|
+
const version = '00';
|
|
89
|
+
if (obj.isColor) {
|
|
90
|
+
obj.bright = 0
|
|
91
|
+
obj.temperature = 0
|
|
92
|
+
} else {
|
|
93
|
+
obj.hue = 0
|
|
94
|
+
obj.sat = 0
|
|
95
|
+
obj.val = 0
|
|
96
|
+
}
|
|
97
|
+
const type = obj.type.toString(16).padStart(2, '0');
|
|
98
|
+
const hueDpValue = obj.hue.toString(16).padStart(4, '0');
|
|
99
|
+
const satDpValue = (obj.sat * 10).toString(16).padStart(4, '0');
|
|
100
|
+
const valDpValue = (obj.val * 10).toString(16).padStart(4, '0');
|
|
101
|
+
const brightnessDpValue = (obj.bright * 10).toString(16).padStart(4, '0');
|
|
102
|
+
const colorTempDpValue = (obj.temperature * 10).toString(16).padStart(4, '0');
|
|
103
|
+
return (
|
|
104
|
+
version + type + hueDpValue + satDpValue + valDpValue + brightnessDpValue + colorTempDpValue
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import PlugBehaviorPage from "./PlugBehaviorPage";
|
|
3
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
4
|
+
|
|
5
|
+
const NewPowerOnBehaviorPageRouters: NavigationRoute[] = [
|
|
6
|
+
{
|
|
7
|
+
name: ui_biz_routerKey.ui_biz_power_behavior_plug,
|
|
8
|
+
component: PlugBehaviorPage,
|
|
9
|
+
options: {
|
|
10
|
+
hideTopbar: true,
|
|
11
|
+
showOfflineView: false,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export default NewPowerOnBehaviorPageRouters
|