@ledvance/base 1.2.22 → 1.2.24

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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.2.22",
7
+ "version": "1.2.24",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -9,6 +9,7 @@ import {
9
9
  import {actions} from '@models'
10
10
 
11
11
  const nativeModule = NativeModules.LDVDeviceEventEmitter
12
+
12
13
  export const nativeEventEmitter = new NativeEventEmitter(nativeModule)
13
14
 
14
15
  let deviceDPListener: EmitterSubscription | null
@@ -4,6 +4,7 @@ interface DeleteButtonProps {
4
4
  onPress: () => void;
5
5
  style?: StyleProp<ViewStyle>;
6
6
  textStyle?: StyleProp<TextStyle>;
7
+ disabled?: boolean;
7
8
  }
8
9
  declare const DeleteButton: (props: DeleteButtonProps) => JSX.Element;
9
10
  export default DeleteButton;
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
- import {StyleProp, Text, TextStyle, TouchableOpacity, ViewStyle} from 'react-native'
3
- import {Utils} from 'tuya-panel-kit'
2
+ import { StyleProp, Text, TextStyle, TouchableOpacity, ViewStyle } from 'react-native'
3
+ import { Utils } from 'tuya-panel-kit'
4
4
 
5
5
  const cx = Utils.RatioUtils.convertX
6
6
 
@@ -9,12 +9,14 @@ interface DeleteButtonProps {
9
9
  onPress: () => void,
10
10
  style?: StyleProp<ViewStyle>,
11
11
  textStyle?: StyleProp<TextStyle>
12
+ disabled?: boolean
12
13
  }
13
14
 
14
15
  const DeleteButton = (props: DeleteButtonProps) => {
15
- const {text, onPress, style, textStyle} = props
16
+ const { text, onPress, style, textStyle, disabled } = props
16
17
  return (
17
18
  <TouchableOpacity
19
+ disabled={disabled}
18
20
  onPress={onPress}
19
21
  style={[{
20
22
  width: '100%',
@@ -42,7 +42,7 @@ const colors = [
42
42
  color: '#fff100',
43
43
  },
44
44
  {
45
- color: '#00FF40',
45
+ color: '#00FF00',
46
46
  },
47
47
  {
48
48
  color: '#0025ff',
@@ -8,6 +8,7 @@ import { NativeApi } from 'api/native'
8
8
  import {
9
9
  DeviceInfo,
10
10
  NativeProps,
11
+ setGroupDevices,
11
12
  setGroupNativeProps,
12
13
  setNativeProps,
13
14
  UAGroupInfo,
@@ -114,6 +115,7 @@ const composeLayout = (component: React.ComponentType) => {
114
115
  this.initReduxDeviceNativeProps(props.ldvDevInfo)
115
116
  } else {
116
117
  this.initReduxGroupNativeProps(props.uaGroupInfo)
118
+ this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
117
119
  }
118
120
  }
119
121
 
@@ -132,9 +134,11 @@ const composeLayout = (component: React.ComponentType) => {
132
134
  dps: {},
133
135
  pId: '',
134
136
  config: {},
137
+ groupDevices: []
135
138
  },
136
139
  familyName: ldvDevInfo.familyName,
137
140
  role: ldvDevInfo.role,
141
+ moods: []
138
142
  }
139
143
  NativeApi.showObj(nativeProps)
140
144
  console.log('Redux 初始数据:', JSON.stringify(nativeProps))
@@ -159,9 +163,11 @@ const composeLayout = (component: React.ComponentType) => {
159
163
  config: {
160
164
  ...JSON.parse(uaGroupInfo.config || '{}'),
161
165
  },
166
+ groupDevices: []
162
167
  },
163
168
  familyName: uaGroupInfo.familyName,
164
169
  role: uaGroupInfo.role,
170
+ moods: []
165
171
  }
166
172
  NativeApi.showObj(nativeProps)
167
173
  console.log('Redux 初始数据:', JSON.stringify(nativeProps))
@@ -169,6 +175,14 @@ const composeLayout = (component: React.ComponentType) => {
169
175
  dispatch(setGroupNativeProps(nativeProps))
170
176
  }
171
177
 
178
+ async initGroupDevices(tyGroupId: number){
179
+ if(!tyGroupId) return
180
+ const res = await NativeApi.getGroupDevices(tyGroupId)
181
+ if(res.success && Array.isArray(res.data)){
182
+ dispatch(setGroupDevices(res.data))
183
+ }
184
+ }
185
+
172
186
  setDpSchemaMap(schema: string): any {
173
187
  // 处理物模型协议和dps
174
188
  const dpSchemaMap: Record<string, DpSchema> = {}
@@ -17,7 +17,6 @@ export interface NativeProps {
17
17
  timeSchedule?: boolean
18
18
  energieverbrauch?: object
19
19
  moods: any[]
20
- groupDevices: any[]
21
20
  }
22
21
 
23
22
  export interface DeviceInfo {
@@ -31,6 +30,7 @@ export interface UAGroupInfo {
31
30
  pId: string
32
31
  dps: any
33
32
  config: any
33
+ groupDevices: DeviceInfo[]
34
34
  }
35
35
 
36
36
  const initialState: NativeProps = {
@@ -46,11 +46,11 @@ const initialState: NativeProps = {
46
46
  pId: '',
47
47
  dps: {},
48
48
  config: {},
49
+ groupDevices: []
49
50
  },
50
51
  timeSchedule: false,
51
52
  energieverbrauch: {},
52
53
  moods: [],
53
- groupDevices: [],
54
54
  }
55
55
 
56
56
  // energy generation
@@ -84,6 +84,9 @@ const nativePropsSlice = createSlice({
84
84
  if (!!action.payload.familyName) {
85
85
  state.familyName = action.payload.familyName
86
86
  }
87
+ if (isNumber(action.payload.role)) {
88
+ state.role = action.payload.role
89
+ }
87
90
  if (!!action.payload.uaGroupInfo.pId) {
88
91
  state.uaGroupInfo.pId = action.payload.uaGroupInfo.pId
89
92
  }
@@ -109,7 +112,7 @@ const nativePropsSlice = createSlice({
109
112
  state.moods = action.payload
110
113
  },
111
114
  setGroupDevices(state, action: PayloadAction<any>) {
112
- state.groupDevices = action.payload
115
+ state.uaGroupInfo.groupDevices = action.payload
113
116
  },
114
117
  },
115
118
  })
@@ -222,7 +225,7 @@ const useMoods = (): [any[], (v: any[]) => void] => {
222
225
  }
223
226
 
224
227
  const useGroupDevices = (): [any[], (v: any[]) => void] => {
225
- const dps = useSelector(store => store.ldvModules.groupDevices)
228
+ const dps = useSelector(store => store.ldvModules.uaGroupInfo.groupDevices)
226
229
  const dispatch = useDispatch()
227
230
  const setGroupDevicesFn = (value: any[]) => {
228
231
  dispatch(setGroupDevices(value))
@@ -311,7 +314,7 @@ export function useFeatureHook<GC, T extends PropertyValueTypes<GC>>(
311
314
  const extraConfig = getExtraConfig ? getExtraConfig(value) : undefined
312
315
  return await setFH(value, dpValue, extraDps, extraConfig)
313
316
  }, [setFH])
314
- return [featureHook || defValue, setFeatureHook]
317
+ return [featureHook ?? defValue, setFeatureHook]
315
318
  }
316
319
 
317
320
  export const useFanMaxSpeed = () => {
@@ -1,51 +0,0 @@
1
- @ColumnInfo(name = "device_id")
2
- val deviceId: String,
3
- @ColumnInfo(name = "device_name")
4
- val deviceName: String,
5
- @ColumnInfo(name = "cat_id")
6
- val catId: String,
7
- @ColumnInfo(name = "channel_no")
8
- val channelNo: Int,
9
- @ColumnInfo(name = "device_category")
10
- val deviceCategory: String,
11
- @ColumnInfo(name = "device_image")
12
- val deviceImage: String,
13
- @ColumnInfo(name = "tuya_device_id")
14
- val tuyaDeviceId: String,
15
- // deviceType 对应 ProductInfo 的 productId
16
- @ColumnInfo(name = "device_type")
17
- val deviceType: String,
18
- @ColumnInfo(name = "offline_time")
19
- val offlineTime: String,
20
- @ColumnInfo(name = "rn_package")
21
- val rnPackage: String?,
22
- @ColumnInfo(name = "status")
23
- val status: Int,
24
- @ColumnInfo(name = "create_time")
25
- val createTime: String,
26
- @ColumnInfo(name = "version")
27
- val version: String,
28
- @ColumnInfo(name = "user_id")
29
- val userId: String,
30
- @ColumnInfo(name = "family_id")
31
- val familyId: Long,
32
- @ColumnInfo(name = "room_id")
33
- val roomId: Long,
34
- @ColumnInfo(name = "room_name")
35
- val roomName: String,
36
- @ColumnInfo(name = "is_shared")
37
- val isShared: Int,
38
- @ColumnInfo(name = "local_index")
39
- val localIndex: String,
40
- @ColumnInfo(name = "resource_category")
41
- val resourceCategory: String,
42
- @ColumnInfo(name = "resource_id")
43
- val resourceId: String,
44
- @ColumnInfo(name = "resource_identifier")
45
- val resourceIdentifier: String,
46
- @ColumnInfo(name = "resource_type")
47
- val resourceType: Int,
48
- @ColumnInfo(name = "index")
49
- val index: Int = 0,
50
- @ColumnInfo(name = "switch_state")
51
- val switchState: Boolean = true