@ledvance/base 1.2.12 → 1.2.14

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.12",
7
+ "version": "1.2.14",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -1,7 +1,7 @@
1
1
  import { DeviceInfo } from '../api/native';
2
2
  export interface ApplyForDeviceListProps {
3
3
  devices: DeviceInfo[];
4
- expand: boolean;
5
- onExpandChange: (expand: boolean) => void;
4
+ expand?: boolean;
5
+ onExpandChange?: (expand: boolean) => void;
6
6
  }
7
7
  export default function ApplyForDeviceList(props: ApplyForDeviceListProps): JSX.Element;
@@ -5,22 +5,37 @@ import { FlatList, StyleSheet, View } from 'react-native'
5
5
  import Spacer from './Spacer'
6
6
  import ApplyForDeviceItem from './ApplyForDeviceItem'
7
7
  import { Utils } from 'tuya-panel-kit'
8
+ import { useReactive, useUpdateEffect } from 'ahooks'
8
9
 
9
10
  const cx = Utils.RatioUtils.convertX
10
11
 
11
12
  export interface ApplyForDeviceListProps {
12
13
  devices: DeviceInfo[]
13
- expand: boolean
14
- onExpandChange: (expand: boolean) => void
14
+ expand?: boolean
15
+ onExpandChange?: (expand: boolean) => void
15
16
  }
16
17
 
17
18
  export default function ApplyForDeviceList(props: ApplyForDeviceListProps) {
19
+ const state = useReactive({
20
+ expand: props.expand || false
21
+ })
22
+
23
+ useUpdateEffect(() =>{
24
+ state.expand = props.expand || false
25
+ }, [props.expand])
26
+
18
27
  return <View>
19
28
  <ApplyForText
20
- expand={props.expand}
21
- onExpandChange={props.onExpandChange}/>
29
+ expand={state.expand}
30
+ onExpandChange={(expand) =>{
31
+ if(props.onExpandChange){
32
+ props.onExpandChange(expand)
33
+ }else{
34
+ state.expand = expand
35
+ }
36
+ }}/>
22
37
  <Spacer height={cx(2)}/>
23
- {props.expand &&
38
+ {state.expand &&
24
39
  <FlatList
25
40
  style={styles.deviceList}
26
41
  data={props.devices}
@@ -18,7 +18,7 @@ const temperatures = [
18
18
  value: 40,
19
19
  },
20
20
  {
21
- color: 'rgb(0, 255, 64)',
21
+ color: 'rgb(246, 247, 244)',
22
22
  value: 60,
23
23
  },
24
24
  {
@@ -0,0 +1,2 @@
1
+ export declare function createParams<T>(params: T): T;
2
+ export declare function useParams<T extends any>(): T;
@@ -0,0 +1,9 @@
1
+ import { useRoute } from '@react-navigation/core'
2
+
3
+ export function createParams<T>(params: T): T {
4
+ return { ...params }
5
+ }
6
+
7
+ export function useParams<T extends any>(): T {
8
+ return useRoute().params as T
9
+ }