@ledvance/base 1.2.81 → 1.2.83

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 +848 -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 -65
  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 -124
  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 +23723 -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 -11
  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,261 +1,261 @@
1
- import _ from 'lodash'
2
- import React, { Component } from 'react'
3
- import { Provider } from 'react-redux'
4
- import { DevInfo, DpValue, Theme, TYSdk } from 'tuya-panel-kit'
5
- import { actions, store } from './models'
6
- import {addListener, nativeEventEmitter, removeListener} from 'api/nativeEventEmitter'
7
- import {getSystemTimeFormat, getTimeZone, NativeApi} from 'api/native'
8
- import {
9
- DeviceInfo,
10
- NativeProps,
11
- setGroupDevices,
12
- setGroupNativeProps,
13
- setNativeProps,
14
- setSystemTimeFormat,
15
- setTimeZone,
16
- UAGroupInfo,
17
- } from './models/modules/NativePropsSlice'
18
- import { DpSchema, GlobalParams } from './models/GlobalParams'
19
- import Connect from './components/connect'
20
- import darkTheme from "./config/dark-theme";
21
- import lightTheme from "./config/light-theme";
22
-
23
- interface Props {
24
- devInfo: DevInfo
25
- preload?: boolean
26
- ldvDevInfo: LdvDevInfo
27
- uaGroupInfo: UAGroupInfoProps
28
- colorScheme?: string
29
- }
30
-
31
- interface LdvDevInfo extends DeviceInfo {
32
- schema: any
33
- familyName: string
34
- role: 0 | 1 | 2 | 3
35
- }
36
-
37
- interface UAGroupInfoProps extends UAGroupInfo {
38
- schema: any
39
- familyName: string
40
- role: 0 | 1 | 2 | 3
41
- }
42
-
43
- const TYEvent = TYSdk.event
44
- const TYDevice = TYSdk.device
45
-
46
- /**
47
- *
48
- * @param {} component - 需要连接到redux store的组件,通常为即为main
49
- */
50
- const composeLayout = (component: React.ComponentType) => {
51
- const NavigatorLayout = component
52
- const { dispatch } = store
53
-
54
- addListener(store)
55
-
56
- /**
57
- * 此处监听了`设备数据变更`事件,
58
- * 每当dp点数据变更时,会将变更的dp点状态同步更新到`redux`中去。
59
- * 同理当设备信息变更时,也会将变更的设备信息值同步更新到`redux`中去。
60
- */
61
- TYEvent.on('deviceDataChange', data => {
62
- switch (data.type) {
63
- case 'dpData':
64
- dispatch(actions.common.responseUpdateDp(data.payload as Record<string, DpValue>))
65
- break
66
- case 'deviceOnline':
67
- console.log('设备在线状态', data.payload)
68
- break
69
- default:
70
- dispatch(actions.common.deviceChange(data.payload as DevInfo))
71
- break
72
- }
73
- })
74
-
75
- /**
76
- * 此处监听了`网络状态变更事件`事件,
77
- * 每当设备信息变更时,会将变更的设备信息值同步更新到`redux`中去。
78
- */
79
- TYSdk.event.on('networkStateChange', data => {
80
- dispatch(actions.common.deviceChange(data as any))
81
- })
82
-
83
- class PanelComponent extends Component<Props> {
84
- /**
85
- * 如果面板进入时,`devInfo`已经存在(通常都会存在的)
86
- * 这里会调用 setDeviceInfo 将原始的devInfo处理一下,并置入`redux`
87
- *
88
- * 如果面板进入时,`devInfo`不存在,
89
- * 那么会调用 getDeviceInfo 异步获取处理好的`devInfo`,并置入`redux`
90
- */
91
- state = {
92
- colorScheme: 'light'
93
- }
94
- constructor(props: Props) {
95
- super(props)
96
- if (props && props.devInfo && props.devInfo.devId) {
97
- TYDevice.setDeviceInfo(props.devInfo)
98
- TYDevice.getDeviceInfo()
99
- .then(data => {
100
- dispatch(actions.common.devInfoChange(data))
101
- return Promise.all([TYDevice.getDeviceState(), data])
102
- })
103
- .then(([dpState, devInfo]) => {
104
- const isEqual = _.isEqual(dpState, devInfo.state)
105
- if (isEqual) return
106
- dispatch(actions.common.responseUpdateDp(dpState))
107
- })
108
- } else if (props.preload) {
109
- // do something
110
- } else {
111
- TYDevice.getDeviceInfo().then(data => dispatch(actions.common.devInfoChange(data)))
112
- }
113
-
114
- if (!!props.ldvDevInfo) {
115
- this.initReduxDeviceNativeProps(props.ldvDevInfo)
116
- } else {
117
- this.initReduxGroupNativeProps(props.uaGroupInfo)
118
- this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
119
- }
120
-
121
- if (!!props.colorScheme) {
122
- this.state = {
123
- colorScheme: props.colorScheme || 'light'
124
- }
125
- }
126
- getSystemTimeFormat().then(time => {
127
- dispatch(setSystemTimeFormat(time === 24))
128
- })
129
-
130
- getTimeZone().then(timeZone => {
131
- dispatch(setTimeZone(timeZone))
132
- })
133
- }
134
-
135
- initReduxDeviceNativeProps(ldvDevInfo: LdvDevInfo) {
136
- console.log('原生数据:', JSON.stringify(ldvDevInfo))
137
- NativeApi.log('原生数据: ' + JSON.stringify(ldvDevInfo))
138
- const dps = this.setDpSchemaMap(ldvDevInfo.schema)
139
- const nativeProps: NativeProps = {
140
- deviceInfo: {
141
- devId: ldvDevInfo.devId,
142
- dps: { ...dps, ...JSON.parse(ldvDevInfo.dps) },
143
- pId: ldvDevInfo.pId,
144
- },
145
- uaGroupInfo: {
146
- tyGroupId: -1,
147
- dps: {},
148
- pId: '',
149
- config: {},
150
- groupDevices: []
151
- },
152
- familyName: ldvDevInfo.familyName,
153
- role: ldvDevInfo.role,
154
- moods: [],
155
- is24HourClock: true
156
- }
157
- NativeApi.showObj(nativeProps)
158
- console.log('Redux 初始数据:', JSON.stringify(nativeProps))
159
- NativeApi.log('Redux 初始数据:' + JSON.stringify(nativeProps))
160
- dispatch(setNativeProps(nativeProps))
161
- }
162
-
163
- initReduxGroupNativeProps(uaGroupInfo: UAGroupInfoProps) {
164
- console.log('原生数据:', JSON.stringify(uaGroupInfo))
165
- NativeApi.log('原生数据: ' + JSON.stringify(uaGroupInfo))
166
- const dps = this.setDpSchemaMap(uaGroupInfo.schema)
167
- const nativeProps: NativeProps = {
168
- deviceInfo: {
169
- devId: '',
170
- dps: {},
171
- pId: '',
172
- },
173
- uaGroupInfo: {
174
- tyGroupId: uaGroupInfo.tyGroupId,
175
- dps: { ...dps, ...JSON.parse(uaGroupInfo.dps) },
176
- pId: uaGroupInfo.pId,
177
- config: {
178
- ...JSON.parse(uaGroupInfo.config || '{}'),
179
- },
180
- groupDevices: []
181
- },
182
- familyName: uaGroupInfo.familyName,
183
- role: uaGroupInfo.role,
184
- moods: [],
185
- is24HourClock: true
186
- }
187
- NativeApi.showObj(nativeProps)
188
- console.log('Redux 初始数据:', JSON.stringify(nativeProps))
189
- NativeApi.log('Redux 初始数据:' + JSON.stringify(nativeProps))
190
- dispatch(setGroupNativeProps(nativeProps))
191
- }
192
-
193
- async initGroupDevices(tyGroupId: number){
194
- if(!tyGroupId) return
195
- const res = await NativeApi.getGroupDevices(tyGroupId)
196
- if(res.success && Array.isArray(res.data)){
197
- dispatch(setGroupDevices(res.data))
198
- }
199
- }
200
-
201
- setDpSchemaMap(schema: string): any {
202
- // 处理物模型协议和dps
203
- const dpSchemaMap: Record<string, DpSchema> = {}
204
- const dps = {}
205
- JSON.parse(schema || '[]')
206
- .forEach((schemaItem: any) => {
207
- dpSchemaMap[schemaItem.code] = {
208
- name: schemaItem.name,
209
- dp: schemaItem.id,
210
- type: schemaItem.type,
211
- mode: schemaItem.mode,
212
- property: schemaItem.property,
213
- }
214
- dps[schemaItem.id] = null
215
- })
216
- GlobalParams.dpSchemaMap = dpSchemaMap
217
- return dps
218
- }
219
-
220
- componentDidMount() {
221
- nativeEventEmitter.addListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
222
- }
223
-
224
- componentWillUnmount() {
225
- removeListener()
226
- nativeEventEmitter.removeListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
227
- }
228
-
229
- handleColorSchemeUpdate = (event: { colorScheme: string }) => {
230
- this.updateColorScheme(event.colorScheme)
231
- }
232
-
233
- updateColorScheme(colorScheme: string) {
234
- this.setState({
235
- colorScheme: colorScheme
236
- })
237
- }
238
-
239
- render() {
240
- // const { colorScheme } = this.state
241
- const colorScheme = 'light'
242
- console.log('colorScheme', colorScheme)
243
- return (
244
- <Provider store={store}>
245
- <Theme theme={colorScheme === 'dark' ? darkTheme : lightTheme}>
246
- <Connect mapStateToProps={_.identity}>
247
- {({ mapStateToProps, ...props }: { mapStateToProps: any; [_: string]: any }) => {
248
- return <NavigatorLayout {...props} />
249
- }}
250
- </Connect>
251
- </Theme>
252
- </Provider>
253
- )
254
- }
255
- }
256
-
257
- return PanelComponent
258
- }
259
-
260
-
261
- export default composeLayout
1
+ import _ from 'lodash'
2
+ import React, { Component } from 'react'
3
+ import { Provider } from 'react-redux'
4
+ import { DevInfo, DpValue, Theme, TYSdk } from 'tuya-panel-kit'
5
+ import { actions, store } from './models'
6
+ import {addListener, nativeEventEmitter, removeListener} from 'api/nativeEventEmitter'
7
+ import {getSystemTimeFormat, getTimeZone, NativeApi} from 'api/native'
8
+ import {
9
+ DeviceInfo,
10
+ NativeProps,
11
+ setGroupDevices,
12
+ setGroupNativeProps,
13
+ setNativeProps,
14
+ setSystemTimeFormat,
15
+ setTimeZone,
16
+ UAGroupInfo,
17
+ } from './models/modules/NativePropsSlice'
18
+ import { DpSchema, GlobalParams } from './models/GlobalParams'
19
+ import Connect from './components/connect'
20
+ import darkTheme from "./config/dark-theme";
21
+ import lightTheme from "./config/light-theme";
22
+
23
+ interface Props {
24
+ devInfo: DevInfo
25
+ preload?: boolean
26
+ ldvDevInfo: LdvDevInfo
27
+ uaGroupInfo: UAGroupInfoProps
28
+ colorScheme?: string
29
+ }
30
+
31
+ interface LdvDevInfo extends DeviceInfo {
32
+ schema: any
33
+ familyName: string
34
+ role: 0 | 1 | 2 | 3
35
+ }
36
+
37
+ interface UAGroupInfoProps extends UAGroupInfo {
38
+ schema: any
39
+ familyName: string
40
+ role: 0 | 1 | 2 | 3
41
+ }
42
+
43
+ const TYEvent = TYSdk.event
44
+ const TYDevice = TYSdk.device
45
+
46
+ /**
47
+ *
48
+ * @param {} component - 需要连接到redux store的组件,通常为即为main
49
+ */
50
+ const composeLayout = (component: React.ComponentType) => {
51
+ const NavigatorLayout = component
52
+ const { dispatch } = store
53
+
54
+ addListener(store)
55
+
56
+ /**
57
+ * 此处监听了`设备数据变更`事件,
58
+ * 每当dp点数据变更时,会将变更的dp点状态同步更新到`redux`中去。
59
+ * 同理当设备信息变更时,也会将变更的设备信息值同步更新到`redux`中去。
60
+ */
61
+ TYEvent.on('deviceDataChange', data => {
62
+ switch (data.type) {
63
+ case 'dpData':
64
+ dispatch(actions.common.responseUpdateDp(data.payload as Record<string, DpValue>))
65
+ break
66
+ case 'deviceOnline':
67
+ console.log('设备在线状态', data.payload)
68
+ break
69
+ default:
70
+ dispatch(actions.common.deviceChange(data.payload as DevInfo))
71
+ break
72
+ }
73
+ })
74
+
75
+ /**
76
+ * 此处监听了`网络状态变更事件`事件,
77
+ * 每当设备信息变更时,会将变更的设备信息值同步更新到`redux`中去。
78
+ */
79
+ TYSdk.event.on('networkStateChange', data => {
80
+ dispatch(actions.common.deviceChange(data as any))
81
+ })
82
+
83
+ class PanelComponent extends Component<Props> {
84
+ /**
85
+ * 如果面板进入时,`devInfo`已经存在(通常都会存在的)
86
+ * 这里会调用 setDeviceInfo 将原始的devInfo处理一下,并置入`redux`
87
+ *
88
+ * 如果面板进入时,`devInfo`不存在,
89
+ * 那么会调用 getDeviceInfo 异步获取处理好的`devInfo`,并置入`redux`
90
+ */
91
+ state = {
92
+ colorScheme: 'light'
93
+ }
94
+ constructor(props: Props) {
95
+ super(props)
96
+ if (props && props.devInfo && props.devInfo.devId) {
97
+ TYDevice.setDeviceInfo(props.devInfo)
98
+ TYDevice.getDeviceInfo()
99
+ .then(data => {
100
+ dispatch(actions.common.devInfoChange(data))
101
+ return Promise.all([TYDevice.getDeviceState(), data])
102
+ })
103
+ .then(([dpState, devInfo]) => {
104
+ const isEqual = _.isEqual(dpState, devInfo.state)
105
+ if (isEqual) return
106
+ dispatch(actions.common.responseUpdateDp(dpState))
107
+ })
108
+ } else if (props.preload) {
109
+ // do something
110
+ } else {
111
+ TYDevice.getDeviceInfo().then(data => dispatch(actions.common.devInfoChange(data)))
112
+ }
113
+
114
+ if (!!props.ldvDevInfo) {
115
+ this.initReduxDeviceNativeProps(props.ldvDevInfo)
116
+ } else {
117
+ this.initReduxGroupNativeProps(props.uaGroupInfo)
118
+ this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
119
+ }
120
+
121
+ if (!!props.colorScheme) {
122
+ this.state = {
123
+ colorScheme: props.colorScheme || 'light'
124
+ }
125
+ }
126
+ getSystemTimeFormat().then(time => {
127
+ dispatch(setSystemTimeFormat(time === 24))
128
+ })
129
+
130
+ getTimeZone().then(timeZone => {
131
+ dispatch(setTimeZone(timeZone))
132
+ })
133
+ }
134
+
135
+ initReduxDeviceNativeProps(ldvDevInfo: LdvDevInfo) {
136
+ console.log('原生数据:', JSON.stringify(ldvDevInfo))
137
+ NativeApi.log('原生数据: ' + JSON.stringify(ldvDevInfo))
138
+ const dps = this.setDpSchemaMap(ldvDevInfo.schema)
139
+ const nativeProps: NativeProps = {
140
+ deviceInfo: {
141
+ devId: ldvDevInfo.devId,
142
+ dps: { ...dps, ...JSON.parse(ldvDevInfo.dps) },
143
+ pId: ldvDevInfo.pId,
144
+ },
145
+ uaGroupInfo: {
146
+ tyGroupId: -1,
147
+ dps: {},
148
+ pId: '',
149
+ config: {},
150
+ groupDevices: []
151
+ },
152
+ familyName: ldvDevInfo.familyName,
153
+ role: ldvDevInfo.role,
154
+ moods: [],
155
+ is24HourClock: true
156
+ }
157
+ NativeApi.showObj(nativeProps)
158
+ console.log('Redux 初始数据:', JSON.stringify(nativeProps))
159
+ NativeApi.log('Redux 初始数据:' + JSON.stringify(nativeProps))
160
+ dispatch(setNativeProps(nativeProps))
161
+ }
162
+
163
+ initReduxGroupNativeProps(uaGroupInfo: UAGroupInfoProps) {
164
+ console.log('原生数据:', JSON.stringify(uaGroupInfo))
165
+ NativeApi.log('原生数据: ' + JSON.stringify(uaGroupInfo))
166
+ const dps = this.setDpSchemaMap(uaGroupInfo.schema)
167
+ const nativeProps: NativeProps = {
168
+ deviceInfo: {
169
+ devId: '',
170
+ dps: {},
171
+ pId: '',
172
+ },
173
+ uaGroupInfo: {
174
+ tyGroupId: uaGroupInfo.tyGroupId,
175
+ dps: { ...dps, ...JSON.parse(uaGroupInfo.dps) },
176
+ pId: uaGroupInfo.pId,
177
+ config: {
178
+ ...JSON.parse(uaGroupInfo.config || '{}'),
179
+ },
180
+ groupDevices: []
181
+ },
182
+ familyName: uaGroupInfo.familyName,
183
+ role: uaGroupInfo.role,
184
+ moods: [],
185
+ is24HourClock: true
186
+ }
187
+ NativeApi.showObj(nativeProps)
188
+ console.log('Redux 初始数据:', JSON.stringify(nativeProps))
189
+ NativeApi.log('Redux 初始数据:' + JSON.stringify(nativeProps))
190
+ dispatch(setGroupNativeProps(nativeProps))
191
+ }
192
+
193
+ async initGroupDevices(tyGroupId: number){
194
+ if(!tyGroupId) return
195
+ const res = await NativeApi.getGroupDevices(tyGroupId)
196
+ if(res.success && Array.isArray(res.data)){
197
+ dispatch(setGroupDevices(res.data))
198
+ }
199
+ }
200
+
201
+ setDpSchemaMap(schema: string): any {
202
+ // 处理物模型协议和dps
203
+ const dpSchemaMap: Record<string, DpSchema> = {}
204
+ const dps = {}
205
+ JSON.parse(schema || '[]')
206
+ .forEach((schemaItem: any) => {
207
+ dpSchemaMap[schemaItem.code] = {
208
+ name: schemaItem.name,
209
+ dp: schemaItem.id,
210
+ type: schemaItem.type,
211
+ mode: schemaItem.mode,
212
+ property: schemaItem.property,
213
+ }
214
+ dps[schemaItem.id] = null
215
+ })
216
+ GlobalParams.dpSchemaMap = dpSchemaMap
217
+ return dps
218
+ }
219
+
220
+ componentDidMount() {
221
+ nativeEventEmitter.addListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
222
+ }
223
+
224
+ componentWillUnmount() {
225
+ removeListener()
226
+ nativeEventEmitter.removeListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
227
+ }
228
+
229
+ handleColorSchemeUpdate = (event: { colorScheme: string }) => {
230
+ this.updateColorScheme(event.colorScheme)
231
+ }
232
+
233
+ updateColorScheme(colorScheme: string) {
234
+ this.setState({
235
+ colorScheme: colorScheme
236
+ })
237
+ }
238
+
239
+ render() {
240
+ const { colorScheme } = this.state
241
+ // const colorScheme = 'light'
242
+ console.log('colorScheme', colorScheme)
243
+ return (
244
+ <Provider store={store}>
245
+ <Theme theme={colorScheme === 'dark' ? darkTheme : lightTheme}>
246
+ <Connect mapStateToProps={_.identity}>
247
+ {({ mapStateToProps, ...props }: { mapStateToProps: any; [_: string]: any }) => {
248
+ return <NavigatorLayout {...props} />
249
+ }}
250
+ </Connect>
251
+ </Theme>
252
+ </Provider>
253
+ )
254
+ }
255
+ }
256
+
257
+ return PanelComponent
258
+ }
259
+
260
+
261
+ export default composeLayout
@@ -1,61 +1,61 @@
1
- import {Utils} from "tuya-panel-kit";
2
-
3
- const { convertX: cx } = Utils.RatioUtils
4
-
5
- export default {
6
- type: 'dark',
7
- global: {
8
- brand: '#fff',
9
- secondBrand: '#fff',
10
- thirdBrand: '#FFE0D4',
11
- background: '#000',
12
- fontColor: '#fff',
13
- secondFontColor: '#cccccc',
14
- disabledFontColor: '#555555',
15
- success: '#00C931',
16
- warning: '#ff9500',
17
- error: '#ff0015',
18
- },
19
- card: {
20
- head: '#666',
21
- background: '#2a2a2a',
22
- board: '#f6f6f6',
23
- fontColor: '#ffffff',
24
- shadowColor: '#444444'
25
- },
26
- button: {
27
- active: '#f60',
28
- disabled: '#f60',
29
- fontColor: '#fff'
30
- },
31
- textInput: {
32
- background: '#737373',
33
- fontColor: '#fff',
34
- line: '#fff'
35
- },
36
- tag: {
37
- background: '#737373',
38
- fontColor: '#fff'
39
- },
40
- dialog: {
41
- width: cx(315), // 弹窗容器宽度
42
- bg: "#2a2a2a", // 弹窗背景色
43
- radius: cx(8), // 弹窗容器圆角
44
- cellHeight: 56, // 列表高度(头部、底部)
45
- lineColor: "#e5e5e5", // 分隔线颜色
46
- titleFontSize: 18, // 标题字体大小
47
- titleFontColor: "#fff", // 头部栏标题颜色
48
- subTitleFontSize: 16, // 副标题字体大小
49
- subTitleFontColor: "#cccccc", // 头部栏副标题颜色
50
- cancelFontSize: 16, // 底部栏取消字体大小
51
- cancelFontColor: "#cccccc", // 底部栏取消字体颜色
52
- confirmFontSize: 16, // 底部栏确认字体大小
53
- confirmFontColor: "#f60", // 底部栏确认字体颜色
54
- prompt: {
55
- bg: "#737373", // 输入框背景色
56
- radius: cx(4), // 输入框圆角
57
- padding: "12px 16px", // 输入框边距
58
- placeholder: "#fff", // 占位符字体颜色
59
- },
60
- },
61
- }
1
+ import {Utils} from "tuya-panel-kit";
2
+
3
+ const { convertX: cx } = Utils.RatioUtils
4
+
5
+ export default {
6
+ type: 'dark',
7
+ global: {
8
+ brand: '#fff',
9
+ secondBrand: '#fff',
10
+ thirdBrand: '#FFE0D4',
11
+ background: '#000',
12
+ fontColor: '#fff',
13
+ secondFontColor: '#cccccc',
14
+ disabledFontColor: '#555555',
15
+ success: '#00C931',
16
+ warning: '#ff9500',
17
+ error: '#ff0015',
18
+ },
19
+ card: {
20
+ head: '#666',
21
+ background: '#2a2a2a',
22
+ board: '#f6f6f6',
23
+ fontColor: '#ffffff',
24
+ shadowColor: '#444444'
25
+ },
26
+ button: {
27
+ active: '#f60',
28
+ disabled: '#f60',
29
+ fontColor: '#fff'
30
+ },
31
+ textInput: {
32
+ background: '#737373',
33
+ fontColor: '#fff',
34
+ line: '#fff'
35
+ },
36
+ tag: {
37
+ background: '#737373',
38
+ fontColor: '#fff'
39
+ },
40
+ dialog: {
41
+ width: cx(315), // 弹窗容器宽度
42
+ bg: "#2a2a2a", // 弹窗背景色
43
+ radius: cx(8), // 弹窗容器圆角
44
+ cellHeight: 56, // 列表高度(头部、底部)
45
+ lineColor: "#e5e5e5", // 分隔线颜色
46
+ titleFontSize: 18, // 标题字体大小
47
+ titleFontColor: "#fff", // 头部栏标题颜色
48
+ subTitleFontSize: 16, // 副标题字体大小
49
+ subTitleFontColor: "#cccccc", // 头部栏副标题颜色
50
+ cancelFontSize: 16, // 底部栏取消字体大小
51
+ cancelFontColor: "#cccccc", // 底部栏取消字体颜色
52
+ confirmFontSize: 16, // 底部栏确认字体大小
53
+ confirmFontColor: "#f60", // 底部栏确认字体颜色
54
+ prompt: {
55
+ bg: "#737373", // 输入框背景色
56
+ radius: cx(4), // 输入框圆角
57
+ padding: "12px 16px", // 输入框边距
58
+ placeholder: "#fff", // 占位符字体颜色
59
+ },
60
+ },
61
+ }