@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.
Files changed (65) hide show
  1. package/.prettierrc.js +0 -0
  2. package/package.json +1 -1
  3. package/src/api/native.d.ts +5 -0
  4. package/src/api/native.ts +193 -160
  5. package/src/api/nativeEventEmitter.ts +54 -54
  6. package/src/components/Card.tsx +25 -25
  7. package/src/components/Cell.tsx +32 -32
  8. package/src/components/ColorAdjustView.tsx +44 -44
  9. package/src/components/ColorTempAdjustView.tsx +37 -37
  10. package/src/components/ColorsLine.d.ts +7 -0
  11. package/src/components/ColorsLine.tsx +48 -0
  12. package/src/components/DeleteButton.d.ts +1 -1
  13. package/src/components/DeleteButton.tsx +27 -27
  14. package/src/components/Dialog.tsx +28 -28
  15. package/src/components/FanAdjustView.tsx +115 -105
  16. package/src/components/InfoText.tsx +29 -29
  17. package/src/components/LampAdjustView.tsx +52 -52
  18. package/src/components/LinearGradientLine.tsx +53 -53
  19. package/src/components/MoodColorsLine.d.ts +9 -0
  20. package/src/components/MoodColorsLine.tsx +38 -0
  21. package/src/components/Page.tsx +34 -34
  22. package/src/components/Popup.tsx +17 -17
  23. package/src/components/Segmented.d.ts +2 -2
  24. package/src/components/Segmented.tsx +66 -65
  25. package/src/components/Spacer.tsx +5 -5
  26. package/src/components/Tag.tsx +42 -42
  27. package/src/components/TextButton.d.ts +1 -1
  28. package/src/components/TextButton.tsx +23 -23
  29. package/src/components/TextField.tsx +58 -58
  30. package/src/components/connect.tsx +10 -10
  31. package/src/components/ldvColorBrightness.tsx +12 -12
  32. package/src/components/ldvColorSlider.tsx +109 -109
  33. package/src/components/ldvPickerView.tsx +70 -70
  34. package/src/components/ldvPresetView.tsx +68 -68
  35. package/src/components/ldvSaturation.tsx +14 -14
  36. package/src/components/ldvSlider.d.ts +3 -3
  37. package/src/components/ldvSlider.tsx +93 -93
  38. package/src/components/ldvSwitch.tsx +35 -35
  39. package/src/components/ldvTemperatureSlider.tsx +120 -120
  40. package/src/components/ldvTopBar.tsx +50 -50
  41. package/src/components/ldvTopName.tsx +44 -44
  42. package/src/components/segmentControl.tsx +59 -59
  43. package/src/components/weekSelect.tsx +76 -76
  44. package/src/composeLayout.tsx +165 -165
  45. package/src/i18n/index.ts +12 -12
  46. package/src/i18n/strings.ts +11004 -11004
  47. package/src/main.tsx +4 -4
  48. package/src/models/GlobalParams.ts +7 -7
  49. package/src/models/TuyaApi.d.ts +3 -3
  50. package/src/models/TuyaApi.ts +61 -61
  51. package/src/models/combine.ts +7 -7
  52. package/src/models/configureStore.ts +14 -14
  53. package/src/models/index.ts +4 -4
  54. package/src/models/modules/NativePropsSlice.tsx +170 -169
  55. package/src/models/modules/Result.ts +8 -8
  56. package/src/models/modules/common.ts +90 -90
  57. package/src/res/index.ts +35 -35
  58. package/src/utils/ColorParser.ts +150 -150
  59. package/src/utils/ColorUtils.tsx +414 -414
  60. package/src/utils/Support.d.ts +9 -0
  61. package/src/utils/Support.ts +85 -0
  62. package/src/utils/cctUtils.d.ts +1 -0
  63. package/src/utils/cctUtils.ts +111 -0
  64. package/src/utils/common.ts +186 -174
  65. package/src/utils/index.ts +123 -123
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
- import { Utils } from 'tuya-panel-kit'
2
+ import {Utils} from 'tuya-panel-kit'
3
3
  import Card from './Card'
4
- import {View, Text, ViewProps, Image, TouchableOpacity} from 'react-native'
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
- const { convertX: cx } = Utils.RatioUtils
12
+
13
+ const {convertX: cx} = Utils.RatioUtils
13
14
 
14
15
  interface FanAdjustViewProps extends ViewProps {
15
- fanEnable: boolean
16
- fanSpeed: number
17
- maxFanSpeed?: number
18
- isSupportDirection?: boolean
19
- isSupportDisinfect?: boolean
20
- isSupportMode?: boolean
21
- directValue?: string
22
- modeValue?: string
23
- disinfect?: boolean
24
- directOptions?:any[]
25
- modeOptions?: any[]
26
- directChange?: (direct:string) => void
27
- modeChange?: (mode: string) => void
28
- disinfectChange?: (disinfect: boolean) => void
29
- onFanSwitch: (fanEnable: boolean) => void
30
- onFanSpeedChange?: (fanSpeed: number) => void
31
- onFanSpeedChangeComplete: (fanSpeed: number) => void
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
- return (
36
- <Card
37
- style={props.style}>
38
- <LdvSwitch
39
- title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_headline')}
40
- enable={props.fanEnable}
41
- setEnable={props.onFanSwitch}
42
- color={''}
43
- colorAlpha={1}/>
44
- {props.fanEnable && (
45
- <View>
46
- <LdvSlider
47
- title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_text')}
48
- value={props.fanSpeed}
49
- min={1}
50
- max={props.maxFanSpeed}
51
- onValueChange={props.onFanSpeedChange}
52
- onSlidingComplete={props.onFanSpeedChangeComplete}
53
- subTitleStr={props.fanSpeed + `/${props.maxFanSpeed}`}/>
54
- <Spacer/>
55
- </View>
56
- )}
57
- {props.fanEnable && props.isSupportDirection && <View style={{marginHorizontal: cx(16)}}>
58
- <View style={{flexDirection: 'row', marginBottom: cx(2), alignItems: 'center'}}>
59
- <Text style={{marginRight: cx(5), color: '#000'}}>{I18n.getLang('ceiling_fan_tile_uvc_fan_direction')}</Text>
60
- <TouchableOpacity onPress={() => Popup({
61
- title: I18n.getLang('ceiling_fan_direction_info_headline'),
62
- confirmText: I18n.getLang('ceiling_fan_direction_info_button_label'),
63
- content: <View>
64
- <Text style={{fontWeight: 'bold', color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_description_text')}</Text>
65
- <Spacer />
66
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_1_headline')}</Text>
67
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_1_text')}</Text>
68
- <Spacer />
69
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_2_headline')}</Text>
70
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_direction_info_option_2_text')}</Text>
71
- </View>
72
- })}>
73
- <Image style={{width: cx(16), height: cx(16), tintColor: '#ff6600'}} source={{uri: res.ic_info}}/>
74
- </TouchableOpacity>
75
- </View>
76
- <Segmented
77
- options={props.directOptions}
78
- value={props.directValue}
79
- onChange={props.directChange}
80
- />
81
- <Spacer />
82
- </View>}
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
- {props.fanEnable && props.isSupportMode && <View style={{marginHorizontal: cx(16)}}>
85
- <View style={{flexDirection: 'row', marginBottom: cx(2), alignItems: 'center'}}>
86
- <Text style={{marginRight: cx(5), color: '#000'}}>{I18n.getLang('ceiling_fan_tile_uvc_fan_mode')}</Text>
87
- <TouchableOpacity onPress={() => Popup({
88
- title: I18n.getLang('ceiling_fan_mode_info_headline'),
89
- confirmText: I18n.getLang('ceiling_fan_direction_info_button_label'),
90
- content: <View>
91
- <Text style={{fontWeight: 'bold', color:'#000'}}>{I18n.getLang('ceiling_fan_mode_info_description_text')}</Text>
92
- <Spacer />
93
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_1_headline')}</Text>
94
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_1_text')}</Text>
95
- <Spacer />
96
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_2_headline')}</Text>
97
- <Text style={{color: '#000'}}>{I18n.getLang('ceiling_fan_mode_info_option_2_text')}</Text>
98
- </View>
99
- })}>
100
- <Image style={{width: cx(16), height: cx(16), tintColor: '#ff6600'}} source={{uri: res.ic_info}}/>
101
- </TouchableOpacity>
102
- </View>
103
- <Segmented
104
- options={props.modeOptions}
105
- value={props.modeValue}
106
- onChange={props.modeChange}
107
- />
108
- <Spacer />
109
- </View>}
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
- {props.fanEnable && props.isSupportDisinfect && <>
112
- <LdvSwitch
113
- enable={props.disinfect || false}
114
- setEnable={props.disinfectChange}
115
- color={''}
116
- colorAlpha={1}
117
- title={'1'}/>
118
- <Spacer height={cx(16)}/>
119
- </>}
120
- </Card>
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 { Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, View, ViewProps } from 'react-native'
1
+ import {Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, View, ViewProps} from 'react-native'
2
2
  import React from 'react'
3
- import { Utils } from 'tuya-panel-kit'
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
- icon: string
10
- text: string
11
- contentColor?: string
12
- iconStyle?: StyleProp<ImageStyle>
13
- textStyle?: StyleProp<TextStyle>
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
- 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
- )
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
- 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
- },
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
- isRGBWLamp: boolean
15
- isRGBLamp: boolean
16
- isOnlyRGBLamp: boolean
17
- isTWLamp: boolean
18
- isDIMLamp: boolean
19
- isColorMode: boolean
20
- setIsColorMode: (isColorMode: boolean) => void
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
- const state = useReactive({
26
- hasSegmentControl: props.isRGBWLamp || props.isRGBLamp,
27
- })
25
+ const state = useReactive({
26
+ hasSegmentControl: props.isRGBWLamp || props.isRGBLamp,
27
+ })
28
28
 
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
- )
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
- segmentControl: {
72
- marginHorizontal: cx(16),
73
- },
71
+ segmentControl: {
72
+ marginHorizontal: cx(16),
73
+ },
74
74
  })
75
75
 
76
76
  export default LampAdjustView
@@ -1,65 +1,65 @@
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'
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
- width: number
9
- height: number
10
- colors: string[]
11
- orientation?: 'vertical' | 'horizontal'
8
+ width: number
9
+ height: number
10
+ colors: string[]
11
+ orientation?: 'vertical' | 'horizontal'
12
12
  }
13
13
 
14
14
  const LinearGradientLine = (props: LinearGradientLineProps) => {
15
- const { width, height } = props
15
+ const {width, height} = props
16
16
 
17
- const state = useReactive({
18
- x1: '0%',
19
- y1: '50%',
20
- x2: '100%',
21
- y2: '50%',
22
- stops: {},
23
- })
17
+ const state = useReactive({
18
+ x1: '0%',
19
+ y1: '50%',
20
+ x2: '100%',
21
+ y2: '50%',
22
+ stops: {},
23
+ })
24
24
 
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])
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
- 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])
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
- 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
- )
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
+ })