@ledvance/base 1.3.103 → 1.3.105

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.
@@ -1,10 +1,11 @@
1
- import React from 'react'
1
+ import React, { useMemo } from 'react'
2
2
  import {StyleProp, StyleSheet, Text, View, ViewStyle} from 'react-native'
3
3
  import {LinearGradient, Slider, Utils} from 'tuya-panel-kit'
4
4
  import {Rect} from 'react-native-svg'
5
5
  import ThemeType from '../config/themeType'
6
+ import { useIsPad } from '../models/modules/NativePropsSlice'
6
7
 
7
- const cx = Utils.RatioUtils.convertX
8
+ const { convertX: cx, width: screenWidth } = Utils.RatioUtils
8
9
  const { withTheme } = Utils.ThemeUtils
9
10
 
10
11
  const temperatures = {
@@ -42,12 +43,56 @@ interface LdvColorSliderProps {
42
43
 
43
44
  const LdvColorSlider = (props: LdvColorSliderProps) => {
44
45
  const {title, type, onSlidingComplete, thumbColor, value} = props
46
+ const isPad = useIsPad()
45
47
  let dataSource = type === TEMP_KEY ? temperatures : colors
46
48
  let max = type === TEMP_KEY ? 100 : 359
47
49
  let min = type === TEMP_KEY ? 0 : 0
48
- const width = props.width || (Utils.RatioUtils.width - cx(80))
50
+ const width = props.width || (isPad ? cx(screenWidth - 10) : (screenWidth - 80))
49
51
 
50
- const styles = StyleSheet.create({
52
+ const styles = useMemo(() => getStyles(props.theme), [props.theme])
53
+
54
+ return (
55
+ <View style={[styles.container, props.style]}>
56
+ <Text accessibilityLabel={"Color"} accessibilityHint={`${value}`} style={styles.title}>
57
+ {title}
58
+ </Text>
59
+ <Slider.Horizontal
60
+ accessibilityLabel={"ColorSliderHorizontal"}
61
+ style={{...styles.shadeSlider, width}}
62
+ styles={{track: styles.sliderTrack, thumb: {...styles.shadeThumb, backgroundColor: thumbColor}}}
63
+ maximumValue={max}
64
+ minimumValue={min}
65
+ value={value}
66
+ stepValue={1}
67
+ canTouchTrack={true}
68
+ theme={{
69
+ trackRadius: cx(15),
70
+ }}
71
+ onlyMaximumTrack={true}
72
+ renderMaximumTrack={() => {
73
+ return (
74
+ <View style={{flex: 1, borderRadius: cx(15)}}>
75
+ <LinearGradient
76
+ style={{...styles.sliderLinearGradient, width}}
77
+ x1="0%"
78
+ y1="0%"
79
+ x2="100%"
80
+ y2="0%"
81
+ stops={dataSource}>
82
+ <Rect {...styles.sliderLinearGradient} width={width}/>
83
+ </LinearGradient>
84
+ </View>
85
+ )
86
+ }}
87
+ onValueChange={props.onValueChange}
88
+ onSlidingComplete={onSlidingComplete}
89
+ />
90
+ </View>
91
+ )
92
+ }
93
+
94
+ const getStyles = (theme?: ThemeType) =>
95
+ StyleSheet.create({
51
96
  container: {
52
97
  height: cx(57),
53
98
  flexDirection: 'column',
@@ -56,8 +101,7 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
56
101
  title: {
57
102
  marginTop: cx(4),
58
103
  fontSize: cx(14),
59
- color: props.theme?.global.fontColor,
60
- fontFamily: 'helvetica_neue_lt_std_roman',
104
+ color: theme?.global.fontColor,
61
105
  },
62
106
  shadeSlider: {
63
107
  marginTop: cx(8),
@@ -94,44 +138,4 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
94
138
  },
95
139
  })
96
140
 
97
- return (
98
- <View style={[styles.container, props.style]}>
99
- <Text accessibilityLabel={"Color"} accessibilityHint={`${value}`} style={styles.title}>
100
- {title}
101
- </Text>
102
- <Slider.Horizontal
103
- accessibilityLabel={"ColorSliderHorizontal"}
104
- style={{...styles.shadeSlider, width}}
105
- styles={{track: styles.sliderTrack, thumb: {...styles.shadeThumb, backgroundColor: thumbColor}}}
106
- maximumValue={max}
107
- minimumValue={min}
108
- value={value}
109
- stepValue={1}
110
- canTouchTrack={true}
111
- theme={{
112
- trackRadius: cx(15),
113
- }}
114
- onlyMaximumTrack={true}
115
- renderMaximumTrack={() => {
116
- return (
117
- <View style={{flex: 1, borderRadius: cx(15)}}>
118
- <LinearGradient
119
- style={{...styles.sliderLinearGradient, width}}
120
- x1="0%"
121
- y1="0%"
122
- x2="100%"
123
- y2="0%"
124
- stops={dataSource}>
125
- <Rect {...styles.sliderLinearGradient} width={width}/>
126
- </LinearGradient>
127
- </View>
128
- )
129
- }}
130
- onValueChange={props.onValueChange}
131
- onSlidingComplete={onSlidingComplete}
132
- />
133
- </View>
134
- )
135
- }
136
-
137
141
  export default withTheme(LdvColorSlider)
@@ -2,7 +2,7 @@ import _ from 'lodash'
2
2
  import React, { Component } from 'react'
3
3
  import { Provider } from 'react-redux'
4
4
  import { DevInfo, DpValue, Theme, TYSdk } from 'tuya-panel-kit'
5
- import { actions, store } from './models'
5
+ import { actions, store } from '@models'
6
6
  import { addListener, nativeEventEmitter, removeListener } from './api/nativeEventEmitter'
7
7
  import { getSystemTimeFormat, getTimeZone, NativeApi } from './api/native'
8
8
  import {
@@ -10,7 +10,9 @@ import {
10
10
  NativeProps,
11
11
  setGroupDevices,
12
12
  setGroupNativeProps,
13
- setNativeProps, setNewPalette,
13
+ setNativeProps,
14
+ setNewPalette,
15
+ setIsPad,
14
16
  setSystemTimeFormat,
15
17
  setTimeZone,
16
18
  UAGroupInfo,
@@ -27,6 +29,7 @@ interface Props {
27
29
  uaGroupInfo: UAGroupInfoProps
28
30
  colorScheme?: string
29
31
  newPalette?: boolean
32
+ isPad?: boolean
30
33
  }
31
34
 
32
35
  interface LdvDevInfo extends DeviceInfo {
@@ -138,6 +141,7 @@ const composeLayout = (component: React.ComponentType) => {
138
141
  })
139
142
 
140
143
  dispatch(setNewPalette(!!props.newPalette))
144
+ dispatch(setIsPad(!!props.isPad))
141
145
  }
142
146
 
143
147
  initReduxDeviceNativeProps(ldvDevInfo: LdvDevInfo) {
@@ -162,7 +166,7 @@ const composeLayout = (component: React.ComponentType) => {
162
166
  familyName: ldvDevInfo.familyName,
163
167
  role: ldvDevInfo.role,
164
168
  moods: [],
165
- is24HourClock: true
169
+ is24HourClock: true,
166
170
  }
167
171
  NativeApi.showObj(nativeProps)
168
172
  console.log('Redux 初始数据:', JSON.stringify(nativeProps))