@ledvance/base 1.2.20 → 1.2.21

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.20",
7
+ "version": "1.2.21",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -0,0 +1,88 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { View, Image, StyleSheet, Text, TouchableOpacity, ViewProps } from "react-native";
3
+ import Card from "@ledvance/base/src/components/Card";
4
+ import Spacer from "@ledvance/base/src/components/Spacer";
5
+ import { Dialog, SwitchButton, Utils } from "tuya-panel-kit";
6
+ import I18n from "@ledvance/base/src/i18n";
7
+
8
+ const cx = Utils.RatioUtils.convertX
9
+
10
+ interface SocketItemProps extends PropsWithChildren<ViewProps>{
11
+ title: string
12
+ name: string
13
+ icon: any
14
+ disabledEdit?: boolean
15
+ onNameChange: (value: string) => void
16
+ enabled: boolean
17
+ onSwitchChange: (value: boolean) => void
18
+ }
19
+
20
+ function SocketItem(props: SocketItemProps) {
21
+ return (
22
+ <Card style={{ marginHorizontal: cx(24) }}>
23
+ <View>
24
+ <Spacer />
25
+ <View style={styles.switchLine}>
26
+ <Text style={styles.title}>{props.title}</Text>
27
+ <Spacer height={0} width={cx(12)} />
28
+ <Image style={styles.icon} source={props.icon} />
29
+ <Spacer style={{ flex: 1 }} />
30
+ <SwitchButton
31
+ value={props.enabled}
32
+ onValueChange={props.onSwitchChange} />
33
+ </View>
34
+ <TouchableOpacity
35
+ style={styles.nameLine}
36
+ onPress={() => {
37
+ if(props.disabledEdit) return
38
+ Dialog.prompt({
39
+ title: I18n.getLang('routines_add_edit_name'),
40
+ value: props.name,
41
+ cancelText: I18n.getLang('auto_scan_system_cancel'),
42
+ confirmText: I18n.getLang('auto_scan_system_wifi_confirm'),
43
+ onChangeText: text => {
44
+ return text.length <= 32 ? text : text.slice(0, 32)
45
+ },
46
+ onConfirm: (text, { close }) => {
47
+ props.onNameChange(text)
48
+ close()
49
+ },
50
+ })
51
+ }}>
52
+ <Text style={styles.name}>{props.name}</Text>
53
+ </TouchableOpacity>
54
+ <Spacer height={cx(16)} />
55
+ {props.children}
56
+ </View>
57
+ </Card>
58
+ )
59
+ }
60
+
61
+ const styles = StyleSheet.create({
62
+ switchLine: {
63
+ flexDirection: 'row',
64
+ alignItems: 'center',
65
+ marginHorizontal: cx(16),
66
+ },
67
+ title: {
68
+ fontSize: cx(16),
69
+ color: '#000',
70
+ fontFamily: 'helvetica_neue_lt_std_bd',
71
+ fontWeight: 'bold',
72
+ },
73
+ icon: {
74
+ width: cx(60),
75
+ height: cx(20),
76
+ },
77
+ nameLine: {
78
+ flex: 1,
79
+ marginHorizontal: cx(16),
80
+ },
81
+ name: {
82
+ fontSize: cx(14),
83
+ color: '#000',
84
+ fontFamily: 'helvetica_neue_lt_std_roman',
85
+ },
86
+ })
87
+
88
+ export default SocketItem