@ledvance/ui-biz-bundle 1.1.73 → 1.1.75

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.73",
7
+ "version": "1.1.75",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -138,5 +138,5 @@ export function timeFormat(time: number): string {
138
138
  hour += 1
139
139
  min = 0
140
140
  }
141
- return `${hour > 0 ? `${hour} h ` : ''}${min > 0 ? `${min} min` : ''}`
141
+ return `${hour > 0 ? `${hour} h ` : ''}${min > 0 ? `${min}` : ''}`
142
142
  }
@@ -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
  }
@@ -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