@ledvance/base 1.3.108 → 1.3.110
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/localazy.json +2 -1
- package/package.json +1 -1
- package/src/components/AdvanceCard.tsx +6 -1
- package/src/components/AdvanceList.tsx +65 -44
- package/src/components/BallDirectionView.tsx +19 -17
- package/src/components/ColorAdjustView.tsx +44 -37
- package/src/components/ColorTempAdjustView.tsx +42 -41
- package/src/components/MoodColorsLine.tsx +33 -23
- package/src/components/ldvColorSlider.tsx +59 -45
- package/src/i18n/strings.ts +58 -28
- package/src/models/TuyaApi.ts +7 -6
- package/src/utils/index.ts +5 -4
- package/translateKey.txt +2 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import React, { useMemo } 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
|
-
import ThemeType from '../config/themeType'
|
|
6
|
-
import { useIsPad } from '../models/modules/NativePropsSlice'
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import { StyleProp, StyleSheet, Text, View, ViewStyle, LayoutChangeEvent } from 'react-native';
|
|
3
|
+
import { LinearGradient, Slider, Utils } from 'tuya-panel-kit';
|
|
4
|
+
import { Rect } from 'react-native-svg';
|
|
5
|
+
import ThemeType from '../config/themeType';
|
|
7
6
|
|
|
8
|
-
const { convertX: cx
|
|
9
|
-
const { withTheme } = Utils.ThemeUtils
|
|
7
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
8
|
+
const { withTheme } = Utils.ThemeUtils;
|
|
10
9
|
|
|
11
10
|
const temperatures = {
|
|
12
11
|
'0%': 'rgb(254, 172, 90)',
|
|
@@ -15,7 +14,7 @@ const temperatures = {
|
|
|
15
14
|
'60%': 'rgb(252, 250, 242)',
|
|
16
15
|
'80%': 'rgb(226, 235, 248)',
|
|
17
16
|
'100%': 'rgb(194, 217, 254)',
|
|
18
|
-
}
|
|
17
|
+
};
|
|
19
18
|
|
|
20
19
|
const colors = {
|
|
21
20
|
'0%': 'rgb(255, 0, 0)',
|
|
@@ -25,31 +24,38 @@ const colors = {
|
|
|
25
24
|
'65%': 'rgb(43, 0, 255)',
|
|
26
25
|
'80%': 'rgb(180, 0, 255)',
|
|
27
26
|
'100%': 'rgb(255, 0, 0)',
|
|
28
|
-
}
|
|
27
|
+
};
|
|
29
28
|
|
|
30
|
-
export const TEMP_KEY = 'temperature'
|
|
29
|
+
export const TEMP_KEY = 'temperature';
|
|
31
30
|
|
|
32
31
|
interface LdvColorSliderProps {
|
|
33
|
-
theme?: ThemeType
|
|
34
|
-
title: string
|
|
35
|
-
type: string
|
|
36
|
-
onValueChange?: (number) => void | undefined
|
|
37
|
-
onSlidingComplete: (number) => void
|
|
38
|
-
thumbColor: string
|
|
39
|
-
value: number
|
|
40
|
-
width?: number | undefined
|
|
41
|
-
style?: StyleProp<ViewStyle> | undefined
|
|
32
|
+
theme?: ThemeType;
|
|
33
|
+
title: string;
|
|
34
|
+
type: string;
|
|
35
|
+
onValueChange?: (number) => void | undefined;
|
|
36
|
+
onSlidingComplete: (number) => void;
|
|
37
|
+
thumbColor: string;
|
|
38
|
+
value: number;
|
|
39
|
+
width?: number | undefined;
|
|
40
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
const LdvColorSlider = (props: LdvColorSliderProps) => {
|
|
45
|
-
const {title, type, onSlidingComplete, thumbColor, value} = props
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
44
|
+
const { title, type, onSlidingComplete, thumbColor, value } = props;
|
|
45
|
+
const dataSource = type === TEMP_KEY ? temperatures : colors;
|
|
46
|
+
const max = type === TEMP_KEY ? 100 : 359;
|
|
47
|
+
const min = type === TEMP_KEY ? 0 : 0;
|
|
48
|
+
|
|
49
|
+
const [sliderWidth, setSliderWidth] = useState(0);
|
|
51
50
|
|
|
52
|
-
const styles = useMemo(() => getStyles(props.theme), [props.theme])
|
|
51
|
+
const styles = useMemo(() => getStyles(props.theme), [props.theme]);
|
|
52
|
+
|
|
53
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
54
|
+
const { width } = event.nativeEvent.layout;
|
|
55
|
+
if (width > 0 && width !== sliderWidth) {
|
|
56
|
+
setSliderWidth(width);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
53
59
|
|
|
54
60
|
return (
|
|
55
61
|
<View style={[styles.container, props.style]}>
|
|
@@ -58,8 +64,8 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
|
|
|
58
64
|
</Text>
|
|
59
65
|
<Slider.Horizontal
|
|
60
66
|
accessibilityLabel={"ColorSliderHorizontal"}
|
|
61
|
-
style={
|
|
62
|
-
styles={{track: styles.sliderTrack, thumb: {...styles.shadeThumb, backgroundColor: thumbColor}}}
|
|
67
|
+
style={styles.shadeSlider}
|
|
68
|
+
styles={{ track: styles.sliderTrack, thumb: { ...styles.shadeThumb, backgroundColor: thumbColor } }}
|
|
63
69
|
maximumValue={max}
|
|
64
70
|
minimumValue={min}
|
|
65
71
|
value={value}
|
|
@@ -71,32 +77,39 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
|
|
|
71
77
|
onlyMaximumTrack={true}
|
|
72
78
|
renderMaximumTrack={() => {
|
|
73
79
|
return (
|
|
74
|
-
<View style={{flex: 1, borderRadius: cx(15)}}>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
<View style={{ flex: 1, borderRadius: cx(15), overflow: 'hidden' }} onLayout={handleLayout}>
|
|
81
|
+
{sliderWidth > 0 && (
|
|
82
|
+
<LinearGradient
|
|
83
|
+
// 【关键改动 1】: 合并样式,使用样式表中的 height 和 state 中的 width
|
|
84
|
+
style={[styles.sliderLinearGradient, { width: sliderWidth }]}
|
|
85
|
+
x1="0%"
|
|
86
|
+
y1="0%"
|
|
87
|
+
x2="100%"
|
|
88
|
+
y2="0%"
|
|
89
|
+
stops={dataSource}>
|
|
90
|
+
{/* 【关键改动 2】: 为 Rect 提供明确的、数字类型的 height 和 width */}
|
|
91
|
+
<Rect
|
|
92
|
+
height={styles.sliderLinearGradient.height} // 使用样式表中的数字高度
|
|
93
|
+
width={sliderWidth} // 使用 state 中的数字宽度
|
|
94
|
+
/>
|
|
95
|
+
</LinearGradient>
|
|
96
|
+
)}
|
|
84
97
|
</View>
|
|
85
|
-
)
|
|
98
|
+
);
|
|
86
99
|
}}
|
|
87
100
|
onValueChange={props.onValueChange}
|
|
88
101
|
onSlidingComplete={onSlidingComplete}
|
|
89
102
|
/>
|
|
90
103
|
</View>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
104
|
+
);
|
|
105
|
+
};
|
|
93
106
|
|
|
94
107
|
const getStyles = (theme?: ThemeType) =>
|
|
95
108
|
StyleSheet.create({
|
|
96
109
|
container: {
|
|
97
110
|
height: cx(57),
|
|
98
111
|
flexDirection: 'column',
|
|
99
|
-
|
|
112
|
+
paddingHorizontal: cx(17),
|
|
100
113
|
},
|
|
101
114
|
title: {
|
|
102
115
|
marginTop: cx(4),
|
|
@@ -130,12 +143,13 @@ const getStyles = (theme?: ThemeType) =>
|
|
|
130
143
|
height: cx(4),
|
|
131
144
|
},
|
|
132
145
|
},
|
|
146
|
+
// 【关键】: 这个样式定义了渐变层的数字高度
|
|
133
147
|
sliderLinearGradient: {
|
|
134
148
|
height: cx(12),
|
|
135
149
|
},
|
|
136
150
|
presetView: {
|
|
137
151
|
height: cx(60),
|
|
138
152
|
},
|
|
139
|
-
})
|
|
153
|
+
});
|
|
140
154
|
|
|
141
|
-
export default withTheme(LdvColorSlider)
|
|
155
|
+
export default withTheme(LdvColorSlider);
|