@ledvance/base 1.2.81 → 1.2.83
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/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/localazy.json +848 -848
- package/localazy.keys.json +4 -4
- package/package.json +74 -74
- package/rn-cli.config.js +8 -8
- package/src/api/native.d.ts +71 -71
- package/src/api/native.ts +423 -423
- package/src/api/nativeEventEmitter.d.ts +3 -3
- package/src/api/nativeEventEmitter.ts +125 -125
- package/src/components/AdvanceCard.d.ts +25 -25
- package/src/components/AdvanceCard.tsx +117 -117
- package/src/components/AdvanceList.d.ts +9 -9
- package/src/components/AdvanceList.tsx +69 -69
- package/src/components/ApplyForDeviceItem.d.ts +6 -6
- package/src/components/ApplyForDeviceItem.tsx +83 -83
- package/src/components/ApplyForDeviceList.d.ts +7 -7
- package/src/components/ApplyForDeviceList.tsx +61 -61
- package/src/components/ApplyForText.d.ts +6 -6
- package/src/components/ApplyForText.tsx +52 -52
- package/src/components/Card.d.ts +10 -10
- package/src/components/Card.tsx +40 -40
- package/src/components/Cell.d.ts +21 -21
- package/src/components/Cell.tsx +69 -69
- package/src/components/CircularProgress.d.ts +8 -8
- package/src/components/CircularProgress.tsx +42 -42
- package/src/components/ColorAdjustView.d.ts +12 -12
- package/src/components/ColorAdjustView.tsx +64 -64
- package/src/components/ColorExtractor.d.ts +73 -73
- package/src/components/ColorExtractor.tsx +374 -374
- package/src/components/ColorTempAdjustView.d.ts +13 -13
- package/src/components/ColorTempAdjustView.tsx +57 -57
- package/src/components/ColorsLine.d.ts +7 -7
- package/src/components/ColorsLine.tsx +47 -47
- package/src/components/CustomListDialog.d.ts +15 -15
- package/src/components/CustomListDialog.tsx +66 -65
- package/src/components/DeleteButton.d.ts +10 -10
- package/src/components/DeleteButton.tsx +40 -40
- package/src/components/Dialog.d.ts +10 -10
- package/src/components/Dialog.tsx +38 -38
- package/src/components/DrawToolView.d.ts +46 -46
- package/src/components/DrawToolView.tsx +262 -262
- package/src/components/FanAdjustView.d.ts +23 -23
- package/src/components/FanAdjustView.tsx +141 -141
- package/src/components/InfoText.d.ts +11 -11
- package/src/components/InfoText.tsx +45 -45
- package/src/components/LampAdjustView.d.ts +10 -10
- package/src/components/LampAdjustView.tsx +75 -75
- package/src/components/LampAdjustView2.d.ts +24 -24
- package/src/components/LampAdjustView2.tsx +104 -104
- package/src/components/LinearGradientLine.d.ts +9 -9
- package/src/components/LinearGradientLine.tsx +63 -63
- package/src/components/LoadingView.tsx +39 -39
- package/src/components/MoodColorsLine.d.ts +9 -9
- package/src/components/MoodColorsLine.tsx +38 -38
- package/src/components/Page.d.ts +21 -21
- package/src/components/Page.tsx +104 -104
- package/src/components/Popup.d.ts +7 -7
- package/src/components/Popup.tsx +71 -71
- package/src/components/Segmented.d.ts +14 -14
- package/src/components/Segmented.tsx +76 -76
- package/src/components/ShowSelect.d.ts +1 -1
- package/src/components/ShowSelect.tsx +158 -158
- package/src/components/SocketItem.d.ts +13 -13
- package/src/components/SocketItem.tsx +87 -87
- package/src/components/Spacer.d.ts +7 -7
- package/src/components/Spacer.tsx +13 -13
- package/src/components/Stepper.d.ts +19 -19
- package/src/components/Stepper.tsx +130 -130
- package/src/components/StripAdjustView.d.ts +16 -16
- package/src/components/StripAdjustView.tsx +129 -129
- package/src/components/StripLightView.d.ts +14 -14
- package/src/components/StripLightView.tsx +24 -24
- package/src/components/Summary.tsx +116 -124
- package/src/components/Tag.d.ts +8 -8
- package/src/components/Tag.tsx +56 -56
- package/src/components/TextButton.d.ts +9 -9
- package/src/components/TextButton.tsx +31 -31
- package/src/components/TextField.d.ts +9 -9
- package/src/components/TextField.tsx +92 -92
- package/src/components/TextFieldStyleButton.d.ts +8 -8
- package/src/components/TextFieldStyleButton.tsx +85 -85
- package/src/components/UATabTitle.d.ts +6 -6
- package/src/components/UATabTitle.tsx +31 -31
- package/src/components/UATabs.d.ts +12 -12
- package/src/components/UATabs.tsx +77 -77
- package/src/components/connect.d.ts +10 -10
- package/src/components/connect.tsx +20 -20
- package/src/components/ldvColorBrightness.d.ts +1 -1
- package/src/components/ldvColorBrightness.tsx +18 -18
- package/src/components/ldvColorSlider.d.ts +14 -14
- package/src/components/ldvColorSlider.tsx +131 -131
- package/src/components/ldvItemView.d.ts +12 -12
- package/src/components/ldvItemView.tsx +43 -43
- package/src/components/ldvPickerView.d.ts +13 -13
- package/src/components/ldvPickerView.tsx +97 -97
- package/src/components/ldvPresetView.d.ts +2 -2
- package/src/components/ldvPresetView.tsx +86 -86
- package/src/components/ldvSaturation.d.ts +2 -2
- package/src/components/ldvSaturation.tsx +22 -22
- package/src/components/ldvSlider.d.ts +15 -15
- package/src/components/ldvSlider.tsx +103 -103
- package/src/components/ldvSwitch.d.ts +10 -10
- package/src/components/ldvSwitch.tsx +52 -52
- package/src/components/ldvTemperatureSlider.d.ts +13 -13
- package/src/components/ldvTemperatureSlider.tsx +139 -139
- package/src/components/ldvTopBar.d.ts +10 -10
- package/src/components/ldvTopBar.tsx +76 -76
- package/src/components/ldvTopName.d.ts +9 -9
- package/src/components/ldvTopName.tsx +63 -63
- package/src/components/segmentControl.d.ts +1 -1
- package/src/components/segmentControl.tsx +65 -65
- package/src/components/weekSelect.d.ts +7 -7
- package/src/components/weekSelect.tsx +98 -98
- package/src/composeLayout.d.ts +30 -30
- package/src/composeLayout.tsx +261 -261
- package/src/config/dark-theme.ts +61 -61
- package/src/config/light-theme.ts +61 -61
- package/src/hooks/Hooks.d.ts +2 -2
- package/src/hooks/Hooks.ts +8 -8
- package/src/i18n/index.d.ts +16 -16
- package/src/i18n/index.ts +37 -37
- package/src/i18n/strings.d.ts +15953 -15953
- package/src/i18n/strings.ts +23723 -23723
- package/src/main.tsx +9 -9
- package/src/models/GlobalParams.d.ts +14 -14
- package/src/models/GlobalParams.ts +14 -14
- package/src/models/TuyaApi.d.ts +29 -29
- package/src/models/TuyaApi.ts +92 -92
- package/src/models/combine.d.ts +26 -26
- package/src/models/combine.ts +17 -17
- package/src/models/configureStore.d.ts +9 -9
- package/src/models/configureStore.ts +33 -33
- package/src/models/index.d.ts +31 -31
- package/src/models/index.ts +22 -22
- package/src/models/modules/NativePropsSlice.d.ts +61 -61
- package/src/models/modules/NativePropsSlice.tsx +467 -467
- package/src/models/modules/Result.d.ts +14 -14
- package/src/models/modules/Result.ts +15 -15
- package/src/models/modules/common.d.ts +44 -44
- package/src/models/modules/common.ts +161 -161
- package/src/res/index.d.ts +70 -70
- package/src/res/index.ts +73 -73
- package/src/utils/ColorParser.d.ts +66 -66
- package/src/utils/ColorParser.ts +189 -189
- package/src/utils/ColorUtils.d.ts +71 -71
- package/src/utils/ColorUtils.tsx +448 -448
- package/src/utils/Support.d.ts +13 -13
- package/src/utils/Support.ts +108 -108
- package/src/utils/TypeUtils.d.ts +3 -3
- package/src/utils/cctUtils.d.ts +1 -1
- package/src/utils/cctUtils.ts +110 -110
- package/src/utils/common.d.ts +35 -35
- package/src/utils/common.ts +379 -379
- package/src/utils/index.d.ts +26 -26
- package/src/utils/index.ts +191 -191
- package/src/utils/interface.d.ts +6 -6
- package/src/utils/interface.ts +50 -11
- package/src/utils/loopsCompare.d.ts +1 -1
- package/src/utils/loopsCompare.ts +62 -62
- package/tsconfig.json +50 -50
- package/update-localazy.py +52 -52
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { ViewProps } from 'react-native';
|
|
3
|
-
export declare type Node = {
|
|
4
|
-
color: string;
|
|
5
|
-
backgroundColor?: string;
|
|
6
|
-
};
|
|
7
|
-
interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
|
|
8
|
-
switchLed?: boolean;
|
|
9
|
-
showEnable?: boolean;
|
|
10
|
-
setEnable: (enable: boolean) => void;
|
|
11
|
-
adjustType?: 1 | 2 | 3;
|
|
12
|
-
setAdjustType: (type: number) => void;
|
|
13
|
-
stripStyle?: 'ONLY_LINE' | 'WITH_BEAD';
|
|
14
|
-
nodes: Node[];
|
|
15
|
-
fixCount?: number;
|
|
16
|
-
touchingMode?: 'CLICK' | 'TOUCH';
|
|
17
|
-
nodeTouch: (idx: number) => void;
|
|
18
|
-
fingerUp: (idxList: string) => void;
|
|
19
|
-
hideLightView?: boolean;
|
|
20
|
-
isSupportColor?: boolean;
|
|
21
|
-
isSupportTemperature?: boolean;
|
|
22
|
-
isSupportBrightness?: boolean;
|
|
23
|
-
isColorMode?: boolean;
|
|
24
|
-
setIsColorMode: (isColorMode: boolean) => void;
|
|
25
|
-
blockColor?: string;
|
|
26
|
-
h: number;
|
|
27
|
-
s: number;
|
|
28
|
-
v: number;
|
|
29
|
-
onHSVChange: (h: number, s: number, v: number) => void;
|
|
30
|
-
onHSVChangeComplete: (h: number, s: number, v: number) => void;
|
|
31
|
-
temperature: number;
|
|
32
|
-
brightness: number;
|
|
33
|
-
onCCTChange: (cct: number) => void;
|
|
34
|
-
onCCTChangeComplete: (cct: number) => void;
|
|
35
|
-
onBrightnessChange: (brightness: number) => void;
|
|
36
|
-
onBrightnessChangeComplete: (brightness: number) => void;
|
|
37
|
-
hideLedNum?: boolean;
|
|
38
|
-
ledNum?: number;
|
|
39
|
-
setLedNum: (num: number) => void;
|
|
40
|
-
hidLampAdjustView?: boolean;
|
|
41
|
-
hideDisableLight?: boolean;
|
|
42
|
-
hideColorize?: boolean;
|
|
43
|
-
ledNumModalVisible?: boolean;
|
|
44
|
-
}
|
|
45
|
-
declare const DrawToolView: (props: DrawToolViewProps) => JSX.Element;
|
|
46
|
-
export default DrawToolView;
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
export declare type Node = {
|
|
4
|
+
color: string;
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
};
|
|
7
|
+
interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
|
|
8
|
+
switchLed?: boolean;
|
|
9
|
+
showEnable?: boolean;
|
|
10
|
+
setEnable: (enable: boolean) => void;
|
|
11
|
+
adjustType?: 1 | 2 | 3;
|
|
12
|
+
setAdjustType: (type: number) => void;
|
|
13
|
+
stripStyle?: 'ONLY_LINE' | 'WITH_BEAD';
|
|
14
|
+
nodes: Node[];
|
|
15
|
+
fixCount?: number;
|
|
16
|
+
touchingMode?: 'CLICK' | 'TOUCH';
|
|
17
|
+
nodeTouch: (idx: number) => void;
|
|
18
|
+
fingerUp: (idxList: string) => void;
|
|
19
|
+
hideLightView?: boolean;
|
|
20
|
+
isSupportColor?: boolean;
|
|
21
|
+
isSupportTemperature?: boolean;
|
|
22
|
+
isSupportBrightness?: boolean;
|
|
23
|
+
isColorMode?: boolean;
|
|
24
|
+
setIsColorMode: (isColorMode: boolean) => void;
|
|
25
|
+
blockColor?: string;
|
|
26
|
+
h: number;
|
|
27
|
+
s: number;
|
|
28
|
+
v: number;
|
|
29
|
+
onHSVChange: (h: number, s: number, v: number) => void;
|
|
30
|
+
onHSVChangeComplete: (h: number, s: number, v: number) => void;
|
|
31
|
+
temperature: number;
|
|
32
|
+
brightness: number;
|
|
33
|
+
onCCTChange: (cct: number) => void;
|
|
34
|
+
onCCTChangeComplete: (cct: number) => void;
|
|
35
|
+
onBrightnessChange: (brightness: number) => void;
|
|
36
|
+
onBrightnessChangeComplete: (brightness: number) => void;
|
|
37
|
+
hideLedNum?: boolean;
|
|
38
|
+
ledNum?: number;
|
|
39
|
+
setLedNum: (num: number) => void;
|
|
40
|
+
hidLampAdjustView?: boolean;
|
|
41
|
+
hideDisableLight?: boolean;
|
|
42
|
+
hideColorize?: boolean;
|
|
43
|
+
ledNumModalVisible?: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare const DrawToolView: (props: DrawToolViewProps) => JSX.Element;
|
|
46
|
+
export default DrawToolView;
|
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
import React, { PropsWithChildren, useCallback, useEffect, useMemo } from 'react'
|
|
2
|
-
import { Image, StyleSheet, Text, TouchableOpacity, View, ViewProps } from 'react-native'
|
|
3
|
-
import { Modal, Utils } from 'tuya-panel-kit'
|
|
4
|
-
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
5
|
-
import Card from './Card'
|
|
6
|
-
import res from '@res'
|
|
7
|
-
import I18n from '@i18n'
|
|
8
|
-
import LdvSwitch from './ldvSwitch'
|
|
9
|
-
import LampAdjustView from './LampAdjustView'
|
|
10
|
-
import { hsv2Hex, mapFloatToRange } from '@utils'
|
|
11
|
-
import Spacer from './Spacer'
|
|
12
|
-
import DeleteButton from './DeleteButton'
|
|
13
|
-
import Stepper from './Stepper'
|
|
14
|
-
import StripLightView from './StripLightView'
|
|
15
|
-
import { nativeEventEmitter } from '../api/nativeEventEmitter'
|
|
16
|
-
|
|
17
|
-
const { convertX: cx } = Utils.RatioUtils
|
|
18
|
-
|
|
19
|
-
export type Node = {
|
|
20
|
-
color: string,
|
|
21
|
-
backgroundColor?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
|
|
25
|
-
title?: string
|
|
26
|
-
switchLed?: boolean
|
|
27
|
-
showEnable?: boolean
|
|
28
|
-
setEnable: (enable: boolean) => void
|
|
29
|
-
adjustType?: 1 | 2 | 3 // 1 全选, 2 单选, 3 擦除
|
|
30
|
-
setAdjustType: (type: number) => void
|
|
31
|
-
stripStyle?: 'ONLY_LINE' | 'WITH_BEAD'
|
|
32
|
-
nodes: Node[]
|
|
33
|
-
fixCount?: number
|
|
34
|
-
touchingMode?: 'CLICK' | 'TOUCH'
|
|
35
|
-
nodeTouch: (idx: number) => void
|
|
36
|
-
fingerUp: (idxList: string) => void
|
|
37
|
-
hideLightView?: boolean
|
|
38
|
-
isSupportColor?: boolean
|
|
39
|
-
isSupportTemperature?: boolean
|
|
40
|
-
isSupportBrightness?: boolean
|
|
41
|
-
isColorMode?: boolean
|
|
42
|
-
setIsColorMode: (isColorMode: boolean) => void
|
|
43
|
-
blockColor?: string
|
|
44
|
-
h: number
|
|
45
|
-
s: number
|
|
46
|
-
v: number
|
|
47
|
-
onHSVChange: (h: number, s: number, v: number) => void
|
|
48
|
-
onHSVChangeComplete: (h: number, s: number, v: number) => void
|
|
49
|
-
temperature: number
|
|
50
|
-
brightness: number
|
|
51
|
-
onCCTChange: (cct: number) => void
|
|
52
|
-
onCCTChangeComplete: (cct: number) => void
|
|
53
|
-
onBrightnessChange: (brightness: number) => void
|
|
54
|
-
onBrightnessChangeComplete: (brightness: number) => void
|
|
55
|
-
hideLedNum?: boolean
|
|
56
|
-
ledNum?: number
|
|
57
|
-
setLedNum: (num: number) => void
|
|
58
|
-
hidLampAdjustView?: boolean
|
|
59
|
-
hideDisableLight?: boolean
|
|
60
|
-
hideColorize?: boolean
|
|
61
|
-
ledNumModalVisible?: boolean
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const DrawToolView = (props: DrawToolViewProps) => {
|
|
65
|
-
const state = useReactive({
|
|
66
|
-
visible: props.ledNumModalVisible || false,
|
|
67
|
-
ledNum: props.ledNum || 5,
|
|
68
|
-
width: 0,
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const fingerUp = nativeEventEmitter.addListener('onFingerUp', props.fingerUp)
|
|
73
|
-
|
|
74
|
-
const nodeTouched = nativeEventEmitter.addListener('onNodeTouched', props.nodeTouch)
|
|
75
|
-
return () => {
|
|
76
|
-
fingerUp.remove()
|
|
77
|
-
nodeTouched.remove()
|
|
78
|
-
}
|
|
79
|
-
}, [])
|
|
80
|
-
|
|
81
|
-
useUpdateEffect(() =>{
|
|
82
|
-
if(props.ledNum){
|
|
83
|
-
state.ledNum = props.ledNum
|
|
84
|
-
}
|
|
85
|
-
}, [props.ledNum])
|
|
86
|
-
|
|
87
|
-
useUpdateEffect(() =>{
|
|
88
|
-
state.visible = props.ledNumModalVisible || false
|
|
89
|
-
}, [props.ledNumModalVisible])
|
|
90
|
-
|
|
91
|
-
const onLayout = (event: any) => {
|
|
92
|
-
const { width } = event.nativeEvent.layout
|
|
93
|
-
state.width = width
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const height = useMemo(() => {
|
|
97
|
-
return cx(52 * Math.ceil((props.nodes.length / (props.fixCount || 5))))
|
|
98
|
-
}, [props.nodes])
|
|
99
|
-
|
|
100
|
-
const getBlockColor = useCallback(() => {
|
|
101
|
-
if (props.isColorMode) {
|
|
102
|
-
const s = Math.round(mapFloatToRange(props.s / 100, 30, 100))
|
|
103
|
-
return hsv2Hex(props.h, s, 100)
|
|
104
|
-
}
|
|
105
|
-
return '#ffffff'
|
|
106
|
-
}, [props.isColorMode, props.h, props.s])
|
|
107
|
-
|
|
108
|
-
const ledNumValidator = (num?: number) => {
|
|
109
|
-
return num && Number.isInteger(num) && num >= 5 && num <= 48;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<Card style={{ marginHorizontal: cx(24) }}>
|
|
114
|
-
<LdvSwitch
|
|
115
|
-
title={props.title || I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
116
|
-
color={'#fff'}
|
|
117
|
-
colorAlpha={1}
|
|
118
|
-
enable={!!props.switchLed}
|
|
119
|
-
showSwitch={!!props.showEnable}
|
|
120
|
-
setEnable={props.setEnable} />
|
|
121
|
-
{(props.showEnable && props.switchLed || !props.showEnable) && <>
|
|
122
|
-
<View style={styles.container}>
|
|
123
|
-
<View style={styles.adjustButtons}>
|
|
124
|
-
<TouchableOpacity
|
|
125
|
-
onPress={() => {
|
|
126
|
-
props.setAdjustType(1)
|
|
127
|
-
}}>
|
|
128
|
-
<Image
|
|
129
|
-
style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
|
|
130
|
-
source={res.ic_paint_bucket} />
|
|
131
|
-
</TouchableOpacity>
|
|
132
|
-
{!props.hideDisableLight && <TouchableOpacity
|
|
133
|
-
onPress={() => {
|
|
134
|
-
props.setAdjustType(3)
|
|
135
|
-
}}>
|
|
136
|
-
<Image
|
|
137
|
-
style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
|
|
138
|
-
source={res.ic_disabled_light} />
|
|
139
|
-
</TouchableOpacity>}
|
|
140
|
-
{!props.hideColorize && <TouchableOpacity
|
|
141
|
-
onPress={() => {
|
|
142
|
-
props.setAdjustType(2)
|
|
143
|
-
}}>
|
|
144
|
-
<Image
|
|
145
|
-
style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
|
|
146
|
-
source={res.ic_colorize} />
|
|
147
|
-
</TouchableOpacity>}
|
|
148
|
-
{!props.hideLedNum && <TouchableOpacity
|
|
149
|
-
onPress={() => {
|
|
150
|
-
state.visible = true
|
|
151
|
-
}}
|
|
152
|
-
style={[styles.adjustButton, {
|
|
153
|
-
alignItems: 'center',
|
|
154
|
-
justifyContent: 'center',
|
|
155
|
-
backgroundColor: '#f60',
|
|
156
|
-
borderRadius: cx(5),
|
|
157
|
-
}]}>
|
|
158
|
-
<Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
|
|
159
|
-
</TouchableOpacity>}
|
|
160
|
-
</View>
|
|
161
|
-
<StripLightView
|
|
162
|
-
style={{ height, flex: 1 }}
|
|
163
|
-
nodes={props.nodes}
|
|
164
|
-
fixCount={props.fixCount || 5}
|
|
165
|
-
stripStyle={props.stripStyle || 'WITH_BEAD'}
|
|
166
|
-
touchingMode={props.touchingMode || 'TOUCH'}
|
|
167
|
-
width={state.width}
|
|
168
|
-
onLayout={onLayout} />
|
|
169
|
-
</View>
|
|
170
|
-
<LdvSwitch
|
|
171
|
-
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
172
|
-
color={props.blockColor || getBlockColor()}
|
|
173
|
-
colorAlpha={1}
|
|
174
|
-
enable={false}
|
|
175
|
-
showSwitch={false}
|
|
176
|
-
setEnable={() => {
|
|
177
|
-
}} />
|
|
178
|
-
{!props.hidLampAdjustView && <LampAdjustView
|
|
179
|
-
isSupportColor={!!props.isSupportColor}
|
|
180
|
-
isSupportTemperature={!!props.isSupportTemperature}
|
|
181
|
-
isSupportBrightness={!!props.isSupportBrightness}
|
|
182
|
-
isColorMode={!!props.isColorMode}
|
|
183
|
-
reserveSV={true}
|
|
184
|
-
minSaturation={1}
|
|
185
|
-
setIsColorMode={props.setIsColorMode}
|
|
186
|
-
h={props.h} s={props.s} v={props.v}
|
|
187
|
-
onHSVChange={props.onHSVChange}
|
|
188
|
-
onHSVChangeComplete={props.onHSVChangeComplete}
|
|
189
|
-
colorTemp={props.temperature}
|
|
190
|
-
brightness={props.brightness}
|
|
191
|
-
onCCTChange={props.onCCTChange}
|
|
192
|
-
onCCTChangeComplete={props.onCCTChangeComplete}
|
|
193
|
-
onBrightnessChange={props.onBrightnessChange}
|
|
194
|
-
onBrightnessChangeComplete={props.onBrightnessChangeComplete} />}
|
|
195
|
-
{!props.hideLedNum && <Modal
|
|
196
|
-
visible={state.visible}
|
|
197
|
-
onMaskPress={() => {
|
|
198
|
-
state.visible = false
|
|
199
|
-
}}
|
|
200
|
-
alignContainer="center"
|
|
201
|
-
style={{ width: '100%', height: cx(150) }}>
|
|
202
|
-
<Card
|
|
203
|
-
containerStyle={{ marginHorizontal: cx(16), alignItems: 'center' }}
|
|
204
|
-
style={{ marginHorizontal: cx(16), marginTop: cx(50) }}>
|
|
205
|
-
<Spacer />
|
|
206
|
-
<Text style={{ color: '#000', fontSize: cx(14) }}>{I18n.getLang('string_lights_set_bulbs_title')}</Text>
|
|
207
|
-
<Spacer height={cx(10)}/>
|
|
208
|
-
<Text style={{color: '#999'}}>{I18n.getLang('string_lights_set_bulbs_description_text')}</Text>
|
|
209
|
-
<Spacer />
|
|
210
|
-
<Stepper
|
|
211
|
-
min={5}
|
|
212
|
-
max={48}
|
|
213
|
-
isBeyond={true}
|
|
214
|
-
stepValue={1}
|
|
215
|
-
editable={true}
|
|
216
|
-
value={state.ledNum}
|
|
217
|
-
isRealTime={true}
|
|
218
|
-
onValueChange={(v) => {
|
|
219
|
-
state.ledNum = v
|
|
220
|
-
}} />
|
|
221
|
-
<Spacer />
|
|
222
|
-
<DeleteButton
|
|
223
|
-
text={I18n.getLang('auto_scan_system_wifi_confirm')}
|
|
224
|
-
style={{ width: cx(150), height: cx(40), backgroundColor: ledNumValidator(state.ledNum) ? '#f60' : '#666' }}
|
|
225
|
-
textStyle={{ fontSize: cx(14) }}
|
|
226
|
-
onPress={() => {
|
|
227
|
-
if (!ledNumValidator(state.ledNum)) return
|
|
228
|
-
props.setLedNum(state.ledNum)
|
|
229
|
-
state.visible = false
|
|
230
|
-
}} />
|
|
231
|
-
<Spacer />
|
|
232
|
-
</Card>
|
|
233
|
-
</Modal>}
|
|
234
|
-
{props.children}
|
|
235
|
-
</>}
|
|
236
|
-
</Card>
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const styles = StyleSheet.create({
|
|
241
|
-
container: {
|
|
242
|
-
paddingLeft: cx(10),
|
|
243
|
-
flexDirection: 'row',
|
|
244
|
-
alignItems: 'center',
|
|
245
|
-
},
|
|
246
|
-
title: {
|
|
247
|
-
color: '#000',
|
|
248
|
-
fontSize: cx(16),
|
|
249
|
-
marginLeft: cx(10),
|
|
250
|
-
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
251
|
-
fontWeight: 'bold',
|
|
252
|
-
},
|
|
253
|
-
adjustButtons: {
|
|
254
|
-
width: cx(50),
|
|
255
|
-
},
|
|
256
|
-
adjustButton: {
|
|
257
|
-
width: cx(44),
|
|
258
|
-
height: cx(44),
|
|
259
|
-
},
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
export default DrawToolView
|
|
1
|
+
import React, { PropsWithChildren, useCallback, useEffect, useMemo } from 'react'
|
|
2
|
+
import { Image, StyleSheet, Text, TouchableOpacity, View, ViewProps } from 'react-native'
|
|
3
|
+
import { Modal, Utils } from 'tuya-panel-kit'
|
|
4
|
+
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
5
|
+
import Card from './Card'
|
|
6
|
+
import res from '@res'
|
|
7
|
+
import I18n from '@i18n'
|
|
8
|
+
import LdvSwitch from './ldvSwitch'
|
|
9
|
+
import LampAdjustView from './LampAdjustView'
|
|
10
|
+
import { hsv2Hex, mapFloatToRange } from '@utils'
|
|
11
|
+
import Spacer from './Spacer'
|
|
12
|
+
import DeleteButton from './DeleteButton'
|
|
13
|
+
import Stepper from './Stepper'
|
|
14
|
+
import StripLightView from './StripLightView'
|
|
15
|
+
import { nativeEventEmitter } from '../api/nativeEventEmitter'
|
|
16
|
+
|
|
17
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
18
|
+
|
|
19
|
+
export type Node = {
|
|
20
|
+
color: string,
|
|
21
|
+
backgroundColor?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
|
|
25
|
+
title?: string
|
|
26
|
+
switchLed?: boolean
|
|
27
|
+
showEnable?: boolean
|
|
28
|
+
setEnable: (enable: boolean) => void
|
|
29
|
+
adjustType?: 1 | 2 | 3 // 1 全选, 2 单选, 3 擦除
|
|
30
|
+
setAdjustType: (type: number) => void
|
|
31
|
+
stripStyle?: 'ONLY_LINE' | 'WITH_BEAD'
|
|
32
|
+
nodes: Node[]
|
|
33
|
+
fixCount?: number
|
|
34
|
+
touchingMode?: 'CLICK' | 'TOUCH'
|
|
35
|
+
nodeTouch: (idx: number) => void
|
|
36
|
+
fingerUp: (idxList: string) => void
|
|
37
|
+
hideLightView?: boolean
|
|
38
|
+
isSupportColor?: boolean
|
|
39
|
+
isSupportTemperature?: boolean
|
|
40
|
+
isSupportBrightness?: boolean
|
|
41
|
+
isColorMode?: boolean
|
|
42
|
+
setIsColorMode: (isColorMode: boolean) => void
|
|
43
|
+
blockColor?: string
|
|
44
|
+
h: number
|
|
45
|
+
s: number
|
|
46
|
+
v: number
|
|
47
|
+
onHSVChange: (h: number, s: number, v: number) => void
|
|
48
|
+
onHSVChangeComplete: (h: number, s: number, v: number) => void
|
|
49
|
+
temperature: number
|
|
50
|
+
brightness: number
|
|
51
|
+
onCCTChange: (cct: number) => void
|
|
52
|
+
onCCTChangeComplete: (cct: number) => void
|
|
53
|
+
onBrightnessChange: (brightness: number) => void
|
|
54
|
+
onBrightnessChangeComplete: (brightness: number) => void
|
|
55
|
+
hideLedNum?: boolean
|
|
56
|
+
ledNum?: number
|
|
57
|
+
setLedNum: (num: number) => void
|
|
58
|
+
hidLampAdjustView?: boolean
|
|
59
|
+
hideDisableLight?: boolean
|
|
60
|
+
hideColorize?: boolean
|
|
61
|
+
ledNumModalVisible?: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const DrawToolView = (props: DrawToolViewProps) => {
|
|
65
|
+
const state = useReactive({
|
|
66
|
+
visible: props.ledNumModalVisible || false,
|
|
67
|
+
ledNum: props.ledNum || 5,
|
|
68
|
+
width: 0,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const fingerUp = nativeEventEmitter.addListener('onFingerUp', props.fingerUp)
|
|
73
|
+
|
|
74
|
+
const nodeTouched = nativeEventEmitter.addListener('onNodeTouched', props.nodeTouch)
|
|
75
|
+
return () => {
|
|
76
|
+
fingerUp.remove()
|
|
77
|
+
nodeTouched.remove()
|
|
78
|
+
}
|
|
79
|
+
}, [])
|
|
80
|
+
|
|
81
|
+
useUpdateEffect(() =>{
|
|
82
|
+
if(props.ledNum){
|
|
83
|
+
state.ledNum = props.ledNum
|
|
84
|
+
}
|
|
85
|
+
}, [props.ledNum])
|
|
86
|
+
|
|
87
|
+
useUpdateEffect(() =>{
|
|
88
|
+
state.visible = props.ledNumModalVisible || false
|
|
89
|
+
}, [props.ledNumModalVisible])
|
|
90
|
+
|
|
91
|
+
const onLayout = (event: any) => {
|
|
92
|
+
const { width } = event.nativeEvent.layout
|
|
93
|
+
state.width = width
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const height = useMemo(() => {
|
|
97
|
+
return cx(52 * Math.ceil((props.nodes.length / (props.fixCount || 5))))
|
|
98
|
+
}, [props.nodes])
|
|
99
|
+
|
|
100
|
+
const getBlockColor = useCallback(() => {
|
|
101
|
+
if (props.isColorMode) {
|
|
102
|
+
const s = Math.round(mapFloatToRange(props.s / 100, 30, 100))
|
|
103
|
+
return hsv2Hex(props.h, s, 100)
|
|
104
|
+
}
|
|
105
|
+
return '#ffffff'
|
|
106
|
+
}, [props.isColorMode, props.h, props.s])
|
|
107
|
+
|
|
108
|
+
const ledNumValidator = (num?: number) => {
|
|
109
|
+
return num && Number.isInteger(num) && num >= 5 && num <= 48;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Card style={{ marginHorizontal: cx(24) }}>
|
|
114
|
+
<LdvSwitch
|
|
115
|
+
title={props.title || I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
116
|
+
color={'#fff'}
|
|
117
|
+
colorAlpha={1}
|
|
118
|
+
enable={!!props.switchLed}
|
|
119
|
+
showSwitch={!!props.showEnable}
|
|
120
|
+
setEnable={props.setEnable} />
|
|
121
|
+
{(props.showEnable && props.switchLed || !props.showEnable) && <>
|
|
122
|
+
<View style={styles.container}>
|
|
123
|
+
<View style={styles.adjustButtons}>
|
|
124
|
+
<TouchableOpacity
|
|
125
|
+
onPress={() => {
|
|
126
|
+
props.setAdjustType(1)
|
|
127
|
+
}}>
|
|
128
|
+
<Image
|
|
129
|
+
style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
|
|
130
|
+
source={res.ic_paint_bucket} />
|
|
131
|
+
</TouchableOpacity>
|
|
132
|
+
{!props.hideDisableLight && <TouchableOpacity
|
|
133
|
+
onPress={() => {
|
|
134
|
+
props.setAdjustType(3)
|
|
135
|
+
}}>
|
|
136
|
+
<Image
|
|
137
|
+
style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
|
|
138
|
+
source={res.ic_disabled_light} />
|
|
139
|
+
</TouchableOpacity>}
|
|
140
|
+
{!props.hideColorize && <TouchableOpacity
|
|
141
|
+
onPress={() => {
|
|
142
|
+
props.setAdjustType(2)
|
|
143
|
+
}}>
|
|
144
|
+
<Image
|
|
145
|
+
style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
|
|
146
|
+
source={res.ic_colorize} />
|
|
147
|
+
</TouchableOpacity>}
|
|
148
|
+
{!props.hideLedNum && <TouchableOpacity
|
|
149
|
+
onPress={() => {
|
|
150
|
+
state.visible = true
|
|
151
|
+
}}
|
|
152
|
+
style={[styles.adjustButton, {
|
|
153
|
+
alignItems: 'center',
|
|
154
|
+
justifyContent: 'center',
|
|
155
|
+
backgroundColor: '#f60',
|
|
156
|
+
borderRadius: cx(5),
|
|
157
|
+
}]}>
|
|
158
|
+
<Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
|
|
159
|
+
</TouchableOpacity>}
|
|
160
|
+
</View>
|
|
161
|
+
<StripLightView
|
|
162
|
+
style={{ height, flex: 1 }}
|
|
163
|
+
nodes={props.nodes}
|
|
164
|
+
fixCount={props.fixCount || 5}
|
|
165
|
+
stripStyle={props.stripStyle || 'WITH_BEAD'}
|
|
166
|
+
touchingMode={props.touchingMode || 'TOUCH'}
|
|
167
|
+
width={state.width}
|
|
168
|
+
onLayout={onLayout} />
|
|
169
|
+
</View>
|
|
170
|
+
<LdvSwitch
|
|
171
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
172
|
+
color={props.blockColor || getBlockColor()}
|
|
173
|
+
colorAlpha={1}
|
|
174
|
+
enable={false}
|
|
175
|
+
showSwitch={false}
|
|
176
|
+
setEnable={() => {
|
|
177
|
+
}} />
|
|
178
|
+
{!props.hidLampAdjustView && <LampAdjustView
|
|
179
|
+
isSupportColor={!!props.isSupportColor}
|
|
180
|
+
isSupportTemperature={!!props.isSupportTemperature}
|
|
181
|
+
isSupportBrightness={!!props.isSupportBrightness}
|
|
182
|
+
isColorMode={!!props.isColorMode}
|
|
183
|
+
reserveSV={true}
|
|
184
|
+
minSaturation={1}
|
|
185
|
+
setIsColorMode={props.setIsColorMode}
|
|
186
|
+
h={props.h} s={props.s} v={props.v}
|
|
187
|
+
onHSVChange={props.onHSVChange}
|
|
188
|
+
onHSVChangeComplete={props.onHSVChangeComplete}
|
|
189
|
+
colorTemp={props.temperature}
|
|
190
|
+
brightness={props.brightness}
|
|
191
|
+
onCCTChange={props.onCCTChange}
|
|
192
|
+
onCCTChangeComplete={props.onCCTChangeComplete}
|
|
193
|
+
onBrightnessChange={props.onBrightnessChange}
|
|
194
|
+
onBrightnessChangeComplete={props.onBrightnessChangeComplete} />}
|
|
195
|
+
{!props.hideLedNum && <Modal
|
|
196
|
+
visible={state.visible}
|
|
197
|
+
onMaskPress={() => {
|
|
198
|
+
state.visible = false
|
|
199
|
+
}}
|
|
200
|
+
alignContainer="center"
|
|
201
|
+
style={{ width: '100%', height: cx(150) }}>
|
|
202
|
+
<Card
|
|
203
|
+
containerStyle={{ marginHorizontal: cx(16), alignItems: 'center' }}
|
|
204
|
+
style={{ marginHorizontal: cx(16), marginTop: cx(50) }}>
|
|
205
|
+
<Spacer />
|
|
206
|
+
<Text style={{ color: '#000', fontSize: cx(14) }}>{I18n.getLang('string_lights_set_bulbs_title')}</Text>
|
|
207
|
+
<Spacer height={cx(10)}/>
|
|
208
|
+
<Text style={{color: '#999'}}>{I18n.getLang('string_lights_set_bulbs_description_text')}</Text>
|
|
209
|
+
<Spacer />
|
|
210
|
+
<Stepper
|
|
211
|
+
min={5}
|
|
212
|
+
max={48}
|
|
213
|
+
isBeyond={true}
|
|
214
|
+
stepValue={1}
|
|
215
|
+
editable={true}
|
|
216
|
+
value={state.ledNum}
|
|
217
|
+
isRealTime={true}
|
|
218
|
+
onValueChange={(v) => {
|
|
219
|
+
state.ledNum = v
|
|
220
|
+
}} />
|
|
221
|
+
<Spacer />
|
|
222
|
+
<DeleteButton
|
|
223
|
+
text={I18n.getLang('auto_scan_system_wifi_confirm')}
|
|
224
|
+
style={{ width: cx(150), height: cx(40), backgroundColor: ledNumValidator(state.ledNum) ? '#f60' : '#666' }}
|
|
225
|
+
textStyle={{ fontSize: cx(14) }}
|
|
226
|
+
onPress={() => {
|
|
227
|
+
if (!ledNumValidator(state.ledNum)) return
|
|
228
|
+
props.setLedNum(state.ledNum)
|
|
229
|
+
state.visible = false
|
|
230
|
+
}} />
|
|
231
|
+
<Spacer />
|
|
232
|
+
</Card>
|
|
233
|
+
</Modal>}
|
|
234
|
+
{props.children}
|
|
235
|
+
</>}
|
|
236
|
+
</Card>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const styles = StyleSheet.create({
|
|
241
|
+
container: {
|
|
242
|
+
paddingLeft: cx(10),
|
|
243
|
+
flexDirection: 'row',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
},
|
|
246
|
+
title: {
|
|
247
|
+
color: '#000',
|
|
248
|
+
fontSize: cx(16),
|
|
249
|
+
marginLeft: cx(10),
|
|
250
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
251
|
+
fontWeight: 'bold',
|
|
252
|
+
},
|
|
253
|
+
adjustButtons: {
|
|
254
|
+
width: cx(50),
|
|
255
|
+
},
|
|
256
|
+
adjustButton: {
|
|
257
|
+
width: cx(44),
|
|
258
|
+
height: cx(44),
|
|
259
|
+
},
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
export default DrawToolView
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ViewProps } from 'react-native';
|
|
2
|
-
interface FanAdjustViewProps extends ViewProps {
|
|
3
|
-
fanEnable: boolean;
|
|
4
|
-
fanSpeed: number;
|
|
5
|
-
maxFanSpeed?: number;
|
|
6
|
-
isSupportDirection?: boolean;
|
|
7
|
-
isSupportDisinfect?: boolean;
|
|
8
|
-
isSupportMode?: boolean;
|
|
9
|
-
directValue?: string;
|
|
10
|
-
modeValue?: string;
|
|
11
|
-
disinfect?: boolean;
|
|
12
|
-
directOptions?: any[];
|
|
13
|
-
modeOptions?: any[];
|
|
14
|
-
directChange?: (direct: string) => void;
|
|
15
|
-
modeChange?: (mode: string) => void;
|
|
16
|
-
disinfectChange?: (disinfect: boolean) => void;
|
|
17
|
-
onFanSwitch: (fanEnable: boolean) => void;
|
|
18
|
-
onFanSpeedChange?: (fanSpeed: number) => void;
|
|
19
|
-
onFanSpeedChangeComplete: (fanSpeed: number) => void;
|
|
20
|
-
}
|
|
21
|
-
declare const FanAdjustView: (props: FanAdjustViewProps) => JSX.Element;
|
|
22
|
-
export declare function FanAdjustViewContent(props: FanAdjustViewProps): JSX.Element;
|
|
23
|
-
export default FanAdjustView;
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
interface FanAdjustViewProps extends ViewProps {
|
|
3
|
+
fanEnable: boolean;
|
|
4
|
+
fanSpeed: number;
|
|
5
|
+
maxFanSpeed?: number;
|
|
6
|
+
isSupportDirection?: boolean;
|
|
7
|
+
isSupportDisinfect?: boolean;
|
|
8
|
+
isSupportMode?: boolean;
|
|
9
|
+
directValue?: string;
|
|
10
|
+
modeValue?: string;
|
|
11
|
+
disinfect?: boolean;
|
|
12
|
+
directOptions?: any[];
|
|
13
|
+
modeOptions?: any[];
|
|
14
|
+
directChange?: (direct: string) => void;
|
|
15
|
+
modeChange?: (mode: string) => void;
|
|
16
|
+
disinfectChange?: (disinfect: boolean) => void;
|
|
17
|
+
onFanSwitch: (fanEnable: boolean) => void;
|
|
18
|
+
onFanSpeedChange?: (fanSpeed: number) => void;
|
|
19
|
+
onFanSpeedChangeComplete: (fanSpeed: number) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const FanAdjustView: (props: FanAdjustViewProps) => JSX.Element;
|
|
22
|
+
export declare function FanAdjustViewContent(props: FanAdjustViewProps): JSX.Element;
|
|
23
|
+
export default FanAdjustView;
|