@ledvance/group-ui-biz-bundle 1.0.25 → 1.0.27
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/flags/FlagEditPage.tsx +2 -1
- package/src/modules/remoteSwitch/RemoteSwitchAction.ts +10 -0
- package/src/modules/remoteSwitch/RemoteSwitchPage.tsx +69 -0
- package/src/modules/switchGradient/SwitchGradientAction.ts +27 -0
- package/src/modules/switchGradient/SwitchGradientPage.tsx +115 -0
- package/src/modules/timer/TimerAction.ts +16 -8
- package/src/modules/timer/TimerPage.tsx +4 -4
- package/src/navigation/Routers.ts +30 -4
package/package.json
CHANGED
|
@@ -70,7 +70,7 @@ const FlagEditPage = () => {
|
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
72
|
<Page
|
|
73
|
-
backText={I18n.getLang('
|
|
73
|
+
backText={I18n.getLang('Feature_devicepanel_flags')}
|
|
74
74
|
showBackDialog={true}
|
|
75
75
|
loading={state.loading}
|
|
76
76
|
backDialogTitle={
|
|
@@ -272,6 +272,7 @@ const FlagEditPage = () => {
|
|
|
272
272
|
h={state.currentNode.h}
|
|
273
273
|
s={state.currentNode.s}
|
|
274
274
|
v={state.currentNode.v}
|
|
275
|
+
minBrightness={0}
|
|
275
276
|
reserveSV={true}
|
|
276
277
|
onHSVChange={(h, s, v) => {
|
|
277
278
|
if (state.colorPaintBucketSelected) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {useFeatureHook} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
2
|
+
import {Result} from "@ledvance/base/src/models/modules/Result";
|
|
3
|
+
|
|
4
|
+
interface RemoteSwitchConfig {
|
|
5
|
+
remoteSwitch: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useRemoteSwitch(): [boolean, (v: boolean) => Promise<Result<any>>] {
|
|
9
|
+
return useFeatureHook<RemoteSwitchConfig, boolean>('remoteSwitch', false)
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
3
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
4
|
+
import I18n from "@ledvance/base/src/i18n/index";
|
|
5
|
+
import {useDeviceInfo} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
6
|
+
import {useReactive} from "ahooks";
|
|
7
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
8
|
+
import {useRemoteSwitch} from "./RemoteSwitchAction";
|
|
9
|
+
import {View, Text, StyleSheet} from "react-native";
|
|
10
|
+
|
|
11
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
12
|
+
|
|
13
|
+
const RemoteSwitchPage = () => {
|
|
14
|
+
const devInfo = useDeviceInfo()
|
|
15
|
+
const [remoteSwitch, setRemoteSwitch] = useRemoteSwitch()
|
|
16
|
+
const state = useReactive({
|
|
17
|
+
loading: false
|
|
18
|
+
})
|
|
19
|
+
return (<Page
|
|
20
|
+
backText={devInfo.name}
|
|
21
|
+
loading={state.loading}>
|
|
22
|
+
<View style={[styles.titleBGView, styles.shadow]}>
|
|
23
|
+
<Text style={styles.title}>{I18n.getLang('light_sources_specific_settings_remote_control')}</Text>
|
|
24
|
+
<View style={[styles.colorBlock, { backgroundColor: 'red', opacity: 0 }]} />
|
|
25
|
+
<Spacer style={{ flex: 1 }} height={0} width={0} />
|
|
26
|
+
<SwitchButton value={remoteSwitch} onValueChange={async v => {
|
|
27
|
+
state.loading = true
|
|
28
|
+
await setRemoteSwitch(v)
|
|
29
|
+
state.loading = false
|
|
30
|
+
} } />
|
|
31
|
+
</View>
|
|
32
|
+
</Page>)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
titleBGView: {
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
paddingHorizontal: cx(16),
|
|
40
|
+
marginHorizontal: cx(24),
|
|
41
|
+
marginTop: cx(30),
|
|
42
|
+
},
|
|
43
|
+
colorBlock: {
|
|
44
|
+
width: cx(20),
|
|
45
|
+
height: cx(20),
|
|
46
|
+
marginStart: cx(12),
|
|
47
|
+
borderRadius: cx(4),
|
|
48
|
+
},
|
|
49
|
+
title: {
|
|
50
|
+
color: '#000',
|
|
51
|
+
fontSize: cx(14),
|
|
52
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
53
|
+
paddingVertical: cx(16),
|
|
54
|
+
},
|
|
55
|
+
shadow: {
|
|
56
|
+
shadowColor: '#000000',
|
|
57
|
+
shadowOpacity: 0.2,
|
|
58
|
+
shadowRadius: 8,
|
|
59
|
+
elevation:8,
|
|
60
|
+
shadowOffset: {
|
|
61
|
+
width: 0,
|
|
62
|
+
height: 4,
|
|
63
|
+
},
|
|
64
|
+
backgroundColor: '#fff',
|
|
65
|
+
borderRadius: 8,
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
export default RemoteSwitchPage
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {useFeatureHook} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
2
|
+
import {Result} from "@ledvance/base/src/models/modules/Result";
|
|
3
|
+
import {useCallback} from "react";
|
|
4
|
+
|
|
5
|
+
interface SwitchGradientConfig {
|
|
6
|
+
switchGradient: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useSwitchGradient(): [number, number, (onDuration: number, offDuration: number) => Promise<Result<any>>] {
|
|
10
|
+
const [config, setConfig] = useFeatureHook<SwitchGradientConfig, string>('switchGradient', '00000000000000')
|
|
11
|
+
const sgHexFixed = !!config && config.length == 14 ? config : '00000000000000'
|
|
12
|
+
const versionHex = sgHexFixed.substring(0, 2)
|
|
13
|
+
const switchOnDuration = parseInt(sgHexFixed.substring(2, 8), 16)
|
|
14
|
+
const switchOffDuration = parseInt(sgHexFixed.substring(8), 16)
|
|
15
|
+
const setSwitchGradient = useCallback(async (onDuration: number, offDuration: number) => {
|
|
16
|
+
const switchOnDurationHex = (onDuration * 1000).toString(16).padStart(6, '0')
|
|
17
|
+
const switchOffDurationHex = (offDuration * 1000).toString(16).padStart(6, '0')
|
|
18
|
+
const sgHex = `${versionHex}${switchOnDurationHex}${switchOffDurationHex}`
|
|
19
|
+
return await setConfig(sgHex)
|
|
20
|
+
}, [setConfig])
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
switchOnDuration <= 0 ? 0 : switchOnDuration / 1000,
|
|
24
|
+
switchOffDuration <= 0 ? 0 : switchOffDuration / 1000,
|
|
25
|
+
setSwitchGradient,
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {useReactive, useUpdateEffect} from "ahooks";
|
|
2
|
+
import {useSwitchGradient} from "./SwitchGradientAction";
|
|
3
|
+
import { useNavigation } from '@react-navigation/native'
|
|
4
|
+
import {useDeviceInfo} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
5
|
+
import {Utils} from "tuya-panel-kit";
|
|
6
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
7
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
8
|
+
import res from "@ledvance/base/src/res";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import {View, Text, StyleSheet} from "react-native";
|
|
11
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
12
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
13
|
+
import Stepper from '@ledvance/base/src/components/Stepper'
|
|
14
|
+
|
|
15
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
16
|
+
|
|
17
|
+
const SwitchGradientPage = () => {
|
|
18
|
+
const devInfo = useDeviceInfo()
|
|
19
|
+
const navigation = useNavigation()
|
|
20
|
+
const [
|
|
21
|
+
switchOnDuration,
|
|
22
|
+
switchOffDuration,
|
|
23
|
+
setSwitchGradient,
|
|
24
|
+
] = useSwitchGradient()
|
|
25
|
+
|
|
26
|
+
const state = useReactive({
|
|
27
|
+
loading: false,
|
|
28
|
+
switchOnDuration,
|
|
29
|
+
switchOffDuration,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
useUpdateEffect(() => {
|
|
33
|
+
state.switchOnDuration = switchOnDuration
|
|
34
|
+
state.switchOffDuration = switchOffDuration
|
|
35
|
+
}, [switchOnDuration, switchOffDuration])
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Page
|
|
39
|
+
backText={devInfo.name}
|
|
40
|
+
headlineText={I18n.getLang('matter_gradient_overview_headline_text')}
|
|
41
|
+
rightButtonIcon={res.ic_check}
|
|
42
|
+
rightButtonIconClick={async () => {
|
|
43
|
+
state.loading = true
|
|
44
|
+
const res = await setSwitchGradient(state.switchOnDuration, state.switchOffDuration)
|
|
45
|
+
state.loading = false
|
|
46
|
+
console.log(res)
|
|
47
|
+
navigation.goBack()
|
|
48
|
+
}}
|
|
49
|
+
loading={state.loading}>
|
|
50
|
+
<View>
|
|
51
|
+
<Card style={styles.stepCard}>
|
|
52
|
+
<Spacer height={cx(16)}/>
|
|
53
|
+
<Text style={styles.stepTitle}>{I18n.getLang('matter_gradient_light_on_description_text')}</Text>
|
|
54
|
+
<Spacer height={cx(10)}/>
|
|
55
|
+
<View style={styles.stepGroup}>
|
|
56
|
+
<Text style={styles.stepText}>{I18n.getLang('matter_gradient_light_on_title')}</Text>
|
|
57
|
+
<Stepper
|
|
58
|
+
value={state.switchOnDuration}
|
|
59
|
+
min={0}
|
|
60
|
+
max={60}
|
|
61
|
+
stepValue={0.2}
|
|
62
|
+
editable={true}
|
|
63
|
+
isRealTime={true}
|
|
64
|
+
onValueChange={v => {
|
|
65
|
+
state.switchOnDuration = v
|
|
66
|
+
}}/>
|
|
67
|
+
</View>
|
|
68
|
+
<Spacer height={cx(16)}/>
|
|
69
|
+
</Card>
|
|
70
|
+
<Spacer/>
|
|
71
|
+
<Card style={styles.stepCard}>
|
|
72
|
+
<Spacer height={cx(16)}/>
|
|
73
|
+
<Text style={styles.stepTitle}>{I18n.getLang('matter_gradient_light_off_description_text')}</Text>
|
|
74
|
+
<Spacer height={cx(10)}/>
|
|
75
|
+
<View style={styles.stepGroup}>
|
|
76
|
+
<Text style={styles.stepText}>{I18n.getLang('matter_gradient_light_off_title')}</Text>
|
|
77
|
+
<Stepper
|
|
78
|
+
value={state.switchOffDuration}
|
|
79
|
+
min={0}
|
|
80
|
+
max={60}
|
|
81
|
+
stepValue={0.2}
|
|
82
|
+
editable={true}
|
|
83
|
+
isRealTime={true}
|
|
84
|
+
onValueChange={v => {
|
|
85
|
+
state.switchOffDuration = v
|
|
86
|
+
}}/>
|
|
87
|
+
</View>
|
|
88
|
+
<Spacer height={cx(16)}/>
|
|
89
|
+
</Card>
|
|
90
|
+
</View>
|
|
91
|
+
</Page>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const styles = StyleSheet.create({
|
|
96
|
+
stepCard: {
|
|
97
|
+
marginHorizontal: cx(24),
|
|
98
|
+
paddingHorizontal: cx(16),
|
|
99
|
+
},
|
|
100
|
+
stepTitle: {
|
|
101
|
+
color: '#000',
|
|
102
|
+
fontSize: cx(14),
|
|
103
|
+
},
|
|
104
|
+
stepGroup: {
|
|
105
|
+
flexDirection: 'row',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
},
|
|
108
|
+
stepText: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
color: '#000',
|
|
111
|
+
fontSize: cx(16),
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
export default SwitchGradientPage
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {useFeatureHook} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
2
|
+
import {Result} from '@ledvance/base/src/models/modules/Result'
|
|
3
3
|
import dayjs from 'dayjs'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import {useCountDown, useReactive} from 'ahooks'
|
|
5
|
+
import {useEffect, useMemo} from 'react'
|
|
6
|
+
import {I18nKey} from "../../../.yalc/@ledvance/base/src/i18n/index";
|
|
6
7
|
|
|
7
8
|
export interface TimerTask {
|
|
8
9
|
name: string
|
|
@@ -15,8 +16,8 @@ export interface TimerTask {
|
|
|
15
16
|
enable: boolean
|
|
16
17
|
}
|
|
17
18
|
status: TaskStatus
|
|
18
|
-
stringOn:
|
|
19
|
-
stringOff:
|
|
19
|
+
stringOn: I18nKey
|
|
20
|
+
stringOff: I18nKey
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export enum TaskStatus {
|
|
@@ -154,14 +155,21 @@ export interface TimerSettableDp {
|
|
|
154
155
|
code: string
|
|
155
156
|
enable: boolean
|
|
156
157
|
}
|
|
157
|
-
stringOn:
|
|
158
|
-
stringOff:
|
|
158
|
+
stringOn: I18nKey
|
|
159
|
+
stringOff: I18nKey
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
export interface TimerPageParams {
|
|
162
163
|
timerSettableDps: TimerSettableDp[]
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
export function timeFormatToRealTime(mCountdown: number) {
|
|
167
|
+
const date = new Date()
|
|
168
|
+
const now = date.getTime()
|
|
169
|
+
const after = new Date(now + mCountdown * 1000)
|
|
170
|
+
return `${after.getHours()}:${after.getMinutes().toString().padStart(2, '0')}`
|
|
171
|
+
}
|
|
172
|
+
|
|
165
173
|
export function timeFormat(time: number): string {
|
|
166
174
|
let hour = Math.trunc(time / 3600)
|
|
167
175
|
const beforeMin = (time % 3600) / 60
|
|
@@ -8,7 +8,7 @@ import LdvPickerView from '@ledvance/base/src/components/ldvPickerView'
|
|
|
8
8
|
import { useReactive } from 'ahooks'
|
|
9
9
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
10
10
|
import DeleteButton from '@ledvance/base/src/components/DeleteButton'
|
|
11
|
-
import {
|
|
11
|
+
import {TaskStatus, timeFormat, timeFormatToRealTime, TimerPageParams, TimerTask, useTimerTasks} from './TimerAction'
|
|
12
12
|
import { cloneDeep, groupBy } from 'lodash'
|
|
13
13
|
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
14
14
|
import GroupBizRes from '../../res/GroupBizRes'
|
|
@@ -188,7 +188,7 @@ const TimerPage = () => {
|
|
|
188
188
|
</View>
|
|
189
189
|
<Spacer height={cx(32)}/>
|
|
190
190
|
<Text
|
|
191
|
-
style={[styles.activeTaskDesc, { textAlign: 'center' }]}>{I18n.formatValue(startedTasks[0].dp.enable ? startedTasks[0].stringOff : startedTasks[0].stringOn,
|
|
191
|
+
style={[styles.activeTaskDesc, { textAlign: 'center' }]}>{I18n.formatValue(startedTasks[0].dp.enable ? startedTasks[0].stringOff : startedTasks[0].stringOn, timeFormatToRealTime(startedTasks[0].timeLeft))}</Text>
|
|
192
192
|
<Spacer height={cx(32)}/>
|
|
193
193
|
<TextButton
|
|
194
194
|
text={I18n.getLang('auto_scan_system_cancel')}
|
|
@@ -241,7 +241,7 @@ function ActiveTimerItem(task: TimerTask, onCancel: () => void) {
|
|
|
241
241
|
<Spacer/>
|
|
242
242
|
<View style={{ marginHorizontal: cx(20) }}>
|
|
243
243
|
<Text style={styles.activeTaskDesc}>{
|
|
244
|
-
I18n.formatValue(task.dp.enable ? task.stringOff : task.stringOn,
|
|
244
|
+
I18n.formatValue(task.dp.enable ? task.stringOff : task.stringOn, timeFormatToRealTime(task.timeLeft))
|
|
245
245
|
}</Text>
|
|
246
246
|
</View>
|
|
247
247
|
<Spacer height={cx(22)}/>
|
|
@@ -339,7 +339,7 @@ const styles = StyleSheet.create({
|
|
|
339
339
|
fontSize: cx(14),
|
|
340
340
|
},
|
|
341
341
|
activeTasBtn: {
|
|
342
|
-
width:
|
|
342
|
+
width: 'auto',
|
|
343
343
|
height: cx(36),
|
|
344
344
|
padding: 0,
|
|
345
345
|
backgroundColor: '#666',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {NavigationRoute, TransitionPresets} from 'tuya-panel-kit'
|
|
2
2
|
import TimerPage from '../modules/timer/TimerPage'
|
|
3
3
|
import TimeSchedulePage from '../modules/time_schedule/TimeSchedulePage'
|
|
4
4
|
import TimeScheduleDetailPage from '../modules/time_schedule/TimeScheduleDetailPage'
|
|
@@ -9,6 +9,8 @@ import StaticMoodEditorPage from '../modules/mood/StaticMoodEditorPage'
|
|
|
9
9
|
import SelectPage from '../modules/select/SelectPage'
|
|
10
10
|
import FlagPage from '../modules/flags/FlagPage'
|
|
11
11
|
import FlagEditPage from '../modules/flags/FlagEditPage'
|
|
12
|
+
import RemoteSwitchPage from "../modules/remoteSwitch/RemoteSwitchPage";
|
|
13
|
+
import SwitchGradientPage from "../modules/switchGradient/SwitchGradientPage";
|
|
12
14
|
|
|
13
15
|
export const ui_biz_routerKey = {
|
|
14
16
|
'group_ui_biz_timer': 'group_ui_biz_timer',
|
|
@@ -20,7 +22,9 @@ export const ui_biz_routerKey = {
|
|
|
20
22
|
'group_ui_biz_dynamic_mood_edit': 'group_ui_biz_dynamic_mood_edit',
|
|
21
23
|
'group_ui_biz_select_page': 'group_ui_biz_select_page',
|
|
22
24
|
'group_ui_biz_flag_page': 'group_ui_biz_flag_page',
|
|
23
|
-
'group_ui_biz_flag_page_edit': 'group_ui_biz_flag_page_edit'
|
|
25
|
+
'group_ui_biz_flag_page_edit': 'group_ui_biz_flag_page_edit',
|
|
26
|
+
'group_ui_biz_remote_switch': 'group_ui_biz_remote_switch',
|
|
27
|
+
'group_ui_biz_switch_gradient': 'group_ui_biz_switch_gradient',
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export const TimerRouters: NavigationRoute[] = [
|
|
@@ -78,7 +82,7 @@ export const MoodRouters: NavigationRoute[] = [
|
|
|
78
82
|
showOfflineView: false,
|
|
79
83
|
},
|
|
80
84
|
},
|
|
81
|
-
{
|
|
85
|
+
{
|
|
82
86
|
name: ui_biz_routerKey.group_ui_biz_dynamic_mood_edit,
|
|
83
87
|
component: DynamicMoodEditorPage,
|
|
84
88
|
options: {
|
|
@@ -117,4 +121,26 @@ export const FlagPageRouters: NavigationRoute[] = [
|
|
|
117
121
|
showOfflineView: false,
|
|
118
122
|
}
|
|
119
123
|
},
|
|
120
|
-
]
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
export const RemoteSwitchRouters: NavigationRoute[] = [
|
|
127
|
+
{
|
|
128
|
+
name: ui_biz_routerKey.group_ui_biz_remote_switch,
|
|
129
|
+
component: RemoteSwitchPage,
|
|
130
|
+
options: {
|
|
131
|
+
hideTopbar: true,
|
|
132
|
+
showOfflineView: false,
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
export const SwitchGradientRouters: NavigationRoute[] = [
|
|
138
|
+
{
|
|
139
|
+
name: ui_biz_routerKey.group_ui_biz_switch_gradient,
|
|
140
|
+
component: SwitchGradientPage,
|
|
141
|
+
options: {
|
|
142
|
+
hideTopbar: true,
|
|
143
|
+
showOfflineView: false,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
]
|