@ledvance/base 1.0.1
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 -0
- package/.eslintignore +6 -0
- package/.eslintrc.js +27 -0
- package/.prettierignore +0 -0
- package/.prettierrc.js +1 -0
- package/.versionrc +5 -0
- package/package.json +71 -0
- package/rn-cli.config.js +8 -0
- package/src/api/native.d.ts +16 -0
- package/src/api/native.ts +161 -0
- package/src/api/nativeEventEmitter.d.ts +2 -0
- package/src/api/nativeEventEmitter.ts +24 -0
- package/src/components/Card.d.ts +9 -0
- package/src/components/Card.tsx +35 -0
- package/src/components/Cell.d.ts +9 -0
- package/src/components/Cell.tsx +41 -0
- package/src/components/ColorAdjustView.d.ts +9 -0
- package/src/components/ColorAdjustView.tsx +66 -0
- package/src/components/ColorTempAdjustView.d.ts +12 -0
- package/src/components/ColorTempAdjustView.tsx +55 -0
- package/src/components/Dialog.d.ts +10 -0
- package/src/components/Dialog.tsx +39 -0
- package/src/components/InfoText.d.ts +10 -0
- package/src/components/InfoText.tsx +44 -0
- package/src/components/LampAdjustView.d.ts +13 -0
- package/src/components/LampAdjustView.tsx +76 -0
- package/src/components/LinearGradientLine.d.ts +9 -0
- package/src/components/LinearGradientLine.tsx +65 -0
- package/src/components/Page.d.ts +11 -0
- package/src/components/Page.tsx +35 -0
- package/src/components/Spacer.d.ts +7 -0
- package/src/components/Spacer.tsx +14 -0
- package/src/components/Tag.d.ts +8 -0
- package/src/components/Tag.tsx +57 -0
- package/src/components/TextButton.d.ts +9 -0
- package/src/components/TextButton.tsx +32 -0
- package/src/components/TextField.d.ts +5 -0
- package/src/components/TextField.tsx +74 -0
- package/src/components/connect.d.ts +10 -0
- package/src/components/connect.tsx +20 -0
- package/src/components/ldvColorBrightness.d.ts +1 -0
- package/src/components/ldvColorBrightness.tsx +18 -0
- package/src/components/ldvColorSlider.d.ts +14 -0
- package/src/components/ldvColorSlider.tsx +132 -0
- package/src/components/ldvPickerView.d.ts +10 -0
- package/src/components/ldvPickerView.tsx +68 -0
- package/src/components/ldvPresetView.d.ts +2 -0
- package/src/components/ldvPresetView.tsx +89 -0
- package/src/components/ldvSaturation.d.ts +2 -0
- package/src/components/ldvSaturation.tsx +23 -0
- package/src/components/ldvSlider.d.ts +15 -0
- package/src/components/ldvSlider.tsx +104 -0
- package/src/components/ldvSwitch.d.ts +9 -0
- package/src/components/ldvSwitch.tsx +48 -0
- package/src/components/ldvTemperatureSlider.d.ts +13 -0
- package/src/components/ldvTemperatureSlider.tsx +140 -0
- package/src/components/ldvTopBar.d.ts +9 -0
- package/src/components/ldvTopBar.tsx +64 -0
- package/src/components/ldvTopName.d.ts +7 -0
- package/src/components/ldvTopName.tsx +47 -0
- package/src/components/segmentControl.d.ts +1 -0
- package/src/components/segmentControl.tsx +66 -0
- package/src/components/weekSelect.d.ts +7 -0
- package/src/components/weekSelect.tsx +95 -0
- package/src/composeLayout.tsx +148 -0
- package/src/i18n/index.d.ts +16 -0
- package/src/i18n/index.ts +36 -0
- package/src/i18n/strings.d.ts +3139 -0
- package/src/i18n/strings.ts +3234 -0
- package/src/main.tsx +9 -0
- package/src/models/GlobalParams.d.ts +14 -0
- package/src/models/GlobalParams.ts +15 -0
- package/src/models/TuyaApi.d.ts +17 -0
- package/src/models/TuyaApi.ts +37 -0
- package/src/models/combine.d.ts +26 -0
- package/src/models/combine.ts +17 -0
- package/src/models/configureStore.d.ts +9 -0
- package/src/models/configureStore.ts +33 -0
- package/src/models/index.d.ts +31 -0
- package/src/models/index.ts +22 -0
- package/src/models/modules/NativePropsSlice.d.ts +25 -0
- package/src/models/modules/NativePropsSlice.tsx +145 -0
- package/src/models/modules/Result.d.ts +14 -0
- package/src/models/modules/Result.ts +16 -0
- package/src/models/modules/common.d.ts +44 -0
- package/src/models/modules/common.ts +161 -0
- package/src/res/index.d.ts +38 -0
- package/src/res/index.ts +37 -0
- package/src/utils/ColorParser.d.ts +66 -0
- package/src/utils/ColorParser.ts +190 -0
- package/src/utils/ColorUtils.d.ts +71 -0
- package/src/utils/ColorUtils.tsx +449 -0
- package/src/utils/common.d.ts +11 -0
- package/src/utils/common.ts +54 -0
- package/src/utils/index.d.ts +24 -0
- package/src/utils/index.ts +164 -0
- package/tsconfig.json +51 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
3
|
+
import { LinearGradient, Slider, Utils } from 'tuya-panel-kit'
|
|
4
|
+
import { Rect } from 'react-native-svg'
|
|
5
|
+
|
|
6
|
+
const cx = Utils.RatioUtils.convertX
|
|
7
|
+
|
|
8
|
+
const temperatures = {
|
|
9
|
+
'0%': 'rgb(254, 172, 90)',
|
|
10
|
+
'22%': 'rgb(249, 209, 164)',
|
|
11
|
+
'41%': 'rgb(254, 244, 223)',
|
|
12
|
+
'60%': 'rgb(252, 250, 242)',
|
|
13
|
+
'80%': 'rgb(226, 235, 248)',
|
|
14
|
+
'100%': 'rgb(194, 217, 254)',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const colors = {
|
|
18
|
+
'0%': 'rgb(255, 0, 0)',
|
|
19
|
+
'17%': 'rgb(249, 238, 0)',
|
|
20
|
+
'35%': 'rgb(96, 255, 66)',
|
|
21
|
+
'55%': 'rgb(0, 249, 255)',
|
|
22
|
+
'65%': 'rgb(43, 0, 255)',
|
|
23
|
+
'80%': 'rgb(180, 0, 255)',
|
|
24
|
+
'100%': 'rgb(255, 0, 0)',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const TEMP_KEY = 'temperature'
|
|
28
|
+
|
|
29
|
+
interface LdvColorSliderProps {
|
|
30
|
+
title: string,
|
|
31
|
+
type: string,
|
|
32
|
+
onValueChange?: (number) => void | undefined,
|
|
33
|
+
onSlidingComplete: (number) => void,
|
|
34
|
+
thumbColor: string,
|
|
35
|
+
value: number,
|
|
36
|
+
width?: number | undefined,
|
|
37
|
+
style?: StyleProp<ViewStyle> | undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const LdvColorSlider = (props: LdvColorSliderProps) => {
|
|
41
|
+
const { title, type, onSlidingComplete, thumbColor, value } = props
|
|
42
|
+
let dataSource = type === TEMP_KEY ? temperatures : colors
|
|
43
|
+
let max = type === TEMP_KEY ? 100 : 359
|
|
44
|
+
let min = type === TEMP_KEY ? 0 : 0
|
|
45
|
+
const width = props.width || (Utils.RatioUtils.width - cx(80))
|
|
46
|
+
return (
|
|
47
|
+
<View style={[styles.container, props.style]}>
|
|
48
|
+
<Text style={styles.title}>
|
|
49
|
+
{title}
|
|
50
|
+
</Text>
|
|
51
|
+
<Slider.Horizontal
|
|
52
|
+
style={{ ...styles.shadeSlider, width }}
|
|
53
|
+
styles={{ track: styles.sliderTrack, thumb: { ...styles.shadeThumb, backgroundColor: thumbColor } }}
|
|
54
|
+
maximumValue={max}
|
|
55
|
+
minimumValue={min}
|
|
56
|
+
value={value}
|
|
57
|
+
stepValue={1}
|
|
58
|
+
canTouchTrack={true}
|
|
59
|
+
theme={{
|
|
60
|
+
trackRadius: cx(15),
|
|
61
|
+
}}
|
|
62
|
+
onlyMaximumTrack={true}
|
|
63
|
+
renderMaximumTrack={() => {
|
|
64
|
+
return (
|
|
65
|
+
<View style={{ flex: 1, borderRadius: cx(15) }}>
|
|
66
|
+
<LinearGradient
|
|
67
|
+
style={{ ...styles.sliderLinearGradient, width }}
|
|
68
|
+
x1="0%"
|
|
69
|
+
y1="0%"
|
|
70
|
+
x2="100%"
|
|
71
|
+
y2="0%"
|
|
72
|
+
stops={dataSource}>
|
|
73
|
+
<Rect {...styles.sliderLinearGradient} width={width} />
|
|
74
|
+
</LinearGradient>
|
|
75
|
+
</View>
|
|
76
|
+
)
|
|
77
|
+
}}
|
|
78
|
+
onValueChange={props.onValueChange}
|
|
79
|
+
onSlidingComplete={onSlidingComplete}
|
|
80
|
+
/>
|
|
81
|
+
</View>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const styles = StyleSheet.create({
|
|
86
|
+
container: {
|
|
87
|
+
height: cx(57),
|
|
88
|
+
flexDirection: 'column',
|
|
89
|
+
paddingStart: cx(16),
|
|
90
|
+
},
|
|
91
|
+
title: {
|
|
92
|
+
marginTop: cx(4),
|
|
93
|
+
fontSize: cx(14),
|
|
94
|
+
color: '#000',
|
|
95
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
96
|
+
},
|
|
97
|
+
shadeSlider: {
|
|
98
|
+
marginTop: cx(8),
|
|
99
|
+
height: cx(28),
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
},
|
|
102
|
+
sliderTrack: {
|
|
103
|
+
marginTop: cx(9),
|
|
104
|
+
marginBottom: cx(9),
|
|
105
|
+
flex: 1,
|
|
106
|
+
borderRadius: cx(15),
|
|
107
|
+
},
|
|
108
|
+
shadeThumb: {
|
|
109
|
+
backgroundColor: 'rgb(0, 249, 255)',
|
|
110
|
+
width: cx(28),
|
|
111
|
+
height: cx(28),
|
|
112
|
+
borderRadius: cx(14),
|
|
113
|
+
borderColor: 'white',
|
|
114
|
+
borderWidth: 1,
|
|
115
|
+
shadowColor: '#000000',
|
|
116
|
+
shadowOpacity: 0.2,
|
|
117
|
+
shadowRadius: cx(8),
|
|
118
|
+
elevation: cx(8),
|
|
119
|
+
shadowOffset: {
|
|
120
|
+
width: 0,
|
|
121
|
+
height: cx(4),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
sliderLinearGradient: {
|
|
125
|
+
height: cx(12),
|
|
126
|
+
},
|
|
127
|
+
presetView: {
|
|
128
|
+
height: cx(60),
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
export default LdvColorSlider
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
interface LdvPickerViewProps {
|
|
3
|
+
hour: string;
|
|
4
|
+
minute: string;
|
|
5
|
+
setHour: (string: any) => void;
|
|
6
|
+
setMinute: (string: any) => void;
|
|
7
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare const LdvPickerView: (props: LdvPickerViewProps) => JSX.Element;
|
|
10
|
+
export default LdvPickerView;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
|
|
3
|
+
import { Picker, Utils } from 'tuya-panel-kit'
|
|
4
|
+
import _ from 'lodash'
|
|
5
|
+
|
|
6
|
+
const { convertX } = Utils.RatioUtils
|
|
7
|
+
|
|
8
|
+
const hours = _.times(24, (n) => _.padStart(n.toString(), 2, '0'))
|
|
9
|
+
const minutes = _.times(60, (n) => _.padStart(n.toString(), 2, '0'))
|
|
10
|
+
const pickerTheme = {
|
|
11
|
+
fontSize: 20,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface LdvPickerViewProps {
|
|
15
|
+
hour: string,
|
|
16
|
+
minute: string,
|
|
17
|
+
setHour: (string) => void,
|
|
18
|
+
setMinute: (string) => void,
|
|
19
|
+
style?: StyleProp<ViewStyle> | undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const LdvPickerView = (props: LdvPickerViewProps) => {
|
|
23
|
+
|
|
24
|
+
const { hour, minute, setHour, setMinute } = props
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View style={[styles.pickerContainer, props.style]}>
|
|
28
|
+
<Picker
|
|
29
|
+
style={[styles.picker, styles.pickerLeft]}
|
|
30
|
+
theme={pickerTheme}
|
|
31
|
+
itemStyle={styles.pickerItem}
|
|
32
|
+
textSize={convertX(14)}
|
|
33
|
+
selectedValue={hour}
|
|
34
|
+
itemAlign={'center'}
|
|
35
|
+
onValueChange={value => setHour(value as string)}>
|
|
36
|
+
{hours.map((value) => (
|
|
37
|
+
<Picker.Item key={value} value={value} label={value} />
|
|
38
|
+
))}
|
|
39
|
+
</Picker>
|
|
40
|
+
<Picker
|
|
41
|
+
style={[styles.picker, styles.pickerLeft]}
|
|
42
|
+
theme={pickerTheme}
|
|
43
|
+
itemStyle={styles.pickerItem}
|
|
44
|
+
textSize={convertX(14)}
|
|
45
|
+
selectedValue={minute}
|
|
46
|
+
onValueChange={value => setMinute(value as string)}>
|
|
47
|
+
{minutes.map((value) => (
|
|
48
|
+
<Picker.Item key={value} value={value} label={value} />
|
|
49
|
+
))}
|
|
50
|
+
</Picker>
|
|
51
|
+
|
|
52
|
+
</View>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
pickerContainer: {
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
},
|
|
61
|
+
picker: {
|
|
62
|
+
flex: 1,
|
|
63
|
+
},
|
|
64
|
+
pickerLeft: {},
|
|
65
|
+
pickerItem: {},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
export default LdvPickerView
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View, TouchableOpacity } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const temperatures = [
|
|
5
|
+
{
|
|
6
|
+
color: 'rgb(253, 176, 97)',
|
|
7
|
+
value: 0,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
color: 'rgb(249, 208, 162)',
|
|
11
|
+
value: 20,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
color: 'rgb(254, 243, 221)',
|
|
15
|
+
value: 40,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
color: 'rgb(246, 247, 244)',
|
|
19
|
+
value: 60,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
color: 'rgb(231, 238, 247)',
|
|
23
|
+
value: 80,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
color: 'rgb(194, 216, 251)',
|
|
27
|
+
value: 100,
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
const colors = [
|
|
32
|
+
{
|
|
33
|
+
color: '#ff0000',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
color: '#ff8700',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
color: '#fff100',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
color: '#00c931',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
color: '#0025ff',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
color: '#bb00ff',
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
const LdvPresetView = (props) => {
|
|
53
|
+
const { type, onPress } = props
|
|
54
|
+
let dataSource = type == 'temperature' ? temperatures : colors
|
|
55
|
+
return (<View style={styles.container}>
|
|
56
|
+
{dataSource.map((item, index) => {
|
|
57
|
+
return (
|
|
58
|
+
<TouchableOpacity
|
|
59
|
+
key={index}
|
|
60
|
+
style={[styles.item, { backgroundColor: item.color }]}
|
|
61
|
+
onPress={() => {
|
|
62
|
+
console.log('LdvPresetView')
|
|
63
|
+
onPress(item)
|
|
64
|
+
}} />
|
|
65
|
+
)
|
|
66
|
+
})}
|
|
67
|
+
</View>)
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const styles = StyleSheet.create({
|
|
72
|
+
container: {
|
|
73
|
+
flex: 1,
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
justifyContent: 'space-between',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
marginHorizontal: 16,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
item: {
|
|
81
|
+
width: 28,
|
|
82
|
+
height: 28,
|
|
83
|
+
borderRadius: 14,
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
borderColor: 'rgb(230, 231, 232)',
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
export default LdvPresetView
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import LdvSlider from 'components/ldvSlider'
|
|
3
|
+
import I18n from '../i18n/index'
|
|
4
|
+
|
|
5
|
+
const LdvSaturation = (props) => {
|
|
6
|
+
const {value, onSlidingComplete} = props
|
|
7
|
+
|
|
8
|
+
const renderBrightness = () => {
|
|
9
|
+
return (
|
|
10
|
+
<LdvSlider
|
|
11
|
+
style={props.style}
|
|
12
|
+
title={I18n.getLang('light_sources_tile_rgb_lighting_saturation')}
|
|
13
|
+
value={value}
|
|
14
|
+
max={100}
|
|
15
|
+
min={0}
|
|
16
|
+
onSlidingComplete={onSlidingComplete}
|
|
17
|
+
onValueChange={props.onValueChange}/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
return renderBrightness()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default LdvSaturation
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
interface LdvSliderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
value: number;
|
|
5
|
+
min?: number | undefined;
|
|
6
|
+
max?: number | undefined;
|
|
7
|
+
onValueChange?: (number: any) => void | undefined;
|
|
8
|
+
onSlidingComplete: (number: any) => void;
|
|
9
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
10
|
+
sliderStyle?: StyleProp<ViewStyle> | undefined;
|
|
11
|
+
subTitleStr?: string;
|
|
12
|
+
titleStyle?: StyleProp<TextStyle> | undefined;
|
|
13
|
+
}
|
|
14
|
+
declare const LdvSlider: (props: LdvSliderProps) => JSX.Element;
|
|
15
|
+
export default LdvSlider;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useReactive } from "ahooks";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
|
+
import { StyleSheet, View, Text, StyleProp, ViewStyle, TextStyle } from 'react-native'
|
|
4
|
+
import { Slider, Utils } from "tuya-panel-kit";
|
|
5
|
+
|
|
6
|
+
const cx = Utils.RatioUtils.convertX;
|
|
7
|
+
|
|
8
|
+
interface LdvSliderProps {
|
|
9
|
+
title: string,
|
|
10
|
+
value: number,
|
|
11
|
+
min?: number | undefined,
|
|
12
|
+
max?: number | undefined,
|
|
13
|
+
onValueChange?: (number) => void | undefined,
|
|
14
|
+
onSlidingComplete: (number) => void,
|
|
15
|
+
style?: StyleProp<ViewStyle> | undefined,
|
|
16
|
+
sliderStyle?: StyleProp<ViewStyle> | undefined
|
|
17
|
+
subTitleStr?: string
|
|
18
|
+
titleStyle?: StyleProp<TextStyle> | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const LdvSlider = (props: LdvSliderProps) => {
|
|
22
|
+
const { value, onSlidingComplete, min, max, sliderStyle, subTitleStr, titleStyle, onValueChange } = props;
|
|
23
|
+
|
|
24
|
+
const mMax = max || 100;
|
|
25
|
+
const mMin = min || 1;
|
|
26
|
+
const state = useReactive({
|
|
27
|
+
value: value,
|
|
28
|
+
})
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
state.value = value
|
|
31
|
+
}, [value])
|
|
32
|
+
return (
|
|
33
|
+
<View style={[styles.container, props.style]}>
|
|
34
|
+
<View style={styles.titleBg}>
|
|
35
|
+
<Text style={[styles.title, titleStyle]}>
|
|
36
|
+
{props.title}
|
|
37
|
+
</Text>
|
|
38
|
+
<Text style={styles.valueText}>
|
|
39
|
+
{subTitleStr ? subTitleStr : state.value + "%"}
|
|
40
|
+
</Text>
|
|
41
|
+
</View>
|
|
42
|
+
<Slider.Horizontal
|
|
43
|
+
style={[styles.slider, sliderStyle]}
|
|
44
|
+
styles={{ thumb: styles.thumb }}
|
|
45
|
+
maximumValue={mMax}
|
|
46
|
+
minimumValue={mMin}
|
|
47
|
+
value={state.value}
|
|
48
|
+
stepValue={1}
|
|
49
|
+
canTouchTrack={true}
|
|
50
|
+
minimumTrackTintColor={"#666"}
|
|
51
|
+
maximumTrackTintColor={"rgba(120, 120, 128, 0.2)"}
|
|
52
|
+
onValueChange={(value) => {
|
|
53
|
+
state.value = value
|
|
54
|
+
onValueChange && onValueChange(value);
|
|
55
|
+
}}
|
|
56
|
+
onSlidingComplete={onSlidingComplete}
|
|
57
|
+
/>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const styles = StyleSheet.create({
|
|
63
|
+
container: {
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
paddingHorizontal: cx(16)
|
|
66
|
+
},
|
|
67
|
+
titleBg: {
|
|
68
|
+
flexDirection: "row",
|
|
69
|
+
justifyContent: "space-between"
|
|
70
|
+
},
|
|
71
|
+
valueText: {
|
|
72
|
+
marginTop: cx(10),
|
|
73
|
+
fontSize: cx(14),
|
|
74
|
+
color: "#000",
|
|
75
|
+
fontFamily: "helvetica_neue_lt_std_roman"
|
|
76
|
+
},
|
|
77
|
+
title: {
|
|
78
|
+
marginTop: cx(10),
|
|
79
|
+
fontSize: cx(14),
|
|
80
|
+
color: "#000",
|
|
81
|
+
fontFamily: "helvetica_neue_lt_std_roman"
|
|
82
|
+
},
|
|
83
|
+
slider: {
|
|
84
|
+
marginTop: cx(8),
|
|
85
|
+
height: cx(28),
|
|
86
|
+
justifyContent: "center"
|
|
87
|
+
},
|
|
88
|
+
thumb: {
|
|
89
|
+
backgroundColor: "#fff",
|
|
90
|
+
width: cx(28),
|
|
91
|
+
height: cx(28),
|
|
92
|
+
borderRadius: cx(14),
|
|
93
|
+
shadowColor: "#000000",
|
|
94
|
+
shadowOpacity: 0.2,
|
|
95
|
+
elevation: cx(8),
|
|
96
|
+
shadowRadius: cx(8),
|
|
97
|
+
shadowOffset: {
|
|
98
|
+
width: 0,
|
|
99
|
+
height: cx(4)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export default LdvSlider;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { SwitchButton, Utils } from 'tuya-panel-kit'
|
|
4
|
+
import Spacer from './Spacer'
|
|
5
|
+
|
|
6
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
7
|
+
|
|
8
|
+
interface Prop {
|
|
9
|
+
title: string
|
|
10
|
+
color: string
|
|
11
|
+
colorAlpha: number
|
|
12
|
+
enable: boolean
|
|
13
|
+
setEnable: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const LdvSwitch = (props: Prop) => {
|
|
17
|
+
const { title, color, colorAlpha, enable, setEnable } = props
|
|
18
|
+
return (
|
|
19
|
+
<View style={styles.titleBGView}>
|
|
20
|
+
<Text style={styles.title}>{title}</Text>
|
|
21
|
+
<View style={[styles.colorBlock, { backgroundColor: color, opacity: colorAlpha }]} />
|
|
22
|
+
<Spacer style={{ flex: 1 }} height={0} width={0} />
|
|
23
|
+
<SwitchButton value={enable} onValueChange={setEnable} />
|
|
24
|
+
</View>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
titleBGView: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
paddingHorizontal: cx(16),
|
|
33
|
+
},
|
|
34
|
+
colorBlock: {
|
|
35
|
+
width: cx(20),
|
|
36
|
+
height: cx(20),
|
|
37
|
+
marginStart: cx(12),
|
|
38
|
+
borderRadius: cx(4),
|
|
39
|
+
},
|
|
40
|
+
title: {
|
|
41
|
+
color: '#000',
|
|
42
|
+
fontSize: cx(16),
|
|
43
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
44
|
+
paddingVertical: cx(16),
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
export default LdvSwitch
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleProp, TextProps, ViewStyle } from 'react-native';
|
|
2
|
+
interface LdvTemperatureSliderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
onSlidingComplete: (number: any) => void;
|
|
5
|
+
thumbColor: string;
|
|
6
|
+
value: number;
|
|
7
|
+
width?: number | undefined;
|
|
8
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
9
|
+
titleStyle?: StyleProp<TextProps> | undefined;
|
|
10
|
+
subTitleStr?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
declare const LdvTemperatureSlider: (props: LdvTemperatureSliderProps) => JSX.Element;
|
|
13
|
+
export default LdvTemperatureSlider;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { StyleProp, StyleSheet, Text, TextProps, View, ViewStyle } from 'react-native'
|
|
3
|
+
import { LinearGradient, Slider, Utils } from 'tuya-panel-kit'
|
|
4
|
+
import { Rect } from 'react-native-svg'
|
|
5
|
+
import { useReactive } from 'ahooks'
|
|
6
|
+
|
|
7
|
+
const cx = Utils.RatioUtils.convertX
|
|
8
|
+
|
|
9
|
+
const temperatures = {
|
|
10
|
+
'0%': 'rgb(254, 172, 90)',
|
|
11
|
+
'22%': 'rgb(249, 209, 164)',
|
|
12
|
+
'41%': 'rgb(254, 244, 223)',
|
|
13
|
+
'60%': 'rgb(252, 250, 242)',
|
|
14
|
+
'80%': 'rgb(226, 235, 248)',
|
|
15
|
+
'100%': 'rgb(194, 217, 254)',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface LdvTemperatureSliderProps {
|
|
19
|
+
title: string
|
|
20
|
+
onSlidingComplete: (number) => void
|
|
21
|
+
thumbColor: string
|
|
22
|
+
value: number
|
|
23
|
+
width?: number | undefined
|
|
24
|
+
style?: StyleProp<ViewStyle> | undefined
|
|
25
|
+
titleStyle?: StyleProp<TextProps> | undefined
|
|
26
|
+
subTitleStr?: string | undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const LdvTemperatureSlider = (props: LdvTemperatureSliderProps) => {
|
|
30
|
+
const { title, onSlidingComplete, thumbColor, value, titleStyle } = props
|
|
31
|
+
let dataSource = temperatures
|
|
32
|
+
let max = 100
|
|
33
|
+
let min = 0
|
|
34
|
+
const width = props.width || (Utils.RatioUtils.width - cx(80))
|
|
35
|
+
|
|
36
|
+
const state = useReactive({
|
|
37
|
+
value: value,
|
|
38
|
+
})
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
state.value = value
|
|
41
|
+
}, [value])
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<View style={[styles.container, props.style]}>
|
|
45
|
+
<View style={styles.titleBg}>
|
|
46
|
+
<Text style={[styles.title, titleStyle]}>
|
|
47
|
+
{title}
|
|
48
|
+
</Text>
|
|
49
|
+
</View>
|
|
50
|
+
<Slider.Horizontal
|
|
51
|
+
style={{ ...styles.shadeSlider, width }}
|
|
52
|
+
styles={{ track: styles.sliderTrack, thumb: { ...styles.shadeThumb, backgroundColor: thumbColor } }}
|
|
53
|
+
maximumValue={max}
|
|
54
|
+
minimumValue={min}
|
|
55
|
+
value={value}
|
|
56
|
+
stepValue={1}
|
|
57
|
+
canTouchTrack={true}
|
|
58
|
+
theme={{
|
|
59
|
+
trackRadius: cx(15),
|
|
60
|
+
}}
|
|
61
|
+
onlyMaximumTrack={true}
|
|
62
|
+
renderMaximumTrack={() => {
|
|
63
|
+
return (
|
|
64
|
+
<View style={{ flex: 1, borderRadius: cx(15) }}>
|
|
65
|
+
<LinearGradient
|
|
66
|
+
style={{ ...styles.sliderLinearGradient, width }}
|
|
67
|
+
x1="0%"
|
|
68
|
+
y1="0%"
|
|
69
|
+
x2="100%"
|
|
70
|
+
y2="0%"
|
|
71
|
+
stops={dataSource}>
|
|
72
|
+
<Rect {...styles.sliderLinearGradient} width={width} />
|
|
73
|
+
</LinearGradient>
|
|
74
|
+
</View>
|
|
75
|
+
)
|
|
76
|
+
}}
|
|
77
|
+
onValueChange={(value) => {
|
|
78
|
+
state.value = value
|
|
79
|
+
}}
|
|
80
|
+
onSlidingComplete={onSlidingComplete}
|
|
81
|
+
/>
|
|
82
|
+
</View>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const styles = StyleSheet.create({
|
|
87
|
+
container: {
|
|
88
|
+
height: cx(57),
|
|
89
|
+
flexDirection: 'column',
|
|
90
|
+
paddingHorizontal: cx(16),
|
|
91
|
+
},
|
|
92
|
+
titleBg: {
|
|
93
|
+
flexDirection: 'row',
|
|
94
|
+
justifyContent: 'space-between',
|
|
95
|
+
},
|
|
96
|
+
valueText: {
|
|
97
|
+
marginTop: cx(10),
|
|
98
|
+
fontSize: cx(14),
|
|
99
|
+
color: '#000',
|
|
100
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
101
|
+
},
|
|
102
|
+
title: {
|
|
103
|
+
marginTop: cx(4),
|
|
104
|
+
fontSize: cx(14),
|
|
105
|
+
color: '#000',
|
|
106
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
107
|
+
},
|
|
108
|
+
shadeSlider: {
|
|
109
|
+
marginTop: cx(8),
|
|
110
|
+
height: cx(28),
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
},
|
|
113
|
+
sliderTrack: {
|
|
114
|
+
marginTop: cx(9),
|
|
115
|
+
marginBottom: cx(9),
|
|
116
|
+
flex: 1,
|
|
117
|
+
borderRadius: cx(15),
|
|
118
|
+
},
|
|
119
|
+
shadeThumb: {
|
|
120
|
+
backgroundColor: 'rgb(0, 249, 255)',
|
|
121
|
+
width: cx(28),
|
|
122
|
+
height: cx(28),
|
|
123
|
+
borderRadius: cx(14),
|
|
124
|
+
borderColor: 'white',
|
|
125
|
+
borderWidth: 1,
|
|
126
|
+
shadowColor: '#000000',
|
|
127
|
+
shadowOpacity: 0.2,
|
|
128
|
+
shadowRadius: cx(8),
|
|
129
|
+
elevation: cx(8),
|
|
130
|
+
shadowOffset: {
|
|
131
|
+
width: 0,
|
|
132
|
+
height: cx(4),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
sliderLinearGradient: {
|
|
136
|
+
height: cx(12),
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
export default LdvTemperatureSlider
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface TopBarProps {
|
|
2
|
+
title: string;
|
|
3
|
+
onBackPress: () => void;
|
|
4
|
+
rightButtonIcon?: any | {};
|
|
5
|
+
rightButtonStyle?: any | undefined;
|
|
6
|
+
onRightButtonPress?: (() => void) | undefined;
|
|
7
|
+
}
|
|
8
|
+
declare const LDVTopBar: (props: TopBarProps) => JSX.Element;
|
|
9
|
+
export default LDVTopBar;
|