@ledvance/base 1.1.13 → 1.1.15
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/.prettierrc.js +0 -0
- package/package.json +1 -1
- package/src/api/native.d.ts +5 -0
- package/src/api/native.ts +193 -160
- package/src/api/nativeEventEmitter.ts +54 -54
- package/src/components/Card.tsx +25 -25
- package/src/components/Cell.tsx +32 -32
- package/src/components/ColorAdjustView.tsx +44 -44
- package/src/components/ColorTempAdjustView.tsx +37 -37
- package/src/components/ColorsLine.d.ts +7 -0
- package/src/components/ColorsLine.tsx +48 -0
- package/src/components/DeleteButton.d.ts +1 -1
- package/src/components/DeleteButton.tsx +27 -27
- package/src/components/Dialog.tsx +28 -28
- package/src/components/FanAdjustView.tsx +115 -105
- package/src/components/InfoText.tsx +29 -29
- package/src/components/LampAdjustView.tsx +52 -52
- package/src/components/LinearGradientLine.tsx +53 -53
- package/src/components/MoodColorsLine.d.ts +9 -0
- package/src/components/MoodColorsLine.tsx +38 -0
- package/src/components/Page.tsx +34 -34
- package/src/components/Popup.tsx +17 -17
- package/src/components/Segmented.d.ts +2 -2
- package/src/components/Segmented.tsx +66 -65
- package/src/components/Spacer.tsx +5 -5
- package/src/components/Tag.tsx +42 -42
- package/src/components/TextButton.d.ts +1 -1
- package/src/components/TextButton.tsx +23 -23
- package/src/components/TextField.tsx +58 -58
- package/src/components/connect.tsx +10 -10
- package/src/components/ldvColorBrightness.tsx +12 -12
- package/src/components/ldvColorSlider.tsx +109 -109
- package/src/components/ldvPickerView.tsx +70 -70
- package/src/components/ldvPresetView.tsx +68 -68
- package/src/components/ldvSaturation.tsx +14 -14
- package/src/components/ldvSlider.d.ts +3 -3
- package/src/components/ldvSlider.tsx +93 -93
- package/src/components/ldvSwitch.tsx +35 -35
- package/src/components/ldvTemperatureSlider.tsx +120 -120
- package/src/components/ldvTopBar.tsx +50 -50
- package/src/components/ldvTopName.tsx +44 -44
- package/src/components/segmentControl.tsx +59 -59
- package/src/components/weekSelect.tsx +76 -76
- package/src/composeLayout.tsx +165 -165
- package/src/i18n/index.ts +12 -12
- package/src/i18n/strings.ts +11004 -11004
- package/src/main.tsx +4 -4
- package/src/models/GlobalParams.ts +7 -7
- package/src/models/TuyaApi.d.ts +3 -3
- package/src/models/TuyaApi.ts +61 -61
- package/src/models/combine.ts +7 -7
- package/src/models/configureStore.ts +14 -14
- package/src/models/index.ts +4 -4
- package/src/models/modules/NativePropsSlice.tsx +170 -169
- package/src/models/modules/Result.ts +8 -8
- package/src/models/modules/common.ts +90 -90
- package/src/res/index.ts +35 -35
- package/src/utils/ColorParser.ts +150 -150
- package/src/utils/ColorUtils.tsx +414 -414
- package/src/utils/Support.d.ts +9 -0
- package/src/utils/Support.ts +85 -0
- package/src/utils/cctUtils.d.ts +1 -0
- package/src/utils/cctUtils.ts +111 -0
- package/src/utils/common.ts +186 -174
- package/src/utils/index.ts +123 -123
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {Utils} from 'tuya-panel-kit'
|
|
3
3
|
import Card from './Card'
|
|
4
|
-
import {
|
|
4
|
+
import {Image, Text, TouchableOpacity, View, ViewProps} from 'react-native'
|
|
5
5
|
import LdvSwitch from './ldvSwitch'
|
|
6
6
|
import I18n from '@i18n'
|
|
7
7
|
import LdvSlider from './ldvSlider'
|
|
@@ -9,116 +9,126 @@ import Spacer from './Spacer'
|
|
|
9
9
|
import res from '../res'
|
|
10
10
|
import Segmented from './Segmented'
|
|
11
11
|
import Popup from './Popup'
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
13
14
|
|
|
14
15
|
interface FanAdjustViewProps extends ViewProps {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
fanEnable: boolean
|
|
17
|
+
fanSpeed: number
|
|
18
|
+
maxFanSpeed?: number
|
|
19
|
+
isSupportDirection?: boolean
|
|
20
|
+
isSupportDisinfect?: boolean
|
|
21
|
+
isSupportMode?: boolean
|
|
22
|
+
directValue?: string
|
|
23
|
+
modeValue?: string
|
|
24
|
+
disinfect?: boolean
|
|
25
|
+
directOptions?: any[]
|
|
26
|
+
modeOptions?: any[]
|
|
27
|
+
directChange?: (direct: string) => void
|
|
28
|
+
modeChange?: (mode: string) => void
|
|
29
|
+
disinfectChange?: (disinfect: boolean) => void
|
|
30
|
+
onFanSwitch: (fanEnable: boolean) => void
|
|
31
|
+
onFanSpeedChange?: (fanSpeed: number) => void
|
|
32
|
+
onFanSpeedChangeComplete: (fanSpeed: number) => void
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const FanAdjustView = (props: FanAdjustViewProps) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
36
|
+
return (
|
|
37
|
+
<Card
|
|
38
|
+
style={props.style}>
|
|
39
|
+
<LdvSwitch
|
|
40
|
+
title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_headline')}
|
|
41
|
+
enable={props.fanEnable}
|
|
42
|
+
setEnable={props.onFanSwitch}
|
|
43
|
+
color={''}
|
|
44
|
+
colorAlpha={1}/>
|
|
45
|
+
{props.fanEnable && (
|
|
46
|
+
<View>
|
|
47
|
+
<LdvSlider
|
|
48
|
+
title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_text')}
|
|
49
|
+
value={props.fanSpeed}
|
|
50
|
+
min={1}
|
|
51
|
+
max={props.maxFanSpeed}
|
|
52
|
+
onValueChange={props.onFanSpeedChange}
|
|
53
|
+
onSlidingComplete={props.onFanSpeedChangeComplete}
|
|
54
|
+
subTitleStr={props.fanSpeed + `/${props.maxFanSpeed}`}/>
|
|
55
|
+
<Spacer/>
|
|
56
|
+
</View>
|
|
57
|
+
)}
|
|
58
|
+
{props.fanEnable && props.isSupportDirection && <View style={{marginHorizontal: cx(16)}}>
|
|
59
|
+
<View style={{flexDirection: 'row', marginBottom: cx(2), alignItems: 'center'}}>
|
|
60
|
+
<Text style={{
|
|
61
|
+
marginRight: cx(5),
|
|
62
|
+
color: '#000',
|
|
63
|
+
}}>{I18n.getLang('ceiling_fan_tile_uvc_fan_direction')}</Text>
|
|
64
|
+
<TouchableOpacity onPress={() => Popup({
|
|
65
|
+
title: I18n.getLang('ceiling_fan_direction_info_headline'),
|
|
66
|
+
confirmText: I18n.getLang('ceiling_fan_direction_info_button_label'),
|
|
67
|
+
content: <View>
|
|
68
|
+
<Text style={{
|
|
69
|
+
fontWeight: 'bold',
|
|
70
|
+
color: '#000',
|
|
71
|
+
}}>{I18n.getLang('ceiling_fan_direction_info_description_text')}</Text>
|
|
72
|
+
<Spacer/>
|
|
73
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_1_headline')}</Text>
|
|
74
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_1_text')}</Text>
|
|
75
|
+
<Spacer/>
|
|
76
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_2_headline')}</Text>
|
|
77
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_2_text')}</Text>
|
|
78
|
+
</View>,
|
|
79
|
+
})}>
|
|
80
|
+
<Image style={{width: cx(16), height: cx(16), tintColor: '#ff6600'}} source={{uri: res.ic_info}}/>
|
|
81
|
+
</TouchableOpacity>
|
|
82
|
+
</View>
|
|
83
|
+
<Segmented
|
|
84
|
+
options={props.directOptions}
|
|
85
|
+
value={props.directValue}
|
|
86
|
+
onChange={props.directChange}
|
|
87
|
+
/>
|
|
88
|
+
<Spacer/>
|
|
89
|
+
</View>}
|
|
83
90
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
{props.fanEnable && props.isSupportMode && <View style={{marginHorizontal: cx(16)}}>
|
|
92
|
+
<View style={{flexDirection: 'row', marginBottom: cx(2), alignItems: 'center'}}>
|
|
93
|
+
<Text style={{marginRight: cx(5), color: '#000'}}>{I18n.getLang('ceiling_fan_tile_uvc_fan_mode')}</Text>
|
|
94
|
+
<TouchableOpacity onPress={() => Popup({
|
|
95
|
+
title: I18n.getLang('ceiling_fan_mode_info_headline'),
|
|
96
|
+
confirmText: I18n.getLang('ceiling_fan_direction_info_button_label'),
|
|
97
|
+
content: <View>
|
|
98
|
+
<Text style={{
|
|
99
|
+
fontWeight: 'bold',
|
|
100
|
+
color: '#000',
|
|
101
|
+
}}>{I18n.getLang('ceiling_fan_mode_info_description_text')}</Text>
|
|
102
|
+
<Spacer/>
|
|
103
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_1_headline')}</Text>
|
|
104
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_1_text')}</Text>
|
|
105
|
+
<Spacer/>
|
|
106
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_2_headline')}</Text>
|
|
107
|
+
<Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_2_text')}</Text>
|
|
108
|
+
</View>,
|
|
109
|
+
})}>
|
|
110
|
+
<Image style={{width: cx(16), height: cx(16), tintColor: '#ff6600'}} source={{uri: res.ic_info}}/>
|
|
111
|
+
</TouchableOpacity>
|
|
112
|
+
</View>
|
|
113
|
+
<Segmented
|
|
114
|
+
options={props.modeOptions}
|
|
115
|
+
value={props.modeValue}
|
|
116
|
+
onChange={props.modeChange}
|
|
117
|
+
/>
|
|
118
|
+
<Spacer/>
|
|
119
|
+
</View>}
|
|
110
120
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
{props.fanEnable && props.isSupportDisinfect && <>
|
|
122
|
+
<LdvSwitch
|
|
123
|
+
enable={props.disinfect || false}
|
|
124
|
+
setEnable={props.disinfectChange}
|
|
125
|
+
color={''}
|
|
126
|
+
colorAlpha={1}
|
|
127
|
+
title={'1'}/>
|
|
128
|
+
<Spacer height={cx(16)}/>
|
|
129
|
+
</>}
|
|
130
|
+
</Card>
|
|
131
|
+
)
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
export default FanAdjustView
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, View, ViewProps} from 'react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import {Utils} from 'tuya-panel-kit'
|
|
4
4
|
import Spacer from './Spacer'
|
|
5
5
|
|
|
6
6
|
const cx = Utils.RatioUtils.convertX
|
|
7
7
|
|
|
8
8
|
interface InfoTextProps extends ViewProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
icon: string
|
|
10
|
+
text: string
|
|
11
|
+
contentColor?: string
|
|
12
|
+
iconStyle?: StyleProp<ImageStyle>
|
|
13
|
+
textStyle?: StyleProp<TextStyle>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const InfoText = (props: InfoTextProps) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const contentColor = props.contentColor || '#666666'
|
|
18
|
+
return (
|
|
19
|
+
<View style={styles.root}>
|
|
20
|
+
<Image style={[styles.icon, props.iconStyle, {tintColor: contentColor}]}
|
|
21
|
+
source={{uri: props.icon}}/>
|
|
22
|
+
<Spacer width={cx(4)} height={0}/>
|
|
23
|
+
<Text style={[styles.text, props.textStyle, {color: contentColor}]}>{props.text}</Text>
|
|
24
|
+
</View>
|
|
25
|
+
)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const styles = StyleSheet.create({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
root: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
},
|
|
32
|
+
icon: {
|
|
33
|
+
width: cx(16),
|
|
34
|
+
height: cx(16),
|
|
35
|
+
},
|
|
36
|
+
text: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
marginTop: cx(2.5),
|
|
39
|
+
fontSize: cx(12),
|
|
40
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
41
|
+
},
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
export default InfoText
|
|
@@ -11,66 +11,66 @@ import I18n from '../i18n/index'
|
|
|
11
11
|
const {convertX: cx} = Utils.RatioUtils
|
|
12
12
|
|
|
13
13
|
interface LampConfigViewProps extends ColorAdjustViewProps, ColorTempAdjustViewProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
isRGBWLamp: boolean
|
|
15
|
+
isRGBLamp: boolean
|
|
16
|
+
isOnlyRGBLamp: boolean
|
|
17
|
+
isTWLamp: boolean
|
|
18
|
+
isDIMLamp: boolean
|
|
19
|
+
isColorMode: boolean
|
|
20
|
+
setIsColorMode: (isColorMode: boolean) => void
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const LampAdjustView = (props: LampConfigViewProps) => {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const state = useReactive({
|
|
26
|
+
hasSegmentControl: props.isRGBWLamp || props.isRGBLamp,
|
|
27
|
+
})
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
29
|
+
return (
|
|
30
|
+
<View>
|
|
31
|
+
{state.hasSegmentControl &&
|
|
32
|
+
<SegmentControl
|
|
33
|
+
style={styles.segmentControl}
|
|
34
|
+
title1={I18n.getLang('light_sources_tile_rgb_lighting_tab_color')}
|
|
35
|
+
title2={I18n.getLang('light_sources_tile_rgb_lighting_tab_white')}
|
|
36
|
+
isFirst={props.isColorMode}
|
|
37
|
+
setIsFirst={props.setIsColorMode}/>
|
|
38
|
+
}
|
|
39
|
+
{(props.isOnlyRGBLamp || (state.hasSegmentControl && props.isColorMode)) &&
|
|
40
|
+
<>
|
|
41
|
+
{state.hasSegmentControl && <Spacer height={cx(10)}/>}
|
|
42
|
+
<ColorAdjustView
|
|
43
|
+
h={props.h}
|
|
44
|
+
s={props.s}
|
|
45
|
+
v={props.v}
|
|
46
|
+
onHSVChange={props.onHSVChange}
|
|
47
|
+
onHSVChangeComplete={props.onHSVChangeComplete}/>
|
|
48
|
+
<Spacer/>
|
|
49
|
+
</>
|
|
50
|
+
}
|
|
51
|
+
{(props.isTWLamp || props.isDIMLamp || (!props.isColorMode)) &&
|
|
52
|
+
<>
|
|
53
|
+
{state.hasSegmentControl && <Spacer height={cx(10)}/>}
|
|
54
|
+
<ColorTempAdjustView
|
|
55
|
+
isSupportTemperature={props.isSupportTemperature}
|
|
56
|
+
isSupportBrightness={props.isSupportBrightness}
|
|
57
|
+
colorTemp={props.colorTemp}
|
|
58
|
+
brightness={props.brightness}
|
|
59
|
+
onCCTChange={props.onCCTChange}
|
|
60
|
+
onCCTChangeComplete={props.onCCTChangeComplete}
|
|
61
|
+
onBrightnessChange={props.onBrightnessChange}
|
|
62
|
+
onBrightnessChangeComplete={props.onBrightnessChangeComplete}/>
|
|
63
|
+
<Spacer/>
|
|
64
|
+
</>
|
|
65
|
+
}
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const styles = StyleSheet.create({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
segmentControl: {
|
|
72
|
+
marginHorizontal: cx(16),
|
|
73
|
+
},
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
export default LampAdjustView
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import {LinearGradient} from 'tuya-panel-kit'
|
|
2
|
+
import React, {useEffect} from 'react'
|
|
3
|
+
import {Rect} from 'react-native-svg'
|
|
4
|
+
import {StyleProp, View} from 'react-native'
|
|
5
|
+
import {useReactive} from 'ahooks'
|
|
6
6
|
|
|
7
7
|
interface LinearGradientLineProps extends StyleProp<any> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
width: number
|
|
9
|
+
height: number
|
|
10
|
+
colors: string[]
|
|
11
|
+
orientation?: 'vertical' | 'horizontal'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const LinearGradientLine = (props: LinearGradientLineProps) => {
|
|
15
|
-
|
|
15
|
+
const {width, height} = props
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const state = useReactive({
|
|
18
|
+
x1: '0%',
|
|
19
|
+
y1: '50%',
|
|
20
|
+
x2: '100%',
|
|
21
|
+
y2: '50%',
|
|
22
|
+
stops: {},
|
|
23
|
+
})
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (props.orientation === 'vertical') {
|
|
27
|
+
state.x1 = '50%'
|
|
28
|
+
state.y1 = '0%'
|
|
29
|
+
state.x2 = '50%'
|
|
30
|
+
state.y2 = '100%'
|
|
31
|
+
} else {
|
|
32
|
+
state.x1 = '0%'
|
|
33
|
+
state.y1 = '50%'
|
|
34
|
+
state.x2 = '100%'
|
|
35
|
+
state.y2 = '50%'
|
|
36
|
+
}
|
|
37
|
+
}, [props.orientation])
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const p = (1 / (props.colors.length - 1)) * 100
|
|
41
|
+
let pc = 0
|
|
42
|
+
props.colors.forEach(color => {
|
|
43
|
+
state.stops[`${pc}%`] = color
|
|
44
|
+
pc += p
|
|
45
|
+
})
|
|
46
|
+
console.log('LinearGradientLine colors', JSON.stringify(state.stops))
|
|
47
|
+
}, [props.colors])
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
return (
|
|
50
|
+
<View style={[{width, height, overflow: 'hidden'}, props.style]}>
|
|
51
|
+
<LinearGradient
|
|
52
|
+
gradientId="Gradient"
|
|
53
|
+
style={{width, height}}
|
|
54
|
+
x1={state.x1}
|
|
55
|
+
y1={state.y1}
|
|
56
|
+
x2={state.x2}
|
|
57
|
+
y2={state.y2}
|
|
58
|
+
stops={state.stops}>
|
|
59
|
+
<Rect width={width} height={height}/>
|
|
60
|
+
</LinearGradient>
|
|
61
|
+
</View>
|
|
62
|
+
)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export default LinearGradientLine
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type MoodColorsLineType = 'gradient' | 'separate';
|
|
2
|
+
interface MoodColorsLineProps {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
type: MoodColorsLineType;
|
|
6
|
+
colors: string[];
|
|
7
|
+
}
|
|
8
|
+
export default function MoodColorsLine(props: MoodColorsLineProps): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import LinearGradientLine from './LinearGradientLine'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {Utils} from 'tuya-panel-kit'
|
|
4
|
+
import {StyleSheet} from 'react-native'
|
|
5
|
+
import ColorsLine from './ColorsLine'
|
|
6
|
+
|
|
7
|
+
const cx = Utils.RatioUtils.convertX
|
|
8
|
+
|
|
9
|
+
export type MoodColorsLineType = 'gradient' | 'separate'
|
|
10
|
+
|
|
11
|
+
interface MoodColorsLineProps {
|
|
12
|
+
width?: number
|
|
13
|
+
height?: number
|
|
14
|
+
type: MoodColorsLineType
|
|
15
|
+
colors: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function MoodColorsLine(props: MoodColorsLineProps) {
|
|
19
|
+
const width = props.width || cx(295)
|
|
20
|
+
const height = props.height || cx(24)
|
|
21
|
+
if (props.type === 'separate' || props.colors.length < 2) {
|
|
22
|
+
return (<ColorsLine colors={props.colors} style={{width, height}}/>)
|
|
23
|
+
} else {
|
|
24
|
+
return (
|
|
25
|
+
<LinearGradientLine
|
|
26
|
+
width={width}
|
|
27
|
+
height={height}
|
|
28
|
+
style={styles.gradient}
|
|
29
|
+
colors={props.colors}/>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
gradient: {
|
|
36
|
+
borderRadius: cx(8),
|
|
37
|
+
},
|
|
38
|
+
})
|