@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,3 +1,3 @@
1
- export declare const nativeEventEmitter: import("react-native").EventEmitter;
2
- export declare const addListener: (store: any) => void;
3
- export declare const removeListener: () => void;
1
+ export declare const nativeEventEmitter: import("react-native").EventEmitter;
2
+ export declare const addListener: (store: any) => void;
3
+ export declare const removeListener: () => void;
@@ -1,125 +1,125 @@
1
- import {EmitterSubscription, NativeEventEmitter, NativeModules} from 'react-native'
2
- import {
3
- DeviceInfo,
4
- NativeProps,
5
- setGroupDevices,
6
- setGroupDps,
7
- setGroupNativeProps,
8
- setNativeProps,
9
- UAGroupInfo,
10
- } from '../models/modules/NativePropsSlice'
11
- import {actions} from '@models'
12
- import { cloneDeep } from 'lodash'
13
- import {DpValue} from "tuya-panel-kit";
14
-
15
- const nativeModule = NativeModules.LDVDeviceEventEmitter
16
-
17
- export const nativeEventEmitter = new NativeEventEmitter(nativeModule)
18
-
19
- let deviceDPListener: EmitterSubscription | null
20
- let groupFeatureListener: EmitterSubscription | null
21
- let groupDeviceListener: EmitterSubscription | null
22
- let groupDpListener: EmitterSubscription | null
23
-
24
- interface GroupFeatureEvent {
25
- tyGroupId: number
26
- config: string
27
- }
28
-
29
- interface GroupDpEvent {
30
- tyGroupId: number
31
- dps: any
32
- }
33
-
34
- interface DeviceEvent {
35
- devId: string
36
- dps: any
37
- name: string
38
- pId: string
39
- }
40
-
41
- interface TYInfoUpdateType {
42
- devId: string
43
- online: boolean
44
- }
45
-
46
- export const addListener = (store) => {
47
- deviceDPListener = nativeEventEmitter.addListener('TYDataUpdate', (event: DeviceEvent) => {
48
- // device info
49
- if (event.dps && event.devId && event.devId === store.getState().ldvModules.deviceInfo.devId) {
50
- console.log('长链接刷新DP数据', event.devId, event.dps)
51
- // @ts-ignore
52
- const nativeProps: NativeProps = {
53
- familyName: '',
54
- deviceInfo: {
55
- devId: event.devId,
56
- pId: event.pId,
57
- dps: JSON.parse(event.dps),
58
- },
59
- uaGroupInfo: {} as UAGroupInfo,
60
- }
61
- store.dispatch(setNativeProps(nativeProps))
62
- }
63
- // 兼容ios修改设备名称
64
- if (!!event.name && event.devId && event.devId === store.getState().ldvModules.deviceInfo.devId) {
65
- store.dispatch(actions.common.devInfoChange({...store.getState().devInfo, name: event.name}))
66
- }
67
- })
68
-
69
- groupFeatureListener = nativeEventEmitter.addListener('UAGroupFeatureUpdate', (event: GroupFeatureEvent) => {
70
- const tyGroupId = Number(event.tyGroupId)
71
- if (tyGroupId == store.getState().ldvModules.uaGroupInfo.tyGroupId) {
72
- console.log('长链接刷新Group数据', event)
73
- // @ts-ignore
74
- const nativeProps: NativeProps = {
75
- familyName: '',
76
- deviceInfo: {} as DeviceInfo,
77
- uaGroupInfo: {
78
- tyGroupId: tyGroupId,
79
- pId: '',
80
- config: JSON.parse(event.config),
81
- dps: {},
82
- } as UAGroupInfo,
83
- }
84
- store.dispatch(setGroupNativeProps(nativeProps))
85
- }
86
- })
87
-
88
- groupDpListener = nativeEventEmitter.addListener('UAGroupDpUpdate', (event: GroupDpEvent) => {
89
- const tyGroupId = Number(event.tyGroupId);
90
- const groupId = Number(store.getState().ldvModules.uaGroupInfo.tyGroupId)
91
- if (tyGroupId === groupId) {
92
- let data = event.dps
93
- if (typeof event.dps === 'string') {
94
- data = JSON.parse(event.dps)
95
- }
96
- store.dispatch(setGroupDps(data as Record<string, DpValue>))
97
- }
98
- })
99
-
100
- groupDeviceListener = nativeEventEmitter.addListener('TYInfoUpdate', (event: TYInfoUpdateType) =>{
101
- const groupDevices = cloneDeep(store.getState().ldvModules.uaGroupInfo.groupDevices)
102
- const idx = groupDevices.findIndex(device => device?.deviceId?.indexOf(event.devId) !== -1)
103
- if(idx !== -1 && Number(groupDevices[idx].status) !== (event.online ? 1 : 0)){
104
- groupDevices[idx] = {
105
- ...groupDevices[idx],
106
- status: event.online ? 1 : 0
107
- }
108
- store.dispatch(setGroupDevices(groupDevices))
109
- }
110
- })
111
- }
112
-
113
- export const removeListener = () => {
114
- deviceDPListener && deviceDPListener.remove()
115
- deviceDPListener = null
116
-
117
- groupFeatureListener && groupFeatureListener.remove()
118
- groupFeatureListener = null
119
-
120
- groupDeviceListener && groupDeviceListener.remove()
121
- groupDeviceListener = null
122
-
123
- groupDpListener && groupDpListener.remove()
124
- groupDpListener = null
125
- }
1
+ import {EmitterSubscription, NativeEventEmitter, NativeModules} from 'react-native'
2
+ import {
3
+ DeviceInfo,
4
+ NativeProps,
5
+ setGroupDevices,
6
+ setGroupDps,
7
+ setGroupNativeProps,
8
+ setNativeProps,
9
+ UAGroupInfo,
10
+ } from '../models/modules/NativePropsSlice'
11
+ import {actions} from '@models'
12
+ import { cloneDeep } from 'lodash'
13
+ import {DpValue} from "tuya-panel-kit";
14
+
15
+ const nativeModule = NativeModules.LDVDeviceEventEmitter
16
+
17
+ export const nativeEventEmitter = new NativeEventEmitter(nativeModule)
18
+
19
+ let deviceDPListener: EmitterSubscription | null
20
+ let groupFeatureListener: EmitterSubscription | null
21
+ let groupDeviceListener: EmitterSubscription | null
22
+ let groupDpListener: EmitterSubscription | null
23
+
24
+ interface GroupFeatureEvent {
25
+ tyGroupId: number
26
+ config: string
27
+ }
28
+
29
+ interface GroupDpEvent {
30
+ tyGroupId: number
31
+ dps: any
32
+ }
33
+
34
+ interface DeviceEvent {
35
+ devId: string
36
+ dps: any
37
+ name: string
38
+ pId: string
39
+ }
40
+
41
+ interface TYInfoUpdateType {
42
+ devId: string
43
+ online: boolean
44
+ }
45
+
46
+ export const addListener = (store) => {
47
+ deviceDPListener = nativeEventEmitter.addListener('TYDataUpdate', (event: DeviceEvent) => {
48
+ // device info
49
+ if (event.dps && event.devId && event.devId === store.getState().ldvModules.deviceInfo.devId) {
50
+ console.log('长链接刷新DP数据', event.devId, event.dps)
51
+ // @ts-ignore
52
+ const nativeProps: NativeProps = {
53
+ familyName: '',
54
+ deviceInfo: {
55
+ devId: event.devId,
56
+ pId: event.pId,
57
+ dps: JSON.parse(event.dps),
58
+ },
59
+ uaGroupInfo: {} as UAGroupInfo,
60
+ }
61
+ store.dispatch(setNativeProps(nativeProps))
62
+ }
63
+ // 兼容ios修改设备名称
64
+ if (!!event.name && event.devId && event.devId === store.getState().ldvModules.deviceInfo.devId) {
65
+ store.dispatch(actions.common.devInfoChange({...store.getState().devInfo, name: event.name}))
66
+ }
67
+ })
68
+
69
+ groupFeatureListener = nativeEventEmitter.addListener('UAGroupFeatureUpdate', (event: GroupFeatureEvent) => {
70
+ const tyGroupId = Number(event.tyGroupId)
71
+ if (tyGroupId == store.getState().ldvModules.uaGroupInfo.tyGroupId) {
72
+ console.log('长链接刷新Group数据', event)
73
+ // @ts-ignore
74
+ const nativeProps: NativeProps = {
75
+ familyName: '',
76
+ deviceInfo: {} as DeviceInfo,
77
+ uaGroupInfo: {
78
+ tyGroupId: tyGroupId,
79
+ pId: '',
80
+ config: JSON.parse(event.config),
81
+ dps: {},
82
+ } as UAGroupInfo,
83
+ }
84
+ store.dispatch(setGroupNativeProps(nativeProps))
85
+ }
86
+ })
87
+
88
+ groupDpListener = nativeEventEmitter.addListener('UAGroupDpUpdate', (event: GroupDpEvent) => {
89
+ const tyGroupId = Number(event.tyGroupId);
90
+ const groupId = Number(store.getState().ldvModules.uaGroupInfo.tyGroupId)
91
+ if (tyGroupId === groupId) {
92
+ let data = event.dps
93
+ if (typeof event.dps === 'string') {
94
+ data = JSON.parse(event.dps)
95
+ }
96
+ store.dispatch(setGroupDps(data as Record<string, DpValue>))
97
+ }
98
+ })
99
+
100
+ groupDeviceListener = nativeEventEmitter.addListener('TYInfoUpdate', (event: TYInfoUpdateType) =>{
101
+ const groupDevices = cloneDeep(store.getState().ldvModules.uaGroupInfo.groupDevices)
102
+ const idx = groupDevices.findIndex(device => device?.deviceId?.indexOf(event.devId) !== -1)
103
+ if(idx !== -1 && Number(groupDevices[idx].status) !== (event.online ? 1 : 0)){
104
+ groupDevices[idx] = {
105
+ ...groupDevices[idx],
106
+ status: event.online ? 1 : 0
107
+ }
108
+ store.dispatch(setGroupDevices(groupDevices))
109
+ }
110
+ })
111
+ }
112
+
113
+ export const removeListener = () => {
114
+ deviceDPListener && deviceDPListener.remove()
115
+ deviceDPListener = null
116
+
117
+ groupFeatureListener && groupFeatureListener.remove()
118
+ groupFeatureListener = null
119
+
120
+ groupDeviceListener && groupDeviceListener.remove()
121
+ groupDeviceListener = null
122
+
123
+ groupDpListener && groupDpListener.remove()
124
+ groupDpListener = null
125
+ }
@@ -1,25 +1,25 @@
1
- export interface AdvancedData {
2
- title: string;
3
- subtitles?: string[];
4
- statusColor: string;
5
- router: {
6
- key: string;
7
- params?: any;
8
- };
9
- dp?: {
10
- key: string;
11
- code: string;
12
- };
13
- }
14
- export declare enum AdvancedStatus {
15
- Enable = "enable",
16
- Disable = "disable",
17
- Suspend = "suspend"
18
- }
19
- export declare function getAdvancedStatusColor(status: AdvancedStatus): string;
20
- export interface AdvanceCardProps {
21
- data: AdvancedData;
22
- onPress: () => void;
23
- }
24
- declare const AdvanceCard: (props: AdvanceCardProps) => JSX.Element;
25
- export default AdvanceCard;
1
+ export interface AdvancedData {
2
+ title: string;
3
+ subtitles?: string[];
4
+ statusColor: string;
5
+ router: {
6
+ key: string;
7
+ params?: any;
8
+ };
9
+ dp?: {
10
+ key: string;
11
+ code: string;
12
+ };
13
+ }
14
+ export declare enum AdvancedStatus {
15
+ Enable = "enable",
16
+ Disable = "disable",
17
+ Suspend = "suspend"
18
+ }
19
+ export declare function getAdvancedStatusColor(status: AdvancedStatus): string;
20
+ export interface AdvanceCardProps {
21
+ data: AdvancedData;
22
+ onPress: () => void;
23
+ }
24
+ declare const AdvanceCard: (props: AdvanceCardProps) => JSX.Element;
25
+ export default AdvanceCard;
@@ -1,117 +1,117 @@
1
- import React, { PropsWithChildren } from 'react'
2
- import { StyleSheet, Text, View, ViewProps } from 'react-native'
3
- import { Utils } from 'tuya-panel-kit'
4
- import Card from 'components/Card'
5
- import Spacer from 'components/Spacer'
6
-
7
- const { convertX: cx } = Utils.RatioUtils
8
- const { withTheme } = Utils.ThemeUtils
9
-
10
- export interface AdvancedData {
11
- title: string
12
- subtitles?: string[]
13
- statusColor?: string
14
- router: { key: string, params?: any }
15
- dp?: { key: string, code: string }
16
- icons?: number | string
17
- }
18
-
19
- const enableStatusColor = 'rgb(0, 201, 49)'
20
- const suspendStatusColor = '#FFDEAD'
21
- const disableStatusColor = '#cbcbcb'
22
-
23
- export enum AdvancedStatus {
24
- Enable = 'enable',
25
- Disable = 'disable',
26
- Suspend = 'suspend',
27
- }
28
-
29
- export function getAdvancedStatusColor(status: AdvancedStatus): string {
30
- switch (status) {
31
- case AdvancedStatus.Enable:
32
- return enableStatusColor
33
- case AdvancedStatus.Suspend:
34
- return suspendStatusColor
35
- case AdvancedStatus.Disable:
36
- return disableStatusColor
37
- }
38
- }
39
-
40
- export interface AdvanceCardProps extends PropsWithChildren<ViewProps> {
41
- theme?: any
42
- data: AdvancedData
43
- onPress: () => void
44
- }
45
-
46
- const AdvanceCard = (props: AdvanceCardProps) => {
47
- const {statusColor} = props.data;
48
- return (
49
- <Card
50
- style={styles.itemContainer}
51
- containerStyle={styles.itemContent}
52
- onPress={props.onPress}>
53
- {!!statusColor && <View style={styles.dotBg}>
54
- <View
55
- style={[
56
- styles.dot,
57
- {backgroundColor: props.data.statusColor},
58
- ]}/>
59
- </View>}
60
- {
61
- props.children ?
62
- props.children :
63
- <View style={styles.titleBg}>
64
- <Text style={{...styles.title, color: props.theme.global.fontColor}}>{props.data.title}</Text>
65
- <Spacer height={cx(8)} />
66
- {
67
- (!!props.data.subtitles) && props.data.subtitles.map((subtitle, index) => (
68
- <Text style={{...styles.subtitle, color: props.theme.global.secondFontColor}} key={`${subtitle}_${index}`}>{subtitle}</Text>
69
- ))
70
- }
71
- </View>
72
- }
73
- </Card>
74
- )
75
- }
76
-
77
- const styles = StyleSheet.create({
78
- itemContainer: {
79
- width: cx(154),
80
- borderRadius: cx(16),
81
- },
82
- itemContent: {},
83
- titleBg: {
84
- height: cx(118),
85
- justifyContent: 'center',
86
- alignItems: 'center',
87
- },
88
- title: {
89
- marginHorizontal: cx(16),
90
- fontSize: cx(14),
91
- textAlign: 'center',
92
- fontFamily: 'helvetica_neue_lt_std_roman',
93
- },
94
- subtitle: {
95
- fontSize: cx(10),
96
- textAlign: 'center',
97
- fontFamily: 'helvetica_neue_lt_std_roman',
98
- },
99
- dotBg: {
100
- position: 'absolute',
101
- top: cx(10),
102
- end: cx(10),
103
- borderWidth: cx(.5),
104
- borderColor: '#cbcbcb80',
105
- borderRadius: cx(7),
106
- },
107
- dot: {
108
- width: cx(10),
109
- height: cx(10),
110
- backgroundColor: 'rgb(0, 201, 49)',
111
- borderRadius: cx(5),
112
- borderColor: '#fff',
113
- borderWidth: cx(1),
114
- },
115
- })
116
-
117
- export default withTheme(AdvanceCard)
1
+ import React, { PropsWithChildren } from 'react'
2
+ import { StyleSheet, Text, View, ViewProps } from 'react-native'
3
+ import { Utils } from 'tuya-panel-kit'
4
+ import Card from 'components/Card'
5
+ import Spacer from 'components/Spacer'
6
+
7
+ const { convertX: cx } = Utils.RatioUtils
8
+ const { withTheme } = Utils.ThemeUtils
9
+
10
+ export interface AdvancedData {
11
+ title: string
12
+ subtitles?: string[]
13
+ statusColor?: string
14
+ router: { key: string, params?: any }
15
+ dp?: { key: string, code: string }
16
+ icons?: number | string
17
+ }
18
+
19
+ const enableStatusColor = 'rgb(0, 201, 49)'
20
+ const suspendStatusColor = '#FFDEAD'
21
+ const disableStatusColor = '#cbcbcb'
22
+
23
+ export enum AdvancedStatus {
24
+ Enable = 'enable',
25
+ Disable = 'disable',
26
+ Suspend = 'suspend',
27
+ }
28
+
29
+ export function getAdvancedStatusColor(status: AdvancedStatus): string {
30
+ switch (status) {
31
+ case AdvancedStatus.Enable:
32
+ return enableStatusColor
33
+ case AdvancedStatus.Suspend:
34
+ return suspendStatusColor
35
+ case AdvancedStatus.Disable:
36
+ return disableStatusColor
37
+ }
38
+ }
39
+
40
+ export interface AdvanceCardProps extends PropsWithChildren<ViewProps> {
41
+ theme?: any
42
+ data: AdvancedData
43
+ onPress: () => void
44
+ }
45
+
46
+ const AdvanceCard = (props: AdvanceCardProps) => {
47
+ const {statusColor} = props.data;
48
+ return (
49
+ <Card
50
+ style={styles.itemContainer}
51
+ containerStyle={styles.itemContent}
52
+ onPress={props.onPress}>
53
+ {!!statusColor && <View style={styles.dotBg}>
54
+ <View
55
+ style={[
56
+ styles.dot,
57
+ {backgroundColor: props.data.statusColor},
58
+ ]}/>
59
+ </View>}
60
+ {
61
+ props.children ?
62
+ props.children :
63
+ <View style={styles.titleBg}>
64
+ <Text style={{...styles.title, color: props.theme.global.fontColor}}>{props.data.title}</Text>
65
+ <Spacer height={cx(8)} />
66
+ {
67
+ (!!props.data.subtitles) && props.data.subtitles.map((subtitle, index) => (
68
+ <Text style={{...styles.subtitle, color: props.theme.global.secondFontColor}} key={`${subtitle}_${index}`}>{subtitle}</Text>
69
+ ))
70
+ }
71
+ </View>
72
+ }
73
+ </Card>
74
+ )
75
+ }
76
+
77
+ const styles = StyleSheet.create({
78
+ itemContainer: {
79
+ width: cx(154),
80
+ borderRadius: cx(16),
81
+ },
82
+ itemContent: {},
83
+ titleBg: {
84
+ height: cx(118),
85
+ justifyContent: 'center',
86
+ alignItems: 'center',
87
+ },
88
+ title: {
89
+ marginHorizontal: cx(16),
90
+ fontSize: cx(14),
91
+ textAlign: 'center',
92
+ fontFamily: 'helvetica_neue_lt_std_roman',
93
+ },
94
+ subtitle: {
95
+ fontSize: cx(10),
96
+ textAlign: 'center',
97
+ fontFamily: 'helvetica_neue_lt_std_roman',
98
+ },
99
+ dotBg: {
100
+ position: 'absolute',
101
+ top: cx(10),
102
+ end: cx(10),
103
+ borderWidth: cx(.5),
104
+ borderColor: '#cbcbcb80',
105
+ borderRadius: cx(7),
106
+ },
107
+ dot: {
108
+ width: cx(10),
109
+ height: cx(10),
110
+ backgroundColor: 'rgb(0, 201, 49)',
111
+ borderRadius: cx(5),
112
+ borderColor: '#fff',
113
+ borderWidth: cx(1),
114
+ },
115
+ })
116
+
117
+ export default withTheme(AdvanceCard)
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import { AdvancedData } from './AdvanceCard';
3
- export interface AdvanceListProps {
4
- advanceData: AdvancedData[];
5
- onAdvanceItemClick?: (advanceData: AdvancedData, index: number) => void | undefined;
6
- }
7
- declare function AdvanceList(props: AdvanceListProps): JSX.Element;
8
- declare const _default: React.MemoExoticComponent<typeof AdvanceList>;
9
- export default _default;
1
+ import React from 'react';
2
+ import { AdvancedData } from './AdvanceCard';
3
+ export interface AdvanceListProps {
4
+ advanceData: AdvancedData[];
5
+ onAdvanceItemClick?: (advanceData: AdvancedData, index: number) => void | undefined;
6
+ }
7
+ declare function AdvanceList(props: AdvanceListProps): JSX.Element;
8
+ declare const _default: React.MemoExoticComponent<typeof AdvanceList>;
9
+ export default _default;