@ledvance/base 1.3.80 → 1.3.82

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 (48) hide show
  1. package/localazy.json +4 -1
  2. package/package.json +1 -1
  3. package/src/components/AdvanceCard.tsx +3 -1
  4. package/src/components/BallDirectionView.tsx +181 -166
  5. package/src/components/Card.tsx +1 -1
  6. package/src/components/Cell.tsx +2 -0
  7. package/src/components/ColorAdjustView.tsx +1 -1
  8. package/src/components/ColorTempAdjustView.tsx +3 -3
  9. package/src/components/DeleteButton.tsx +4 -1
  10. package/src/components/DiySceneNodeView.tsx +6 -0
  11. package/src/components/DrawToolView.tsx +12 -0
  12. package/src/components/HybridSwitchView.tsx +3 -0
  13. package/src/components/MoodStripAdjustView.tsx +4 -0
  14. package/src/components/OptionGroup.tsx +6 -1
  15. package/src/components/OsramFanAdjustView.tsx +93 -0
  16. package/src/components/Page.tsx +5 -1
  17. package/src/components/Popup.tsx +2 -0
  18. package/src/components/Segmented.tsx +3 -0
  19. package/src/components/SocketItem.tsx +9 -1
  20. package/src/components/Stepper.tsx +6 -0
  21. package/src/components/StripAdjustView.tsx +2 -0
  22. package/src/components/Tag.tsx +12 -8
  23. package/src/components/TextButton.tsx +3 -1
  24. package/src/components/TextField.tsx +3 -2
  25. package/src/components/TextFieldStyleButton.tsx +2 -2
  26. package/src/components/UATabs.tsx +3 -0
  27. package/src/components/ldvColorBrightness.tsx +4 -1
  28. package/src/components/ldvColorSlider.tsx +2 -1
  29. package/src/components/ldvPickerView.tsx +4 -0
  30. package/src/components/ldvPresetView.tsx +3 -1
  31. package/src/components/ldvSaturation.tsx +3 -1
  32. package/src/components/ldvSlider.tsx +8 -3
  33. package/src/components/ldvSwitch.tsx +2 -2
  34. package/src/components/ldvTemperatureSlider.tsx +4 -2
  35. package/src/components/ldvTopBar.tsx +3 -1
  36. package/src/components/ldvTopName.tsx +1 -0
  37. package/src/components/rect-color-and-bright-picker/ColourPicker.tsx +2 -0
  38. package/src/components/rect-color-and-bright-picker/RectPicker.tsx +7 -0
  39. package/src/components/rect-color-and-bright-picker/Slider.tsx +3 -1
  40. package/src/components/rect-color-and-bright-picker/WhitePicker.tsx +50 -1
  41. package/src/components/rect-color-and-bright-picker/utils/storage.ts +97 -0
  42. package/src/components/segmentControl.tsx +11 -4
  43. package/src/components/weekSelect.tsx +3 -0
  44. package/src/i18n/strings.ts +116 -32
  45. package/src/utils/interface.ts +1 -1
  46. package/translateKey.txt +4 -1
  47. package/src/components/ShowSelect.d.ts +0 -1
  48. package/src/components/ShowSelect.tsx +0 -159
@@ -0,0 +1,93 @@
1
+ import React from "react"
2
+ import { View, Text, TouchableOpacity, Image } from "react-native"
3
+ import LdvSwitch from "./ldvSwitch"
4
+ import I18n from "@i18n"
5
+ import LdvSlider from "./ldvSlider"
6
+ import Spacer from "./Spacer"
7
+ import ThemeType from "config/themeType"
8
+ import { Utils } from "tuya-panel-kit"
9
+ import Popup from "./Popup"
10
+ import res from "@res"
11
+ import Segmented from "./Segmented"
12
+
13
+ const cx = Utils.RatioUtils.convertX
14
+ const { withTheme } = Utils.ThemeUtils
15
+
16
+ interface OsramFanAdjustProps {
17
+ theme?: ThemeType
18
+ hideFanSwitch?: boolean
19
+ fanSwitch: boolean
20
+ setFanSwitch: (v: boolean) => void
21
+ fanSpeed: number
22
+ minSpeed?: number
23
+ maxSpeed?: number
24
+ onFanSpeedChange?: (v: number) => void
25
+ setFanSpeed: (v: number) => void
26
+ fanMode: 'fresh' | 'nature'
27
+ setFanMode: (v: 'fresh' | 'nature') => void
28
+ }
29
+
30
+ const OsramFanAdjustView = (props: OsramFanAdjustProps) => {
31
+ const { hideFanSwitch = false, fanSwitch, setFanSwitch, fanSpeed, onFanSpeedChange, setFanSpeed, minSpeed = 1, maxSpeed = 3, fanMode, setFanMode } = props
32
+ return (
33
+ <View>
34
+ {
35
+ !hideFanSwitch && <LdvSwitch
36
+ title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_headline')}
37
+ enable={fanSwitch}
38
+ setEnable={setFanSwitch}
39
+ />
40
+ }
41
+ {
42
+ fanSwitch && (
43
+ <>
44
+ <LdvSlider
45
+ title={I18n.getLang('add_new_dynamic_mood_ceiling_fan_field_text')}
46
+ subTitleStr={`${fanSpeed}/${maxSpeed}`}
47
+ value={fanSpeed}
48
+ min={minSpeed}
49
+ max={maxSpeed}
50
+ onValueChange={onFanSpeedChange}
51
+ onSlidingComplete={setFanSpeed}
52
+ />
53
+ <Spacer />
54
+ <View style={{ marginHorizontal: cx(16) }}>
55
+ <View style={{ flexDirection: 'row', marginBottom: cx(2), alignItems: 'center' }}>
56
+ <Text style={{ marginRight: cx(5), color: props.theme?.global.fontColor }}>{I18n.getLang('ceiling_fan_tile_uvc_fan_mode')}</Text>
57
+ <TouchableOpacity onPress={() => Popup({
58
+ title: I18n.getLang('ceiling_fan_mode_info_headline'),
59
+ confirmText: I18n.getLang('ceiling_fan_direction_info_button_label'),
60
+ content: <View>
61
+ <Text style={{
62
+ fontWeight: 'bold',
63
+ color: props.theme?.global.fontColor,
64
+ }}>{I18n.getLang('ceiling_fan_mode_info_description_text')}</Text>
65
+ <Spacer />
66
+ <Text style={{ color: props.theme?.global.fontColor }}>{I18n.getLang('ceiling_fan_mode_info_option_1_headline')}</Text>
67
+ <Text style={{ color: props.theme?.global.fontColor }}>{I18n.getLang('ceiling_fan_mode_info_option_1_text')}</Text>
68
+ <Spacer />
69
+ <Text style={{ color: props.theme?.global.fontColor }}>{I18n.getLang('ceiling_fan_mode_info_option_2_headline')}</Text>
70
+ <Text style={{ color: props.theme?.global.fontColor }}>{I18n.getLang('ceiling_fan_mode_info_option_2_text')}</Text>
71
+ </View>,
72
+ })}>
73
+ <Image style={{ width: cx(16), height: cx(16), tintColor: props.theme?.icon.primary }} source={{ uri: res.ic_info }} />
74
+ </TouchableOpacity>
75
+ </View>
76
+ <Segmented
77
+ options={[
78
+ { label: I18n.getLang('ceiling_fan_tile_uvc_fan_mode_opt_1'), value: 'fresh' },
79
+ { label: I18n.getLang('ceiling_fan_tile_uvc_fan_mode_opt_2'), value: 'nature' },
80
+ ]}
81
+ value={fanMode}
82
+ onChange={setFanMode}
83
+ />
84
+ </View>
85
+ <Spacer />
86
+ </>
87
+ )
88
+ }
89
+ </View>
90
+ )
91
+ }
92
+
93
+ export default withTheme(OsramFanAdjustView)
@@ -70,7 +70,11 @@ const Page = (props: PageProps) => {
70
70
 
71
71
  return (
72
72
  <>
73
- <View style={[{ flex: 1, position: 'relative', backgroundColor: props.theme?.global.background }, props.style]}>
73
+ <View
74
+ accessibilityLabel='Page'
75
+ accessibilityHint={props.headlineText}
76
+ style={[{ flex: 1, position: 'relative', backgroundColor: props.theme?.global.background }, props.style]}
77
+ >
74
78
  <LDVTopBar
75
79
  title={props.backText}
76
80
  onBackPress={
@@ -26,6 +26,8 @@ const InformationPopup = (props: InformationPopupProps) => {
26
26
  }}>{props.title}</Text>
27
27
  </View>
28
28
  <TouchableOpacity
29
+ accessibilityLabel='PopupCloseButton'
30
+ accessibilityHint={props.confirmText}
29
31
  style={{
30
32
  flexDirection: 'column-reverse',
31
33
  alignItems: 'center',
@@ -57,6 +57,9 @@ const Segmented = (props: SegmentedProps) => {
57
57
  <View style={[styles.wrap_container, props.style]}>
58
58
  {props.options && props.options.map((item, idx) => (
59
59
  <TouchableOpacity
60
+ accessibilityLabel={"Segmented"}
61
+ accessibilityHint={`${item.value}`}
62
+ accessibilityState={{checked: item.value === props.value}}
60
63
  style={[
61
64
  styles.segmented_item,
62
65
  idx === 0 && styles.segmented_item_first,
@@ -13,6 +13,7 @@ interface SocketItemProps extends PropsWithChildren<ViewProps>{
13
13
  theme?: ThemeType
14
14
  title: string
15
15
  name: string
16
+ placeholder?: string
16
17
  icon?: any
17
18
  disabledEdit?: boolean
18
19
  onNameChange: (value: string) => void
@@ -65,12 +66,19 @@ function SocketItem(props: SocketItemProps) {
65
66
  onValueChange={props.onSwitchChange} />
66
67
  </View>
67
68
  <TouchableOpacity
69
+ accessibilityLabel={"Description"}
70
+ accessibilityHint={props.name}
68
71
  style={styles.nameLine}
69
72
  onPress={() => {
70
73
  if(props.disabledEdit) return
71
74
  Dialog.prompt({
72
75
  title: I18n.getLang('routines_add_edit_name'),
73
76
  value: props.name,
77
+ accessibilityLabel: "DialogInput",
78
+ accessibilityHint: props.name,
79
+ confirmAccessibilityLabel: "DialogConfirm",
80
+ cancelAccessibilityLabel: "DialogCancel",
81
+ placeholder: props.placeholder,
74
82
  cancelText: I18n.getLang('auto_scan_system_cancel'),
75
83
  confirmText: I18n.getLang('auto_scan_system_wifi_confirm'),
76
84
  inputWrapperStyle: {backgroundColor: props.theme?.textInput.background, borderRadius: cx(10)},
@@ -83,7 +91,7 @@ function SocketItem(props: SocketItemProps) {
83
91
  },
84
92
  })
85
93
  }}>
86
- <Text style={styles.name}>{props.name}</Text>
94
+ <Text style={styles.name}>{props.name || props.placeholder}</Text>
87
95
  </TouchableOpacity>
88
96
  <Spacer height={cx(16)} />
89
97
  {props.children}
@@ -111,12 +111,16 @@ const Stepper = (props: StepperProps) => {
111
111
  return (
112
112
  <View style={[styles.stepperContainer, props.style]}>
113
113
  <TouchableOpacity
114
+ accessibilityLabel={"StepperMinusButton"}
115
+ accessibilityHint={`${state.value}`}
114
116
  style={[styles.stepperButton, props.buttonStyle]}
115
117
  onPress={() => handlePress(false)}
116
118
  >
117
119
  <Image style={styles.stepperIcon} source={{uri: res.ic_minus}} />
118
120
  </TouchableOpacity>
119
121
  <TextInput
122
+ accessibilityLabel={"StepperInput"}
123
+ accessibilityHint={`${state.value}`}
120
124
  style={[styles.stepperInput, props.inputStyle]}
121
125
  value={state.value.toString()}
122
126
  keyboardType="numeric"
@@ -127,6 +131,8 @@ const Stepper = (props: StepperProps) => {
127
131
  editable={props.editable || props.disabled}
128
132
  />
129
133
  <TouchableOpacity
134
+ accessibilityLabel={"StepperPlusButton"}
135
+ accessibilityHint={`${state.value}`}
130
136
  style={[styles.stepperButton, props.buttonStyle]}
131
137
  onPress={() => handlePress(true)}
132
138
  >
@@ -6,6 +6,7 @@ import Spacer from "./Spacer";
6
6
  import { TabBar, Utils } from "tuya-panel-kit";
7
7
  import { ColorDisk } from "@tuya/tuya-panel-lamp-sdk";
8
8
  import res from "../res";
9
+ import ThemeType from "../config/themeType";
9
10
  const { convertX: cx } = Utils.RatioUtils
10
11
  const { withTheme } = Utils.ThemeUtils
11
12
 
@@ -14,6 +15,7 @@ type TabsNode = {
14
15
  title: string
15
16
  }
16
17
  interface StripAdjustViewProps extends ColorAdjustViewProps, ColorTempAdjustViewProps {
18
+ theme?: ThemeType
17
19
  lampTabs: TabsNode[]
18
20
  activeKey: number | string
19
21
  onActiveKeyChange: (key: number | string) => void
@@ -1,6 +1,6 @@
1
- import {Image, StyleSheet, Text, TouchableOpacity, View, ViewProps} from 'react-native'
1
+ import { Image, StyleSheet, Text, TouchableOpacity, 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 res from '../res'
5
5
  import ThemeType from '../config/themeType'
6
6
 
@@ -49,13 +49,17 @@ const Tag = (props: TagProps) => {
49
49
  onPress={() => {
50
50
  props.onCheckedChange(!props.checked)
51
51
  }}>
52
- <View style={[styles.root, props.checked ? styles.checked : styles.uncheck, props.style]}>
53
- <Text style={[styles.text, {marginEnd: cx(props.checked ? 4 : 12)}]}>{props.text}</Text>
52
+ <View
53
+ accessibilityLabel={"Tag"}
54
+ accessibilityHint={props.text}
55
+ accessibilityState={{ checked: props.checked }}
56
+ style={[styles.root, props.checked ? styles.checked : styles.uncheck, props.style]}
57
+ >
58
+ <Text style={[styles.text, { marginEnd: cx(props.checked ? 4 : 12) }]}>
59
+ {props.text}
60
+ </Text>
54
61
  {
55
- props.checked &&
56
- <Image
57
- source={{uri: res.ic_arrows_nav_clear}}
58
- style={styles.icon}/>
62
+ props.checked ? <Image accessibilityLabel='TagClearIcon' source={{ uri: res.ic_arrows_nav_clear }} style={styles.icon} /> : <></>
59
63
  }
60
64
  </View>
61
65
  </TouchableOpacity>
@@ -14,6 +14,8 @@ interface TextButtonProps {
14
14
  export default function TextButton(props: TextButtonProps) {
15
15
  return (
16
16
  <TouchableOpacity
17
+ accessibilityLabel={"TextButton"}
18
+ accessibilityHint={props.text}
17
19
  style={[{
18
20
  justifyContent: 'center',
19
21
  alignItems: 'center',
@@ -29,4 +31,4 @@ export default function TextButton(props: TextButtonProps) {
29
31
  }, props.textStyle]}>{props.text}</Text>
30
32
  </TouchableOpacity>
31
33
  )
32
- }
34
+ }
@@ -70,14 +70,15 @@ const TextField = (props: TextFieldProps) => {
70
70
  <View style={props.style}>
71
71
  <Text style={[styles.topTip, { opacity: (!!props.value) ? 1 : 0 }]}>{props.placeholder}</Text>
72
72
  <View style={styles.textInputGroup}>
73
- <TextInput{...props} style={styles.textInput} />
73
+ <TextInput {...props} accessibilityLabel={"TextInput"} accessibilityHint={props.value} style={styles.textInput} />
74
74
  {!!props.value && editable &&
75
75
  <TouchableOpacity
76
+ accessibilityLabel={"TextInputClearButton"}
76
77
  style={styles.iconTouchable}
77
78
  onPress={() => {
78
79
  props.onChangeText && props.onChangeText('')
79
80
  }}>
80
- <Image source={{ uri: res.ic_cancel }} style={styles.icon} />
81
+ <Image source={{uri: res.ic_cancel}} style={styles.icon}/>
81
82
  </TouchableOpacity>
82
83
  }
83
84
  <View style={styles.line} />
@@ -67,11 +67,11 @@ const TextFieldStyleButton = (props: TextFieldStyleButtonProps) => {
67
67
  <View style={props.style}>
68
68
  <View style={styles.tipParent}>
69
69
  <Text style={styles.topTip}>{props.placeholder}</Text>
70
- {props.showTipIcon && <TouchableOpacity onPress={props.onTipIconPress}>
70
+ {props.showTipIcon && <TouchableOpacity accessibilityLabel={"TipIcon"} onPress={props.onTipIconPress}>
71
71
  <Image source={{uri: res.ic_info}} style={styles.tipIcon}/>
72
72
  </TouchableOpacity>}
73
73
  </View>
74
- <TouchableOpacity onPress={props.onPress}>
74
+ <TouchableOpacity accessibilityLabel={"TextFieldStyleButton"} accessibilityHint={props.text} onPress={props.onPress}>
75
75
  <View style={styles.textGroup}>
76
76
  <View style={styles.textParent}>
77
77
  <Text style={styles.text}>{props.text}</Text>
@@ -54,6 +54,9 @@ const UATabs = (props: UATabsProps) => {
54
54
  const active = props.active === item.value
55
55
 
56
56
  return <TouchableOpacity
57
+ accessibilityLabel={"UATabs"}
58
+ accessibilityHint={`${item.value}`}
59
+ accessibilityState={{checked: active}}
57
60
  key={index}
58
61
  style={{ flex: 1 }}
59
62
  onPress={() => {
@@ -7,6 +7,9 @@ export default function LdvColorBrightness(props) {
7
7
  const renderBrightness = () => {
8
8
  return (
9
9
  <LdvSlider
10
+ accessibilityLabel={"Brightness"}
11
+ accessibilityHint={`${value}`}
12
+ max={100}
10
13
  min={minBrightness}
11
14
  style={props.style}
12
15
  title={I18n.getLang('light_sources_tile_dim_lighting_brightness')}
@@ -16,4 +19,4 @@ export default function LdvColorBrightness(props) {
16
19
  )
17
20
  }
18
21
  return renderBrightness()
19
- }
22
+ }
@@ -96,10 +96,11 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
96
96
 
97
97
  return (
98
98
  <View style={[styles.container, props.style]}>
99
- <Text style={styles.title}>
99
+ <Text accessibilityLabel={"Color"} accessibilityHint={`${value}`} style={styles.title}>
100
100
  {title}
101
101
  </Text>
102
102
  <Slider.Horizontal
103
+ accessibilityLabel={"ColorSliderHorizontal"}
103
104
  style={{...styles.shadeSlider, width}}
104
105
  styles={{track: styles.sliderTrack, thumb: {...styles.shadeThumb, backgroundColor: thumbColor}}}
105
106
  maximumValue={max}
@@ -55,6 +55,8 @@ const LdvPickerView = (props: LdvPickerViewProps) => {
55
55
  <View key={props.theme?.type} style={[styles.pickerContainer, props.style]}>
56
56
  <View style={styles.picContainer}>
57
57
  <Picker
58
+ accessibilityLabel={"HourPicker"}
59
+ accessibilityHint={hour}
58
60
  itemTextColor='#aeadb5'
59
61
  style={[styles.picker, styles.pickerLeft]}
60
62
  loop={true}
@@ -76,6 +78,8 @@ const LdvPickerView = (props: LdvPickerViewProps) => {
76
78
  </View>
77
79
  <View style={styles.picContainer}>
78
80
  <Picker
81
+ accessibilityLabel={"MinutePicker"}
82
+ accessibilityHint={minute}
79
83
  itemTextColor='#aeadb5'
80
84
  style={[styles.picker, styles.pickerLeft]}
81
85
  loop={true}
@@ -59,6 +59,8 @@ const LdvPresetView = (props) => {
59
59
  <View style={styles.container}>
60
60
  {dataSource.map((item, index) =>
61
61
  <TouchableOpacity
62
+ accessibilityLabel={"PresetNode"}
63
+ accessibilityHint={`${item.color}`}
62
64
  key={index}
63
65
  style={[styles.item, {backgroundColor: item.color}]}
64
66
  onPress={() => {
@@ -84,4 +86,4 @@ const styles = StyleSheet.create({
84
86
  },
85
87
  })
86
88
 
87
- export default LdvPresetView
89
+ export default LdvPresetView
@@ -8,6 +8,8 @@ const LdvSaturation = (props) => {
8
8
  const renderBrightness = () => {
9
9
  return (
10
10
  <LdvSlider
11
+ accessibilityLabel={"Saturation"}
12
+ accessibilityHint={`${value}`}
11
13
  style={props.style}
12
14
  title={I18n.getLang('light_sources_tile_rgb_lighting_saturation')}
13
15
  value={value}
@@ -20,4 +22,4 @@ const LdvSaturation = (props) => {
20
22
  return renderBrightness()
21
23
  }
22
24
 
23
- export default LdvSaturation
25
+ export default LdvSaturation
@@ -1,13 +1,13 @@
1
1
  import {useReactive} from 'ahooks'
2
2
  import React, {useEffect} from 'react'
3
- import {StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle} from 'react-native'
3
+ import {AccessibilityProps, StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle} from 'react-native'
4
4
  import {Slider, Utils} from 'tuya-panel-kit'
5
5
  import ThemeType from '../config/themeType'
6
6
 
7
7
  const cx = Utils.RatioUtils.convertX
8
8
  const { withTheme } = Utils.ThemeUtils
9
9
 
10
- interface LdvSliderProps {
10
+ interface LdvSliderProps extends AccessibilityProps{
11
11
  theme?: ThemeType
12
12
  title: string,
13
13
  value: number,
@@ -77,7 +77,11 @@ const LdvSlider = (props: LdvSliderProps) => {
77
77
 
78
78
  return (
79
79
  <View style={[styles.container, props.style]}>
80
- <View style={styles.titleBg}>
80
+ <View
81
+ accessibilityLabel={props.accessibilityLabel}
82
+ accessibilityHint={props.accessibilityHint}
83
+ style={styles.titleBg}
84
+ >
81
85
  <Text style={[styles.title, titleStyle]}>
82
86
  {props.title}
83
87
  </Text>
@@ -86,6 +90,7 @@ const LdvSlider = (props: LdvSliderProps) => {
86
90
  </Text>
87
91
  </View>
88
92
  <Slider.Horizontal
93
+ accessibilityLabel={"SliderHorizontal"}
89
94
  style={[styles.slider, sliderStyle]}
90
95
  styles={{thumb: styles.thumb}}
91
96
  maximumValue={mMax}
@@ -23,7 +23,7 @@ interface Prop {
23
23
  const LdvSwitch = (props: Prop) => {
24
24
  const {title, color, colorAlpha = 0, enable, description, titleStyle, setEnable, leftValue, rightValue, showSwitch = true} = props
25
25
  return (
26
- <View style={styles.titleBGView}>
26
+ <View accessibilityLabel={"LdvSwitch"} accessibilityHint={`${color}`} accessibilityState={{checked: enable}} style={styles.titleBGView}>
27
27
  <View style={{flexDirection: 'column', flex: 1}}>
28
28
  <View style={{flexDirection: 'row', alignItems: 'center'}}>
29
29
  <Text style={[styles.title, {color: props.theme?.global.fontColor}, titleStyle]}>{title}</Text>
@@ -33,7 +33,7 @@ const LdvSwitch = (props: Prop) => {
33
33
  </View>
34
34
  {showSwitch && <>
35
35
  {leftValue && <Text style={{color: props.theme?.global.fontColor, marginRight: cx(5)}}>{leftValue}</Text>}
36
- <SwitchButton value={enable} onValueChange={setEnable}/>
36
+ <SwitchButton accessibilityLabel={"SwitchButton"} value={enable} onValueChange={setEnable}/>
37
37
  {rightValue && <Text style={{color: props.theme?.global.fontColor, marginLeft: cx(5)}}>{rightValue}</Text>}
38
38
  </>
39
39
  }
@@ -24,6 +24,7 @@ interface LdvTemperatureSliderProps {
24
24
  style?: StyleProp<ViewStyle> | undefined
25
25
  titleStyle?: StyleProp<TextProps> | undefined
26
26
  subTitleStr?: string | undefined
27
+ accessibilityLabel?: string | undefined
27
28
  }
28
29
 
29
30
  const LdvTemperatureSlider = (props: LdvTemperatureSliderProps) => {
@@ -43,11 +44,12 @@ const LdvTemperatureSlider = (props: LdvTemperatureSliderProps) => {
43
44
  return (
44
45
  <View style={[styles.container, props.style]}>
45
46
  <View style={styles.titleBg}>
46
- <Text style={[styles.title, titleStyle]}>
47
+ <Text accessibilityLabel={"Temperature"} accessibilityHint={`${value}`} style={[styles.title, titleStyle]}>
47
48
  {title}
48
49
  </Text>
49
50
  </View>
50
51
  <Slider.Horizontal
52
+ accessibilityLabel={"TemperatureSliderHorizontal"}
51
53
  style={{...styles.shadeSlider, width}}
52
54
  styles={{track: styles.sliderTrack, thumb: {...styles.shadeThumb, backgroundColor: thumbColor}}}
53
55
  maximumValue={max}
@@ -137,4 +139,4 @@ const styles = StyleSheet.create({
137
139
  },
138
140
  })
139
141
 
140
- export default LdvTemperatureSlider
142
+ export default LdvTemperatureSlider
@@ -29,7 +29,7 @@ const LDVTopBar = (props: TopBarProps) => {
29
29
  marginTop: Platform.OS === 'ios' ? Utils.RatioUtils.statusBarHeight : 0,
30
30
  justifyContent: 'space-between',
31
31
  }}>
32
- <TouchableOpacity onPress={props.onBackPress} style={{flex: 1, maxWidth: cx(290)}} >
32
+ <TouchableOpacity accessibilityLabel={"GoBack"} onPress={props.onBackPress} style={{flex: 1, maxWidth: cx(290)}} >
33
33
  <View
34
34
  style={{
35
35
  flexDirection: 'row',
@@ -52,6 +52,8 @@ const LDVTopBar = (props: TopBarProps) => {
52
52
  </TouchableOpacity>
53
53
  {!!props.rightButtonIcon &&
54
54
  <TouchableOpacity
55
+ accessibilityLabel={"RightButton"}
56
+ accessibilityState={{disabled: props.rightButtonDisabled}}
55
57
  style={{
56
58
  width: cx(44),
57
59
  height: cx(44),
@@ -54,6 +54,7 @@ const LdvTopName = (props: LdvTopNameProps) => {
54
54
  /> || null}
55
55
  </View>}
56
56
  {props.rightIcon && <TouchableOpacity
57
+ accessibilityLabel={"RightIcon"}
57
58
  onPress={props.rightIconClick}>
58
59
  <Image
59
60
  style={{ width: cx(24), height: cx(24), tintColor: props.theme?.global.brand }}
@@ -233,6 +233,8 @@ export default class ColourPicker extends Component<ColourProps, IState> {
233
233
  return (
234
234
  <View style={[{ flex: 1 }, style]}>
235
235
  <RectPicker
236
+ accessibilityLabel={"RectColorPicker"}
237
+ accessibilityHint={`${hue}, ${ Math.round(saturation / 10)}`}
236
238
  coorToValue={this.coorToValue}
237
239
  valueToColor={this.valueToColor}
238
240
  valueToCoor={this.valueToCoor}
@@ -82,6 +82,8 @@ interface IProps extends DefaultProps {
82
82
  valueToCoor: (value: any, originCoor?: Point, validBound?: ValidBound) => Point;
83
83
  valueToColor: (value: any) => string;
84
84
  initData: (validBound?: ValidBound) => void;
85
+ accessibilityLabel?: string;
86
+ accessibilityHint?: string;
85
87
  }
86
88
 
87
89
  interface IState {
@@ -377,10 +379,15 @@ export default class RectPicker extends Component<IProps, IState> {
377
379
  disabled,
378
380
  thumbSize,
379
381
  thumbImg,
382
+ accessibilityLabel,
383
+ accessibilityHint
380
384
  } = this.props;
381
385
  const { showPicker, pickerHeight, pickerWidth, thumbPosition } = this;
382
386
  return (
383
387
  <View
388
+ accessibilityLabel={accessibilityLabel}
389
+ accessibilityHint={accessibilityHint}
390
+ accessibilityRole={'adjustable'}
384
391
  style={[{ flex: 1 }, style]}
385
392
  {...this._panResponder.panHandlers}
386
393
  pointerEvents="box-only"
@@ -504,7 +504,9 @@ export default class Slider extends React.Component<IProps, IState> {
504
504
  return (
505
505
  <View
506
506
  style={containerStyle}
507
- accessibilityLabel="ReactColorPicker_Slider"
507
+ accessibilityLabel="ReactColorPickerSlider"
508
+ accessibilityHint={`${this.brightWidth}`}
509
+ accessibilityRole={'adjustable'}
508
510
  onLayout={this.handleLayout}
509
511
  pointerEvents="box-only"
510
512
  {...this._panResponder.panHandlers}
@@ -10,6 +10,7 @@ import RectPicker, {
10
10
  } from './RectPicker';
11
11
  import Slider, { IBrightOption } from './Slider';
12
12
  import ColorUtils from './utils/color';
13
+ import StorageUtils from './utils/storage';
13
14
 
14
15
  export interface IWhite {
15
16
  brightness: number;
@@ -52,20 +53,38 @@ const defaultProps = {
52
53
  onRelease(_v: any, _option?: { isChangeBright: boolean }) {},
53
54
  onPress(_v: any, _option?: { isChangeBright: boolean }) {},
54
55
  };
56
+
57
+ interface TempStorageData {
58
+ temperature: number;
59
+ position: Point;
60
+ }
61
+
55
62
  type DefaultProps = {
56
63
  style?: ViewStyle;
57
64
  rectStyle?: ViewStyle;
65
+ storageKey?: string;
58
66
  } & Readonly<typeof defaultProps>;
59
67
 
60
68
  type WhiteProps = DefaultProps;
61
69
 
70
+ let storageKeyIndex = 0;
71
+
62
72
  export default class WhitePicker extends Component<WhiteProps, IWhite> {
63
73
  static defaultProps = defaultProps;
64
74
 
65
75
  constructor(props: WhiteProps) {
66
76
  super(props);
67
- const { value: { brightness, temperature }, } = this.props;
77
+ // 是否定义了storageKey
78
+ const {
79
+ storageKey,
80
+ value: { brightness, temperature },
81
+ } = this.props;
68
82
  this.state = { brightness, temperature };
83
+ if (!storageKey) {
84
+ this.storageKey = `temperature_key_${storageKeyIndex++}`;
85
+ } else {
86
+ this.storageKey = storageKey;
87
+ }
69
88
  }
70
89
 
71
90
  componentDidUpdate(prevProps: WhiteProps) {
@@ -199,7 +218,26 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
199
218
  }
200
219
 
201
220
  initData = async (validBound: ValidBound) => {
221
+ let cacheEnabled = true;
222
+ // 尺寸有变化时,不使用缓存
223
+ if (!_.isEqual(validBound, this.pickerBound)) {
224
+ cacheEnabled = false;
225
+ }
226
+
202
227
  const { temperature } = this.state;
228
+
229
+ // 获取当前positon的值
230
+ const data = (await StorageUtils.getDevItem(this.storageKey)) as TempStorageData;
231
+ // 是否相同色温,相同使用缓存坐标展示
232
+ if (data && data.temperature === temperature && cacheEnabled) {
233
+ this.thumbPosition = data.position;
234
+ this.currentTemperature = temperature;
235
+ } else {
236
+ // 根据色温计算位置
237
+ this.thumbPosition = this.autoTemperaturePosition(temperature, validBound);
238
+ this.currentTemperature = temperature;
239
+ }
240
+
203
241
  // 根据色温计算位置
204
242
  this.thumbPosition = this.autoTemperaturePosition(temperature, validBound);
205
243
  this.currentTemperature = temperature;
@@ -217,6 +255,8 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
217
255
  validBound
218
256
  );
219
257
  }
258
+
259
+ StorageUtils.setDevItem(this.storageKey, { temperature, position });
220
260
  return position;
221
261
  }
222
262
 
@@ -242,6 +282,7 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
242
282
  x: normal.x * length + normalVector.originX,
243
283
  y: normal.y * length + normalVector.originY,
244
284
  };
285
+ StorageUtils.setDevItem(this.storageKey, { temperature, position });
245
286
  return position;
246
287
  }
247
288
 
@@ -263,6 +304,11 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
263
304
  }
264
305
  return this.handleTemperaturePosition(temperature, validBound);
265
306
  }
307
+
308
+ StorageUtils.setDevItem(this.storageKey, {
309
+ temperature,
310
+ position: origin,
311
+ });
266
312
  this.currentTemperature = temperature;
267
313
  this.thumbPosition = origin;
268
314
  return origin;
@@ -281,6 +327,7 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
281
327
  private currentTemperature: number;
282
328
  private pickerRef: RectPicker | null;
283
329
  private pickerBound: ValidBound;
330
+ private storageKey: string;
284
331
 
285
332
  handlePickerGrant = () => {
286
333
  const { temperature, brightness } = this.state;
@@ -325,6 +372,8 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
325
372
  ref={(ref: RectPicker) => {
326
373
  this.pickerRef = ref;
327
374
  }}
375
+ accessibilityLabel={"ReactWhitePicker"}
376
+ accessibilityHint={`${ Math.round(temperature / 10)}`}
328
377
  coorToValue={this.coorToValue}
329
378
  valueToColor={this.valueToColor}
330
379
  valueToCoor={this.valueToCoor}