@ledvance/base 1.2.83 → 1.2.85

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 (165) hide show
  1. package/.babelrc +31 -31
  2. package/.eslintignore +5 -5
  3. package/.eslintrc.js +27 -27
  4. package/.prettierrc.js +1 -1
  5. package/.versionrc +5 -5
  6. package/localazy.json +851 -848
  7. package/localazy.keys.json +4 -4
  8. package/package.json +74 -74
  9. package/rn-cli.config.js +8 -8
  10. package/src/api/native.d.ts +71 -71
  11. package/src/api/native.ts +423 -423
  12. package/src/api/nativeEventEmitter.d.ts +3 -3
  13. package/src/api/nativeEventEmitter.ts +125 -125
  14. package/src/components/AdvanceCard.d.ts +25 -25
  15. package/src/components/AdvanceCard.tsx +117 -117
  16. package/src/components/AdvanceList.d.ts +9 -9
  17. package/src/components/AdvanceList.tsx +69 -69
  18. package/src/components/ApplyForDeviceItem.d.ts +6 -6
  19. package/src/components/ApplyForDeviceItem.tsx +83 -83
  20. package/src/components/ApplyForDeviceList.d.ts +7 -7
  21. package/src/components/ApplyForDeviceList.tsx +61 -61
  22. package/src/components/ApplyForText.d.ts +6 -6
  23. package/src/components/ApplyForText.tsx +52 -52
  24. package/src/components/Card.d.ts +10 -10
  25. package/src/components/Card.tsx +40 -40
  26. package/src/components/Cell.d.ts +21 -21
  27. package/src/components/Cell.tsx +69 -69
  28. package/src/components/CircularProgress.d.ts +8 -8
  29. package/src/components/CircularProgress.tsx +42 -42
  30. package/src/components/ColorAdjustView.d.ts +12 -12
  31. package/src/components/ColorAdjustView.tsx +64 -64
  32. package/src/components/ColorExtractor.d.ts +73 -73
  33. package/src/components/ColorExtractor.tsx +374 -374
  34. package/src/components/ColorTempAdjustView.d.ts +13 -13
  35. package/src/components/ColorTempAdjustView.tsx +57 -57
  36. package/src/components/ColorsLine.d.ts +7 -7
  37. package/src/components/ColorsLine.tsx +47 -47
  38. package/src/components/CustomListDialog.d.ts +15 -15
  39. package/src/components/CustomListDialog.tsx +66 -66
  40. package/src/components/DeleteButton.d.ts +10 -10
  41. package/src/components/DeleteButton.tsx +40 -40
  42. package/src/components/Dialog.d.ts +10 -10
  43. package/src/components/Dialog.tsx +38 -38
  44. package/src/components/DrawToolView.d.ts +46 -46
  45. package/src/components/DrawToolView.tsx +262 -262
  46. package/src/components/FanAdjustView.d.ts +23 -23
  47. package/src/components/FanAdjustView.tsx +141 -141
  48. package/src/components/InfoText.d.ts +11 -11
  49. package/src/components/InfoText.tsx +45 -45
  50. package/src/components/LampAdjustView.d.ts +10 -10
  51. package/src/components/LampAdjustView.tsx +75 -75
  52. package/src/components/LampAdjustView2.d.ts +24 -24
  53. package/src/components/LampAdjustView2.tsx +104 -104
  54. package/src/components/LinearGradientLine.d.ts +9 -9
  55. package/src/components/LinearGradientLine.tsx +63 -63
  56. package/src/components/LoadingView.tsx +39 -39
  57. package/src/components/MoodColorsLine.d.ts +9 -9
  58. package/src/components/MoodColorsLine.tsx +38 -38
  59. package/src/components/Page.d.ts +21 -21
  60. package/src/components/Page.tsx +104 -104
  61. package/src/components/Popup.d.ts +7 -7
  62. package/src/components/Popup.tsx +71 -71
  63. package/src/components/Segmented.d.ts +14 -14
  64. package/src/components/Segmented.tsx +76 -76
  65. package/src/components/ShowSelect.d.ts +1 -1
  66. package/src/components/ShowSelect.tsx +158 -158
  67. package/src/components/SocketItem.d.ts +13 -13
  68. package/src/components/SocketItem.tsx +87 -87
  69. package/src/components/Spacer.d.ts +7 -7
  70. package/src/components/Spacer.tsx +13 -13
  71. package/src/components/Stepper.d.ts +19 -19
  72. package/src/components/Stepper.tsx +130 -130
  73. package/src/components/StripAdjustView.d.ts +16 -16
  74. package/src/components/StripAdjustView.tsx +129 -129
  75. package/src/components/StripLightView.d.ts +14 -14
  76. package/src/components/StripLightView.tsx +24 -24
  77. package/src/components/Summary.tsx +116 -116
  78. package/src/components/Tag.d.ts +8 -8
  79. package/src/components/Tag.tsx +56 -56
  80. package/src/components/TextButton.d.ts +9 -9
  81. package/src/components/TextButton.tsx +31 -31
  82. package/src/components/TextField.d.ts +9 -9
  83. package/src/components/TextField.tsx +92 -92
  84. package/src/components/TextFieldStyleButton.d.ts +8 -8
  85. package/src/components/TextFieldStyleButton.tsx +85 -85
  86. package/src/components/UATabTitle.d.ts +6 -6
  87. package/src/components/UATabTitle.tsx +31 -31
  88. package/src/components/UATabs.d.ts +12 -12
  89. package/src/components/UATabs.tsx +77 -77
  90. package/src/components/connect.d.ts +10 -10
  91. package/src/components/connect.tsx +20 -20
  92. package/src/components/ldvColorBrightness.d.ts +1 -1
  93. package/src/components/ldvColorBrightness.tsx +18 -18
  94. package/src/components/ldvColorSlider.d.ts +14 -14
  95. package/src/components/ldvColorSlider.tsx +131 -131
  96. package/src/components/ldvItemView.d.ts +12 -12
  97. package/src/components/ldvItemView.tsx +43 -43
  98. package/src/components/ldvPickerView.d.ts +13 -13
  99. package/src/components/ldvPickerView.tsx +97 -97
  100. package/src/components/ldvPresetView.d.ts +2 -2
  101. package/src/components/ldvPresetView.tsx +86 -86
  102. package/src/components/ldvSaturation.d.ts +2 -2
  103. package/src/components/ldvSaturation.tsx +22 -22
  104. package/src/components/ldvSlider.d.ts +15 -15
  105. package/src/components/ldvSlider.tsx +103 -103
  106. package/src/components/ldvSwitch.d.ts +10 -10
  107. package/src/components/ldvSwitch.tsx +52 -52
  108. package/src/components/ldvTemperatureSlider.d.ts +13 -13
  109. package/src/components/ldvTemperatureSlider.tsx +139 -139
  110. package/src/components/ldvTopBar.d.ts +10 -10
  111. package/src/components/ldvTopBar.tsx +76 -76
  112. package/src/components/ldvTopName.d.ts +9 -9
  113. package/src/components/ldvTopName.tsx +63 -63
  114. package/src/components/segmentControl.d.ts +1 -1
  115. package/src/components/segmentControl.tsx +65 -65
  116. package/src/components/weekSelect.d.ts +7 -7
  117. package/src/components/weekSelect.tsx +98 -98
  118. package/src/composeLayout.d.ts +30 -30
  119. package/src/composeLayout.tsx +261 -261
  120. package/src/config/dark-theme.ts +61 -61
  121. package/src/config/light-theme.ts +61 -61
  122. package/src/hooks/Hooks.d.ts +2 -2
  123. package/src/hooks/Hooks.ts +8 -8
  124. package/src/i18n/index.d.ts +16 -16
  125. package/src/i18n/index.ts +37 -37
  126. package/src/i18n/strings.d.ts +15953 -15953
  127. package/src/i18n/strings.ts +23781 -23723
  128. package/src/main.tsx +9 -9
  129. package/src/models/GlobalParams.d.ts +14 -14
  130. package/src/models/GlobalParams.ts +14 -14
  131. package/src/models/TuyaApi.d.ts +29 -29
  132. package/src/models/TuyaApi.ts +92 -92
  133. package/src/models/combine.d.ts +26 -26
  134. package/src/models/combine.ts +17 -17
  135. package/src/models/configureStore.d.ts +9 -9
  136. package/src/models/configureStore.ts +33 -33
  137. package/src/models/index.d.ts +31 -31
  138. package/src/models/index.ts +22 -22
  139. package/src/models/modules/NativePropsSlice.d.ts +61 -61
  140. package/src/models/modules/NativePropsSlice.tsx +467 -467
  141. package/src/models/modules/Result.d.ts +14 -14
  142. package/src/models/modules/Result.ts +15 -15
  143. package/src/models/modules/common.d.ts +44 -44
  144. package/src/models/modules/common.ts +161 -161
  145. package/src/res/index.d.ts +70 -70
  146. package/src/res/index.ts +73 -73
  147. package/src/utils/ColorParser.d.ts +66 -66
  148. package/src/utils/ColorParser.ts +189 -189
  149. package/src/utils/ColorUtils.d.ts +71 -71
  150. package/src/utils/ColorUtils.tsx +448 -448
  151. package/src/utils/Support.d.ts +13 -13
  152. package/src/utils/Support.ts +108 -108
  153. package/src/utils/TypeUtils.d.ts +3 -3
  154. package/src/utils/cctUtils.d.ts +1 -1
  155. package/src/utils/cctUtils.ts +110 -110
  156. package/src/utils/common.d.ts +35 -35
  157. package/src/utils/common.ts +379 -379
  158. package/src/utils/index.d.ts +26 -26
  159. package/src/utils/index.ts +191 -191
  160. package/src/utils/interface.d.ts +6 -6
  161. package/src/utils/interface.ts +50 -50
  162. package/src/utils/loopsCompare.d.ts +1 -1
  163. package/src/utils/loopsCompare.ts +62 -62
  164. package/tsconfig.json +50 -50
  165. package/update-localazy.py +52 -52
@@ -1,104 +1,104 @@
1
- import React, { PropsWithChildren, useCallback, useEffect } from 'react'
2
- import { BackHandler, View, ViewProps } from 'react-native'
3
- import LDVTopBar from './ldvTopBar'
4
- import { useNavigation } from '@react-navigation/native'
5
- import {Dialog, Toast, Utils} from 'tuya-panel-kit'
6
- import I18n from '@i18n'
7
- import LdvTopName from './ldvTopName'
8
-
9
- const { withTheme } = Utils.ThemeUtils
10
-
11
- interface PageProps extends PropsWithChildren<ViewProps> {
12
- theme?: any
13
- rightButtonDisabled?: boolean
14
- backText: string
15
- onBackClick?: () => void
16
- showBackDialog?: boolean
17
- backDialogTitle?: string
18
- backDialogContent?: string
19
- rightButtonIcon?: string
20
- rightButtonStyle?: any | undefined
21
- rightButtonIconClick?: () => void
22
- headlineText?: string
23
- headlineIcon?: string | number
24
- onHeadlineIconClick?: () => void
25
- headlineContent?: React.ReactNode
26
- showGreenery?: boolean
27
- greeneryIcon?: string | undefined | number
28
- loading?: boolean
29
- }
30
-
31
- const Page = (props: PageProps) => {
32
- const navigation = useNavigation()
33
- const disabled = props.rightButtonDisabled
34
-
35
- const onBack = useCallback(() => {
36
- if (disabled) {
37
- navigation.goBack()
38
- return true
39
- }
40
- Dialog.confirm({
41
- title: props.backDialogTitle || '',
42
- subTitle: props.backDialogContent || '',
43
- cancelText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
44
- confirmText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
45
- onConfirm: (_, { close }) => {
46
- close()
47
- navigation.goBack()
48
- },
49
- motionConfig: {
50
- hideDuration: 0,
51
- showDuration: 100,
52
- },
53
- })
54
- return true
55
- },
56
- [props.backDialogTitle, props.backDialogContent, disabled],
57
- )
58
-
59
- useEffect(() => {
60
- if (!!props.showBackDialog) {
61
- BackHandler.addEventListener('hardwareBackPress', onBack)
62
- return () => {
63
- BackHandler.removeEventListener('hardwareBackPress', onBack)
64
- }
65
- }
66
- }, [props.showBackDialog, disabled])
67
-
68
- return (
69
- <>
70
- <View style={[{ flex: 1, position: 'relative', backgroundColor: props.theme.global.backgroud }, props.style]}>
71
- <LDVTopBar
72
- title={props.backText}
73
- onBackPress={
74
- !!props.onBackClick ? props.onBackClick :
75
- !!props.showBackDialog ? onBack : (() => {
76
- navigation.goBack()
77
- })
78
- }
79
- rightButtonIcon={props.rightButtonIcon}
80
- rightButtonStyle={props.rightButtonStyle}
81
- onRightButtonPress={props.rightButtonIconClick}
82
- rightButtonDisabled={disabled}/>
83
- {(!!props.headlineText) &&
84
- <LdvTopName
85
- title={props.headlineText}
86
- rightIcon={props.headlineIcon}
87
- rightIconClick={props.onHeadlineIconClick}
88
- showGreenery={props.showGreenery}
89
- greeneryIcon={props.greeneryIcon}
90
- headlineContent={props.headlineContent}
91
- />}
92
- {props.children}
93
- </View>
94
- {!!props.loading && <Toast.Loading
95
- style={{ zIndex: 999, elevation: 10 }}
96
- show={props.loading}
97
- onFinish={() => {
98
-
99
- }}/>}
100
- </>
101
- )
102
- }
103
-
104
- export default withTheme(Page)
1
+ import React, { PropsWithChildren, useCallback, useEffect } from 'react'
2
+ import { BackHandler, View, ViewProps } from 'react-native'
3
+ import LDVTopBar from './ldvTopBar'
4
+ import { useNavigation } from '@react-navigation/native'
5
+ import {Dialog, Toast, Utils} from 'tuya-panel-kit'
6
+ import I18n from '@i18n'
7
+ import LdvTopName from './ldvTopName'
8
+
9
+ const { withTheme } = Utils.ThemeUtils
10
+
11
+ interface PageProps extends PropsWithChildren<ViewProps> {
12
+ theme?: any
13
+ rightButtonDisabled?: boolean
14
+ backText: string
15
+ onBackClick?: () => void
16
+ showBackDialog?: boolean
17
+ backDialogTitle?: string
18
+ backDialogContent?: string
19
+ rightButtonIcon?: string
20
+ rightButtonStyle?: any | undefined
21
+ rightButtonIconClick?: () => void
22
+ headlineText?: string
23
+ headlineIcon?: string | number
24
+ onHeadlineIconClick?: () => void
25
+ headlineContent?: React.ReactNode
26
+ showGreenery?: boolean
27
+ greeneryIcon?: string | undefined | number
28
+ loading?: boolean
29
+ }
30
+
31
+ const Page = (props: PageProps) => {
32
+ const navigation = useNavigation()
33
+ const disabled = props.rightButtonDisabled
34
+
35
+ const onBack = useCallback(() => {
36
+ if (disabled) {
37
+ navigation.goBack()
38
+ return true
39
+ }
40
+ Dialog.confirm({
41
+ title: props.backDialogTitle || '',
42
+ subTitle: props.backDialogContent || '',
43
+ cancelText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
44
+ confirmText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
45
+ onConfirm: (_, { close }) => {
46
+ close()
47
+ navigation.goBack()
48
+ },
49
+ motionConfig: {
50
+ hideDuration: 0,
51
+ showDuration: 100,
52
+ },
53
+ })
54
+ return true
55
+ },
56
+ [props.backDialogTitle, props.backDialogContent, disabled],
57
+ )
58
+
59
+ useEffect(() => {
60
+ if (!!props.showBackDialog) {
61
+ BackHandler.addEventListener('hardwareBackPress', onBack)
62
+ return () => {
63
+ BackHandler.removeEventListener('hardwareBackPress', onBack)
64
+ }
65
+ }
66
+ }, [props.showBackDialog, disabled])
67
+
68
+ return (
69
+ <>
70
+ <View style={[{ flex: 1, position: 'relative', backgroundColor: props.theme.global.backgroud }, props.style]}>
71
+ <LDVTopBar
72
+ title={props.backText}
73
+ onBackPress={
74
+ !!props.onBackClick ? props.onBackClick :
75
+ !!props.showBackDialog ? onBack : (() => {
76
+ navigation.goBack()
77
+ })
78
+ }
79
+ rightButtonIcon={props.rightButtonIcon}
80
+ rightButtonStyle={props.rightButtonStyle}
81
+ onRightButtonPress={props.rightButtonIconClick}
82
+ rightButtonDisabled={disabled}/>
83
+ {(!!props.headlineText) &&
84
+ <LdvTopName
85
+ title={props.headlineText}
86
+ rightIcon={props.headlineIcon}
87
+ rightIconClick={props.onHeadlineIconClick}
88
+ showGreenery={props.showGreenery}
89
+ greeneryIcon={props.greeneryIcon}
90
+ headlineContent={props.headlineContent}
91
+ />}
92
+ {props.children}
93
+ </View>
94
+ {!!props.loading && <Toast.Loading
95
+ style={{ zIndex: 999, elevation: 10 }}
96
+ show={props.loading}
97
+ onFinish={() => {
98
+
99
+ }}/>}
100
+ </>
101
+ )
102
+ }
103
+
104
+ export default withTheme(Page)
@@ -1,7 +1,7 @@
1
- interface InformationPopupProps {
2
- title: string;
3
- confirmText: string;
4
- content: any;
5
- }
6
- declare const InformationPopup: (props: InformationPopupProps) => void;
7
- export default InformationPopup;
1
+ interface InformationPopupProps {
2
+ title: string;
3
+ confirmText: string;
4
+ content: any;
5
+ }
6
+ declare const InformationPopup: (props: InformationPopupProps) => void;
7
+ export default InformationPopup;
@@ -1,72 +1,72 @@
1
- import React from 'react'
2
- import {Text, TouchableOpacity, View} from 'react-native'
3
- import {Popup, Utils} from 'tuya-panel-kit'
4
-
5
- const {convertX: cx, height} = Utils.RatioUtils
6
-
7
- interface InformationPopupProps {
8
- title: string
9
- confirmText: string
10
- content: any
11
- }
12
-
13
- const InformationPopup = (props: InformationPopupProps) => {
14
- console.log(props, '< --- props')
15
-
16
- const titleNode = () => {
17
- return (
18
- <View style={{flexDirection: 'row', height: cx(80), justifyContent: 'space-between'}}>
19
- <View style={{flexDirection: 'column-reverse', flex: 1, alignItems: 'center', paddingLeft: cx(12)}}>
20
- <Text style={{
21
- fontSize: cx(16),
22
- fontWeight: 'bold',
23
- color: '#000000',
24
- paddingBottom: cx(12),
25
-
26
- }}>{props.title}</Text>
27
- </View>
28
- <TouchableOpacity
29
- style={{
30
- flexDirection: 'column-reverse',
31
- alignItems: 'center',
32
- paddingBottom: cx(12),
33
- paddingRight: cx(6),
34
- }}
35
- onPress={() => Popup.close()}
36
- >
37
- <Text
38
- style={{
39
- fontSize: cx(12),
40
- color: '#FF6600',
41
- }}
42
- >
43
- {props.confirmText}
44
- </Text>
45
- </TouchableOpacity>
46
- </View>
47
- )
48
- }
49
-
50
- Popup.custom({
51
- content: <View style={{height: height - cx(80), padding: cx(24)}}>
52
- {props.content}
53
- </View>,
54
- title: titleNode(),
55
- footer: null,
56
- confirmText: '',
57
- cancelText: '',
58
- onMaskPress: ({close}) => {
59
- close()
60
- },
61
- onConfirm: () => {
62
- Popup.close()
63
- },
64
- footerWrapperStyle: {
65
- display: 'none',
66
- },
67
- })
68
-
69
-
70
- }
71
-
1
+ import React from 'react'
2
+ import {Text, TouchableOpacity, View} from 'react-native'
3
+ import {Popup, Utils} from 'tuya-panel-kit'
4
+
5
+ const {convertX: cx, height} = Utils.RatioUtils
6
+
7
+ interface InformationPopupProps {
8
+ title: string
9
+ confirmText: string
10
+ content: any
11
+ }
12
+
13
+ const InformationPopup = (props: InformationPopupProps) => {
14
+ console.log(props, '< --- props')
15
+
16
+ const titleNode = () => {
17
+ return (
18
+ <View style={{flexDirection: 'row', height: cx(80), justifyContent: 'space-between'}}>
19
+ <View style={{flexDirection: 'column-reverse', flex: 1, alignItems: 'center', paddingLeft: cx(12)}}>
20
+ <Text style={{
21
+ fontSize: cx(16),
22
+ fontWeight: 'bold',
23
+ color: '#000000',
24
+ paddingBottom: cx(12),
25
+
26
+ }}>{props.title}</Text>
27
+ </View>
28
+ <TouchableOpacity
29
+ style={{
30
+ flexDirection: 'column-reverse',
31
+ alignItems: 'center',
32
+ paddingBottom: cx(12),
33
+ paddingRight: cx(6),
34
+ }}
35
+ onPress={() => Popup.close()}
36
+ >
37
+ <Text
38
+ style={{
39
+ fontSize: cx(12),
40
+ color: '#FF6600',
41
+ }}
42
+ >
43
+ {props.confirmText}
44
+ </Text>
45
+ </TouchableOpacity>
46
+ </View>
47
+ )
48
+ }
49
+
50
+ Popup.custom({
51
+ content: <View style={{height: height - cx(80), padding: cx(24)}}>
52
+ {props.content}
53
+ </View>,
54
+ title: titleNode(),
55
+ footer: null,
56
+ confirmText: '',
57
+ cancelText: '',
58
+ onMaskPress: ({close}) => {
59
+ close()
60
+ },
61
+ onConfirm: () => {
62
+ Popup.close()
63
+ },
64
+ footerWrapperStyle: {
65
+ display: 'none',
66
+ },
67
+ })
68
+
69
+
70
+ }
71
+
72
72
  export default InformationPopup
@@ -1,14 +1,14 @@
1
- import { ReactNode } from 'react';
2
- import { ViewStyle } from 'react-native';
3
- interface SegmentedItem {
4
- label: ReactNode;
5
- value: string | number;
6
- }
7
- interface SegmentedProps {
8
- value?: string | number;
9
- options?: SegmentedItem[];
10
- onChange?: (v: string | number) => void;
11
- style?: ViewStyle;
12
- }
13
- declare const Segmented: (props: SegmentedProps) => JSX.Element;
14
- export default Segmented;
1
+ import { ReactNode } from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ interface SegmentedItem {
4
+ label: ReactNode;
5
+ value: string | number;
6
+ }
7
+ interface SegmentedProps {
8
+ value?: string | number;
9
+ options?: SegmentedItem[];
10
+ onChange?: (v: string | number) => void;
11
+ style?: ViewStyle;
12
+ }
13
+ declare const Segmented: (props: SegmentedProps) => JSX.Element;
14
+ export default Segmented;
@@ -1,77 +1,77 @@
1
- import React, {ReactNode} from 'react'
2
- import {StyleSheet, Text, TouchableOpacity, View, ViewStyle} from 'react-native'
3
- import {Utils} from 'tuya-panel-kit'
4
-
5
- const {convertX: cx} = Utils.RatioUtils
6
-
7
- interface SegmentedItem {
8
- label: ReactNode
9
- value: string | number
10
- }
11
-
12
- interface SegmentedProps {
13
- value?: string | number
14
- options?: SegmentedItem[]
15
- onChange?: (v: string | number) => void
16
- style?: ViewStyle
17
- }
18
-
19
- const Segmented = (props: SegmentedProps) => {
20
- return (
21
- <View style={[styles.wrap_container, props.style]}>
22
- {props.options && props.options.map((item, idx) => (
23
- <TouchableOpacity
24
- style={[
25
- styles.segmented_item,
26
- idx === 0 && styles.segmented_item_first,
27
- idx + 1 === props.options?.length && styles.segmented_item_last,
28
- item.value === props.value && styles.segmented_item_check,
29
- ]}
30
- onPress={() => props.onChange && props.onChange(item.value)}
31
- key={idx}
32
- >
33
- <Text style={[
34
- styles.segmented_text,
35
- item.value === props.value && styles.segmented_text_check,
36
- ]}>{item.label}</Text>
37
- </TouchableOpacity>
38
- ))}
39
- </View>
40
- )
41
- }
42
-
43
- export default Segmented
44
-
45
- const styles = StyleSheet.create({
46
- wrap_container: {
47
- flexDirection: 'row',
48
- height: cx(42),
49
- backgroundColor: '#f6f6f6',
50
- padding: cx(2),
51
- borderRadius: cx(8),
52
- },
53
- segmented_item: {
54
- flex: 1,
55
- alignItems: 'center',
56
- justifyContent: 'center',
57
- backgroundColor: '#fff',
58
- },
59
- segmented_item_first: {
60
- borderBottomLeftRadius: cx(8),
61
- borderTopLeftRadius: cx(8),
62
- },
63
- segmented_item_last: {
64
- borderBottomRightRadius: cx(8),
65
- borderTopRightRadius: cx(8),
66
- },
67
- segmented_item_check: {
68
- backgroundColor: '#f60',
69
- },
70
- segmented_text: {
71
- fontSize: cx(16),
72
- color: '#999',
73
- },
74
- segmented_text_check: {
75
- color: '#fff',
76
- },
1
+ import React, {ReactNode} from 'react'
2
+ import {StyleSheet, Text, TouchableOpacity, View, ViewStyle} from 'react-native'
3
+ import {Utils} from 'tuya-panel-kit'
4
+
5
+ const {convertX: cx} = Utils.RatioUtils
6
+
7
+ interface SegmentedItem {
8
+ label: ReactNode
9
+ value: string | number
10
+ }
11
+
12
+ interface SegmentedProps {
13
+ value?: string | number
14
+ options?: SegmentedItem[]
15
+ onChange?: (v: string | number) => void
16
+ style?: ViewStyle
17
+ }
18
+
19
+ const Segmented = (props: SegmentedProps) => {
20
+ return (
21
+ <View style={[styles.wrap_container, props.style]}>
22
+ {props.options && props.options.map((item, idx) => (
23
+ <TouchableOpacity
24
+ style={[
25
+ styles.segmented_item,
26
+ idx === 0 && styles.segmented_item_first,
27
+ idx + 1 === props.options?.length && styles.segmented_item_last,
28
+ item.value === props.value && styles.segmented_item_check,
29
+ ]}
30
+ onPress={() => props.onChange && props.onChange(item.value)}
31
+ key={idx}
32
+ >
33
+ <Text style={[
34
+ styles.segmented_text,
35
+ item.value === props.value && styles.segmented_text_check,
36
+ ]}>{item.label}</Text>
37
+ </TouchableOpacity>
38
+ ))}
39
+ </View>
40
+ )
41
+ }
42
+
43
+ export default Segmented
44
+
45
+ const styles = StyleSheet.create({
46
+ wrap_container: {
47
+ flexDirection: 'row',
48
+ height: cx(42),
49
+ backgroundColor: '#f6f6f6',
50
+ padding: cx(2),
51
+ borderRadius: cx(8),
52
+ },
53
+ segmented_item: {
54
+ flex: 1,
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ backgroundColor: '#fff',
58
+ },
59
+ segmented_item_first: {
60
+ borderBottomLeftRadius: cx(8),
61
+ borderTopLeftRadius: cx(8),
62
+ },
63
+ segmented_item_last: {
64
+ borderBottomRightRadius: cx(8),
65
+ borderTopRightRadius: cx(8),
66
+ },
67
+ segmented_item_check: {
68
+ backgroundColor: '#f60',
69
+ },
70
+ segmented_text: {
71
+ fontSize: cx(16),
72
+ color: '#999',
73
+ },
74
+ segmented_text_check: {
75
+ color: '#fff',
76
+ },
77
77
  })
@@ -1 +1 @@
1
- export declare const ShowSelectView: (title: any, data: any, defaultValue: any, callback: any) => void;
1
+ export declare const ShowSelectView: (title: any, data: any, defaultValue: any, callback: any) => void;