@ledvance/ui-biz-bundle 1.1.72 → 1.1.74
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/timer/TimerPage.tsx +2 -0
- package/src/modules/timer/TimerPageAction.ts +1 -1
- package/src/navigation/Routers.ts +2 -1
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +2 -2
- package/src/newModules/switchGradient/Routers.ts +16 -0
- package/src/newModules/switchGradient/SwitchGradientActions.ts +26 -0
- package/src/newModules/switchGradient/SwitchGradientPage.tsx +124 -0
package/package.json
CHANGED
|
@@ -43,5 +43,6 @@ export const ui_biz_routerKey = {
|
|
|
43
43
|
'ui_biz_light_mode': 'ui_biz_light_mode',
|
|
44
44
|
'ui_biz_overcharge_switch': 'ui_biz_overcharge_switch',
|
|
45
45
|
'ui_biz_child_lock': 'ui_biz_child_lock',
|
|
46
|
-
'ui_biz_remote_control': 'ui_biz_remote_control'
|
|
46
|
+
'ui_biz_remote_control': 'ui_biz_remote_control',
|
|
47
|
+
'ui_biz_switch_gradient': 'ui_biz_switch_gradient'
|
|
47
48
|
}
|
|
@@ -268,12 +268,12 @@ const FixedTimeDetailPage = () => {
|
|
|
268
268
|
<View style={{ flexDirection: 'column' }}>
|
|
269
269
|
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_4', `${Math.trunc(state.fixedTime.openTime / 60)}`, `${state.fixedTime.openTime % 60}`)}</Text>
|
|
270
270
|
<View style={styles.summaryTag}>
|
|
271
|
-
<Text style={{ color: '#000' }}>{
|
|
271
|
+
<Text style={{ color: '#000' }}>{params.applyForList[params.isPlug ? (state.fixedTime.channel ?? 0) : 0]?.key}</Text>
|
|
272
272
|
</View>
|
|
273
273
|
<Spacer height={cx(5)} />
|
|
274
274
|
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_6', `${Math.trunc(state.fixedTime.closeTime / 60)}`, `${state.fixedTime.closeTime % 60}`)}</Text>
|
|
275
275
|
<View style={styles.summaryTag}>
|
|
276
|
-
<Text style={{ color: '#000' }}>{
|
|
276
|
+
<Text style={{ color: '#000' }}>{params.applyForList[params.isPlug ? (state.fixedTime.channel ?? 0) : 0]?.key}</Text>
|
|
277
277
|
</View>
|
|
278
278
|
</View>
|
|
279
279
|
)}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import SwitchGradientPage from "./SwitchGradientPage";
|
|
3
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
4
|
+
|
|
5
|
+
const SwitchGradientPagePageRouters: NavigationRoute[] = [
|
|
6
|
+
{
|
|
7
|
+
name: ui_biz_routerKey.ui_biz_switch_gradient,
|
|
8
|
+
component: SwitchGradientPage,
|
|
9
|
+
options:{
|
|
10
|
+
hideTopbar: true,
|
|
11
|
+
showOfflineView: false,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export default SwitchGradientPagePageRouters
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
2
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
3
|
+
import { useCallback } from "react"
|
|
4
|
+
|
|
5
|
+
export function useSwitchGradient(dpCode: string): [number, number, (onDuration: number, offDuration: number) => Promise<Result<any>>] {
|
|
6
|
+
const [sgHex, setSgHex] = useDp<string, any>(dpCode)
|
|
7
|
+
|
|
8
|
+
const sgHexFixed = !!sgHex && sgHex.length == 14 ? sgHex : '00000000000000'
|
|
9
|
+
|
|
10
|
+
const versionHex = sgHexFixed.substring(0, 2)
|
|
11
|
+
|
|
12
|
+
const switchOnDuration = parseInt(sgHexFixed.substring(2, 8), 16)
|
|
13
|
+
const switchOffDuration = parseInt(sgHexFixed.substring(8), 16)
|
|
14
|
+
const setSwitchGradient = useCallback(async (onDuration: number, offDuration: number) => {
|
|
15
|
+
const switchOnDurationHex = (onDuration * 1000).toString(16).padStart(6, '0')
|
|
16
|
+
const switchOffDurationHex = (offDuration * 1000).toString(16).padStart(6, '0')
|
|
17
|
+
const sgHex = `${versionHex}${switchOnDurationHex}${switchOffDurationHex}`
|
|
18
|
+
return await setSgHex(sgHex)
|
|
19
|
+
}, [setSgHex])
|
|
20
|
+
|
|
21
|
+
return [
|
|
22
|
+
switchOnDuration <= 0 ? 0 : switchOnDuration / 1000,
|
|
23
|
+
switchOffDuration <= 0 ? 0 : switchOffDuration / 1000,
|
|
24
|
+
setSwitchGradient,
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import Page from '@ledvance/base/src/components/Page'
|
|
2
|
+
import {useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import res from '@ledvance/base/src/res'
|
|
5
|
+
import {useSwitchGradient} from './SwitchGradientActions'
|
|
6
|
+
import {StyleSheet, Text, View} from 'react-native'
|
|
7
|
+
import {useReactive, useUpdateEffect} from 'ahooks'
|
|
8
|
+
import { Utils} from 'tuya-panel-kit'
|
|
9
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
10
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
11
|
+
import {useNavigation} from '@react-navigation/core'
|
|
12
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
13
|
+
import Stepper from '@ledvance/base/src/components/Stepper'
|
|
14
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
15
|
+
|
|
16
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
17
|
+
|
|
18
|
+
export interface SwitchGradientPageParams {
|
|
19
|
+
switchGradientDpCode: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SwitchGradientPage = () => {
|
|
23
|
+
const devInfo = useDeviceInfo()
|
|
24
|
+
const navigation = useNavigation()
|
|
25
|
+
const params = useParams<SwitchGradientPageParams>()
|
|
26
|
+
const [
|
|
27
|
+
switchOnDuration,
|
|
28
|
+
switchOffDuration,
|
|
29
|
+
setSwitchGradient,
|
|
30
|
+
] = useSwitchGradient(params.switchGradientDpCode)
|
|
31
|
+
|
|
32
|
+
const state = useReactive({
|
|
33
|
+
loading: false,
|
|
34
|
+
switchOnDuration,
|
|
35
|
+
switchOffDuration,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
useUpdateEffect(() => {
|
|
39
|
+
state.switchOnDuration = switchOnDuration
|
|
40
|
+
state.switchOffDuration = switchOffDuration
|
|
41
|
+
|
|
42
|
+
}, [switchOnDuration, switchOffDuration])
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Page
|
|
46
|
+
backText={devInfo.name}
|
|
47
|
+
headlineText={I18n.getLang('matter_gradient_overview_headline_text')}
|
|
48
|
+
rightButtonIcon={res.ic_check}
|
|
49
|
+
rightButtonIconClick={async () => {
|
|
50
|
+
state.loading = true
|
|
51
|
+
const res = await setSwitchGradient(state.switchOnDuration, state.switchOffDuration)
|
|
52
|
+
state.loading = false
|
|
53
|
+
console.log(res)
|
|
54
|
+
navigation.goBack()
|
|
55
|
+
}}
|
|
56
|
+
loading={state.loading}>
|
|
57
|
+
<View>
|
|
58
|
+
<Card style={styles.stepCard}>
|
|
59
|
+
<Spacer height={cx(16)}/>
|
|
60
|
+
<Text style={styles.stepTitle}>{I18n.getLang('matter_gradient_light_on_description_text')}</Text>
|
|
61
|
+
<Spacer height={cx(10)}/>
|
|
62
|
+
<View style={styles.stepGroup}>
|
|
63
|
+
<Text style={styles.stepText}>{I18n.getLang('matter_gradient_light_on_title')}</Text>
|
|
64
|
+
<Stepper
|
|
65
|
+
value={state.switchOnDuration}
|
|
66
|
+
min={0}
|
|
67
|
+
max={60}
|
|
68
|
+
stepValue={0.2}
|
|
69
|
+
precision={1}
|
|
70
|
+
editable={true}
|
|
71
|
+
isRealTime={true}
|
|
72
|
+
onValueChange={v => {
|
|
73
|
+
state.switchOnDuration = v
|
|
74
|
+
}}/>
|
|
75
|
+
</View>
|
|
76
|
+
<Spacer height={cx(16)}/>
|
|
77
|
+
</Card>
|
|
78
|
+
<Spacer/>
|
|
79
|
+
<Card style={styles.stepCard}>
|
|
80
|
+
<Spacer height={cx(16)}/>
|
|
81
|
+
<Text style={styles.stepTitle}>{I18n.getLang('matter_gradient_light_off_description_text')}</Text>
|
|
82
|
+
<Spacer height={cx(10)}/>
|
|
83
|
+
<View style={styles.stepGroup}>
|
|
84
|
+
<Text style={styles.stepText}>{I18n.getLang('matter_gradient_light_off_title')}</Text>
|
|
85
|
+
<Stepper
|
|
86
|
+
value={state.switchOffDuration}
|
|
87
|
+
min={0}
|
|
88
|
+
max={60}
|
|
89
|
+
stepValue={0.2}
|
|
90
|
+
precision={1}
|
|
91
|
+
editable={true}
|
|
92
|
+
isRealTime={true}
|
|
93
|
+
onValueChange={v => {
|
|
94
|
+
state.switchOffDuration = v
|
|
95
|
+
}}/>
|
|
96
|
+
</View>
|
|
97
|
+
<Spacer height={cx(16)}/>
|
|
98
|
+
</Card>
|
|
99
|
+
</View>
|
|
100
|
+
</Page>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const styles = StyleSheet.create({
|
|
105
|
+
stepCard: {
|
|
106
|
+
marginHorizontal: cx(24),
|
|
107
|
+
paddingHorizontal: cx(16),
|
|
108
|
+
},
|
|
109
|
+
stepTitle: {
|
|
110
|
+
color: '#000',
|
|
111
|
+
fontSize: cx(14),
|
|
112
|
+
},
|
|
113
|
+
stepGroup: {
|
|
114
|
+
flexDirection: 'row',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
},
|
|
117
|
+
stepText: {
|
|
118
|
+
flex: 1,
|
|
119
|
+
color: '#000',
|
|
120
|
+
fontSize: cx(16),
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
export default SwitchGradientPage
|