@ledvance/base 1.3.72 → 1.3.73
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/localazy.json +3 -1
- package/package.json +1 -1
- package/src/components/rect-color-and-bright-picker/Slider.tsx +4 -2
- package/src/hooks/Hooks.ts +46 -0
- package/src/i18n/strings.ts +1141 -1085
- package/translateKey.txt +2 -0
package/localazy.json
CHANGED
|
@@ -1198,7 +1198,9 @@
|
|
|
1198
1198
|
"MATCH:body_create_your_own_routine",
|
|
1199
1199
|
"MATCH:setting_cur_passwd",
|
|
1200
1200
|
"MATCH:setting_set_passwd",
|
|
1201
|
-
"MATCH:camera_user"
|
|
1201
|
+
"MATCH:camera_user",
|
|
1202
|
+
"MATCH:camera_motiondetection",
|
|
1203
|
+
"MATCH:camera_motiondetectiondescription"
|
|
1202
1204
|
],
|
|
1203
1205
|
"replacements": {
|
|
1204
1206
|
"REGEX:% %1\\$s.*?\\)%": "{0}",
|
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
} from 'react-native';
|
|
16
16
|
import { IconFont, TYText } from 'tuya-panel-kit';
|
|
17
17
|
import icons from './brightness-icons';
|
|
18
|
+
import {Utils} from 'tuya-panel-kit'
|
|
19
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
18
20
|
|
|
19
21
|
interface IPercentProps {
|
|
20
22
|
percent: number;
|
|
@@ -498,7 +500,7 @@ export default class Slider extends React.Component<IProps, IState> {
|
|
|
498
500
|
render() {
|
|
499
501
|
const { trackColor, activeColor, fontColor, style, iconSize, percentStyle } = this.props;
|
|
500
502
|
const containerStyle = [styles.container, style];
|
|
501
|
-
const { height = 45 } = StyleSheet.flatten(containerStyle);
|
|
503
|
+
const { height = cx(45) } = StyleSheet.flatten(containerStyle);
|
|
502
504
|
return (
|
|
503
505
|
<View
|
|
504
506
|
style={containerStyle}
|
|
@@ -556,7 +558,7 @@ const styles = StyleSheet.create({
|
|
|
556
558
|
container: {
|
|
557
559
|
alignItems: 'center',
|
|
558
560
|
flexDirection: 'row',
|
|
559
|
-
height: 45,
|
|
561
|
+
height: cx(45),
|
|
560
562
|
justifyContent: 'center',
|
|
561
563
|
width: '100%',
|
|
562
564
|
},
|
package/src/hooks/Hooks.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRoute, useNavigation } from '@react-navigation/core'
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
2
3
|
|
|
3
4
|
export function createParams<T>(params: T): T {
|
|
4
5
|
return { ...params }
|
|
@@ -13,3 +14,48 @@ export function useCurrentPage(routeName: string): boolean {
|
|
|
13
14
|
const { index, routes} = navigation.getState()
|
|
14
15
|
return routeName === routes[index].name
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* dp 响应时间校验 hook
|
|
20
|
+
* 用于在指定时间内阻止长连接响应更新界面状态
|
|
21
|
+
*/
|
|
22
|
+
export function useDpResponseValidator(timeoutMs: number = 1000) {
|
|
23
|
+
const dpTimestamps = useRef<{[dpKey: string]: number}>({});
|
|
24
|
+
|
|
25
|
+
// dp 响应时间校验函数
|
|
26
|
+
const sendDpWithTimestamps = useCallback((dpKey: string, sendFunc: () => Promise<any>) => {
|
|
27
|
+
// 记录发送时间戳
|
|
28
|
+
const timestamp = Date.now();
|
|
29
|
+
dpTimestamps.current[dpKey] = timestamp;
|
|
30
|
+
|
|
31
|
+
// 发送命令
|
|
32
|
+
return sendFunc();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
// 监听 dp 响应,比较时间戳
|
|
36
|
+
const onDpResponse = useCallback((dpKey: string) => {
|
|
37
|
+
const sendTimestamp = dpTimestamps.current[dpKey];
|
|
38
|
+
if (sendTimestamp) {
|
|
39
|
+
const responseTimestamp = Date.now();
|
|
40
|
+
const timeDiff = responseTimestamp - sendTimestamp;
|
|
41
|
+
|
|
42
|
+
if (timeDiff <= timeoutMs) {
|
|
43
|
+
// 指定时间内收到响应,不接收更新
|
|
44
|
+
return true; // 阻止更新
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false; // 允许更新
|
|
48
|
+
}, [timeoutMs]);
|
|
49
|
+
|
|
50
|
+
// 组件卸载时清理所有记录
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
return () => {
|
|
53
|
+
dpTimestamps.current = {};
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
sendDpWithTimestamps,
|
|
59
|
+
onDpResponse,
|
|
60
|
+
};
|
|
61
|
+
}
|