@eohjsc/react-native-smart-city 0.3.53 → 0.3.55

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 (64) hide show
  1. package/package.json +2 -1
  2. package/src/Images/Common/loading-circle.json +1 -0
  3. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  4. package/src/commons/ActionGroup/index.js +6 -2
  5. package/src/commons/ButtonPopup/index.js +2 -0
  6. package/src/commons/DevMode/EmptyComponent.js +2 -2
  7. package/src/commons/DevMode/Item.js +2 -4
  8. package/src/commons/DevMode/Styles/ItemStyles.js +6 -0
  9. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +9 -6
  10. package/src/commons/FullLoading/__test__/index.test.js +43 -0
  11. package/src/commons/FullLoading/index.js +13 -3
  12. package/src/commons/Header/HeaderCustom.js +6 -1
  13. package/src/commons/Header/Styles/HeaderCustomStyles.js +4 -1
  14. package/src/commons/Processing/index.js +20 -18
  15. package/src/commons/Processing/styles.js +4 -3
  16. package/src/commons/StatusBox/index.js +23 -5
  17. package/src/commons/StatusBox/styles.js +7 -6
  18. package/src/configs/API.js +1 -1
  19. package/src/configs/AccessibilityLabel.js +1 -1
  20. package/src/configs/Colors.js +2 -0
  21. package/src/hooks/IoT/__test__/useRemoteControl.test.js +22 -21
  22. package/src/hooks/IoT/useRemoteControl.js +8 -7
  23. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  24. package/src/navigations/Main.js +3 -1
  25. package/src/screens/AddNewGateway/ConnectingModbusDevice.js +16 -19
  26. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +139 -75
  27. package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +8 -7
  28. package/src/screens/AddNewGateway/RenameNewDevices.js +147 -70
  29. package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +35 -16
  30. package/src/screens/AddNewGateway/ShareWifiPassword.js +176 -107
  31. package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +14 -1
  32. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +53 -7
  33. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +44 -10
  34. package/src/screens/AddNewGateway/hooks/__Tests__/useStateAlertRename.test.js +57 -0
  35. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +22 -0
  36. package/src/screens/AddNewGateway/hooks/useWifiManage.js +29 -0
  37. package/src/screens/Device/__test__/detail.test.js +7 -1
  38. package/src/screens/Device/components/SensorDisplayItem.js +10 -2
  39. package/src/screens/Gateway/GatewayInfo/__test__/index.test.js +1 -1
  40. package/src/screens/Gateway/__test__/index.test.js +1 -1
  41. package/src/screens/Gateway/components/GatewayItem/index.js +1 -1
  42. package/src/screens/Gateway/components/GatewayItem/styles.js +4 -0
  43. package/src/screens/Gateway/components/Information/__test__/index.test.js +1 -1
  44. package/src/screens/Gateway/components/Information/index.js +5 -3
  45. package/src/screens/Gateway/components/Information/styles.js +3 -0
  46. package/src/screens/Gateway/components/TabPaneCT/index.js +31 -27
  47. package/src/screens/Gateway/components/TabPaneCT/styles.js +7 -1
  48. package/src/screens/Gateway/index.js +10 -10
  49. package/src/screens/Gateway/styles.js +3 -1
  50. package/src/screens/Notification/__test__/Notification.test.js +9 -1
  51. package/src/screens/Notification/index.js +7 -4
  52. package/src/screens/Smart/__test__/index.test.js +16 -4
  53. package/src/screens/Smart/index.js +15 -1
  54. package/src/screens/Smart/styles.js +15 -0
  55. package/src/screens/Template/EditTemplate.js +1 -1
  56. package/src/screens/Template/Styles/indexStyles.js +1 -1
  57. package/src/screens/Template/detail.js +26 -2
  58. package/src/screens/Template/index.js +1 -1
  59. package/src/screens/Unit/MoreMenu.js +56 -58
  60. package/src/screens/Unit/__test__/MoreMenu.test.js +59 -0
  61. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +6 -3
  62. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +7 -1
  63. package/src/utils/I18n/translations/en.json +10 -8
  64. package/src/utils/I18n/translations/vi.json +10 -7
@@ -1,4 +1,3 @@
1
- import { Platform } from 'react-native';
2
1
  import { Dimensions, StyleSheet } from 'react-native';
3
2
  import { getBottomSpace } from 'react-native-iphone-x-helper';
4
3
  import { Colors } from '../../configs';
@@ -58,11 +57,13 @@ export default StyleSheet.create({
58
57
  lineHeight: 24,
59
58
  },
60
59
  bottomButtonView: {
61
- marginBottom:
62
- getBottomSpace() +
63
- Platform.select({
64
- android: 10,
65
- ios: -10,
66
- }),
60
+ marginBottom: getBottomSpace(),
61
+ },
62
+ loading: {
63
+ width: 40,
64
+ height: 40,
65
+ },
66
+ backgroundLoading: {
67
+ backgroundColor: Colors.Gray21,
67
68
  },
68
69
  });
@@ -22,9 +22,33 @@ const RenameNewDevices = memo(({ route }) => {
22
22
 
23
23
  const { unitId, subUnit, chipId, sensorId, addDeviceType } =
24
24
  route?.params || {};
25
-
25
+ const [selectedItem, setSelectedItem] = useState({});
26
+ const [isCanRename, setIsCanRename] = useState(false);
26
27
  const [info, setInfo] = useState({});
27
28
 
29
+ const renameLabel = AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE;
30
+
31
+ const scrollViewHeight = useMemo(() => {
32
+ const baseHeight = 40;
33
+ let contentItems = 0;
34
+
35
+ if (addDeviceType !== 'gateway') {
36
+ info?.sensors?.map(
37
+ (sensor) => (contentItems += sensor?.end_devices?.length)
38
+ );
39
+ if (contentItems === 1) {
40
+ return 90;
41
+ }
42
+ if (contentItems === 2) {
43
+ return 180;
44
+ }
45
+ if (contentItems > 2) {
46
+ return 270;
47
+ }
48
+ }
49
+ return baseHeight + contentItems * 25;
50
+ }, [addDeviceType, info.sensors]);
51
+
28
52
  const onPressDone = useCallback(async () => {
29
53
  await axiosPost(API.CHIP.RENAME_DEVICES(info.id), info);
30
54
  const resetAction = CommonActions.reset({
@@ -92,19 +116,114 @@ const RenameNewDevices = memo(({ route }) => {
92
116
  });
93
117
  };
94
118
 
95
- const scrollviewHeight = useMemo(() => {
96
- const baseHeight = 40;
97
- let contentItems = 1;
119
+ const ItemDevice = useCallback(
120
+ ({
121
+ item,
122
+ onPress,
123
+ isFocus = false,
124
+ isGateway = false,
125
+ accessibilityLabelTextInput,
126
+ onChange,
127
+ onSubmitEditing,
128
+ }) => {
129
+ const isCanRenameItem = isGateway
130
+ ? item?.can_rename && isCanRename
131
+ : isFocus;
132
+ return (
133
+ <TouchableOpacity
134
+ style={[styles.boxDevice, isGateway && styles.marginTop16]}
135
+ accessibilityLabel={`${renameLabel}-button-${item?.id}`}
136
+ onPress={onPress}
137
+ >
138
+ {isGateway ? (
139
+ <GatewayIcon width={43} height={43} />
140
+ ) : (
141
+ <IconComponent icon={item?.icon} iconKit={item?.icon_kit} />
142
+ )}
143
+ <View style={styles.viewTextInput}>
144
+ {isCanRenameItem ? (
145
+ <_TextInput
146
+ wrapStyle={styles.marginTop0}
147
+ autoFocus={isCanRenameItem}
148
+ accessibilityLabel={accessibilityLabelTextInput}
149
+ value={item?.name}
150
+ textInputStyle={[styles.textItem, styles.textInputRename]}
151
+ onChange={onChange}
152
+ onSubmitEditing={onSubmitEditing}
153
+ />
154
+ ) : (
155
+ <Text
156
+ type="H4"
157
+ color={Colors.Gray9}
158
+ style={styles.textStation}
159
+ accessibilityLabel={`${renameLabel}-chip-name`}
160
+ numberOfLines={1}
161
+ >
162
+ {item?.name}
163
+ </Text>
164
+ )}
165
+ </View>
166
+ </TouchableOpacity>
167
+ );
168
+ },
169
+ [isCanRename, renameLabel]
170
+ );
171
+ const handleOnPressGatewayItem = useCallback(() => {
172
+ setIsCanRename(!isCanRename);
173
+ }, [isCanRename]);
98
174
 
99
- if (addDeviceType !== 'gateway') {
100
- info?.sensors?.map(
101
- (sensor) => (contentItems += sensor?.end_devices?.length)
175
+ const handleOnPressDeviceItem = useCallback(
176
+ (item) => () => {
177
+ setSelectedItem(item);
178
+ },
179
+ []
180
+ );
181
+
182
+ const renderListItem = useMemo(() => {
183
+ if (addDeviceType === 'gateway') {
184
+ return (
185
+ <ItemDevice
186
+ item={info}
187
+ onPress={handleOnPressGatewayItem}
188
+ onSubmitEditing={handleOnPressGatewayItem}
189
+ isGateway
190
+ accessibilityLabelTextInput={`${renameLabel}-chip`}
191
+ onChange={updateItemName('chip')}
192
+ />
102
193
  );
103
194
  }
104
- return baseHeight + contentItems * 43;
105
- }, [addDeviceType, info.sensors]);
106
-
107
- const renameLabel = AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE;
195
+ return (
196
+ <View style={[styles.devicesWrapper, { height: scrollViewHeight }]}>
197
+ <ScrollView>
198
+ {(info?.sensors || []).map((sensor, sensor_index) =>
199
+ (sensor?.end_devices || []).map((end_device, end_device_index) => (
200
+ <ItemDevice
201
+ onSubmitEditing={handleOnPressDeviceItem(end_device?.id)}
202
+ key={`${end_device?.id}`}
203
+ item={end_device}
204
+ onPress={handleOnPressDeviceItem(end_device)}
205
+ isFocus={end_device?.id === selectedItem?.id}
206
+ accessibilityLabelTextInput={`${renameLabel}-end_device-${end_device?.id}`}
207
+ onChange={updateItemName(
208
+ 'end_device',
209
+ sensor_index,
210
+ end_device_index
211
+ )}
212
+ />
213
+ ))
214
+ )}
215
+ </ScrollView>
216
+ </View>
217
+ );
218
+ }, [
219
+ addDeviceType,
220
+ scrollViewHeight,
221
+ info,
222
+ handleOnPressGatewayItem,
223
+ renameLabel,
224
+ handleOnPressDeviceItem,
225
+ selectedItem,
226
+ ]);
108
227
 
109
228
  return (
110
229
  <View style={styles.container}>
@@ -114,66 +233,24 @@ const RenameNewDevices = memo(({ route }) => {
114
233
  isCanBack={false}
115
234
  />
116
235
  <View style={styles.content}>
117
- <IconOutline name="check-circle" size={28} color={Colors.Green6} />
118
- <Text semibold color={Colors.Black} size={20} style={styles.textStatus}>
119
- {t('successfully_connected')}
120
- </Text>
121
- <Text size={14} color={Colors.Gray9} style={styles.textStation}>
122
- {subUnit?.name}
123
- </Text>
124
- <View style={{ ...styles.devicesWrapper, height: scrollviewHeight }}>
125
- <ScrollView>
126
- {addDeviceType === 'gateway' ? (
127
- <View style={styles.boxDevice}>
128
- <GatewayIcon width={43} height={43} />
129
- {info.can_rename ? (
130
- <_TextInput
131
- accessibilityLabel={`${renameLabel}-chip`}
132
- value={info.name}
133
- textInputStyle={styles.textItem}
134
- onChange={updateItemName('chip')}
135
- />
136
- ) : (
137
- <Text
138
- size={14}
139
- color={Colors.Gray9}
140
- style={styles.textStation}
141
- accessibilityLabel={`${renameLabel}-chip-name`}
142
- >
143
- {info.name}
144
- </Text>
145
- )}
146
- </View>
147
- ) : (
148
- !!info?.sensors?.length &&
149
- info.sensors.map((sensor, sensor_index) =>
150
- (sensor?.end_devices || []).map(
151
- (end_device, end_device_index) => (
152
- <View style={styles.boxDevice} key={`${end_device?.id}`}>
153
- <IconComponent
154
- icon={end_device?.icon}
155
- iconKit={end_device?.icon_kit}
156
- />
157
- <_TextInput
158
- accessibilityLabel={`${renameLabel}-end_device-${end_device?.id}`}
159
- value={end_device?.name}
160
- textInputStyle={styles.textItem}
161
- onChange={updateItemName(
162
- 'end_device',
163
- sensor_index,
164
- end_device_index
165
- )}
166
- />
167
- </View>
168
- )
169
- )
170
- )
171
- )}
172
- </ScrollView>
236
+ <View style={styles.viewIconSuccess}>
237
+ <IconOutline name="check-circle" size={28} color={Colors.Green6} />
238
+ <Text
239
+ semibold
240
+ color={Colors.Black}
241
+ size={20}
242
+ style={styles.textStatus}
243
+ >
244
+ {t('successfully_connected')}
245
+ </Text>
246
+ <Text size={14} color={Colors.Gray9}>
247
+ {subUnit?.name}
248
+ </Text>
249
+ {renderListItem}
250
+ <Text size={16} color={Colors.Gray8} style={styles.textRename}>
251
+ {t('click_on_box_to_rename_device')}
252
+ </Text>
173
253
  </View>
174
- <Text size={16} color={Colors.Gray8} style={styles.textRename}>
175
- {t('click_on_box_to_rename_device')}
176
- </Text>
177
254
  </View>
178
255
  <TouchableOpacity
179
256
  style={styles.btnDone}
@@ -9,31 +9,36 @@ const styles = StyleSheet.create({
9
9
  alignItems: 'center',
10
10
  },
11
11
  boxDevice: {
12
- width: 250,
12
+ width: 275,
13
13
  flexDirection: 'row',
14
+ alignItems: 'center',
14
15
  paddingLeft: 16,
15
16
  borderWidth: 1,
16
17
  borderRadius: 10,
17
18
  borderColor: Colors.Gray4,
18
19
  backgroundColor: Colors.White,
19
- alignItems: 'center',
20
20
  marginBottom: 16,
21
+ padding: 16,
21
22
  },
22
23
  device: {
23
24
  flexDirection: 'row',
24
25
  alignItems: 'center',
25
26
  },
27
+ viewTextInput: {
28
+ flex: 1,
29
+ },
26
30
  textItem: {
27
31
  borderWidth: 0,
28
- textAlign: 'center',
29
- marginTop: -20,
30
32
  fontSize: 16,
31
33
  lineHeight: 24,
32
- maxWidth: 170,
34
+ textAlign: 'left',
35
+ paddingTop: 0,
36
+ marginTop: 0,
37
+ paddingBottom: 8,
33
38
  },
34
39
  content: {
35
40
  flex: 1,
36
- justifyContent: 'center',
41
+ justifyContent: 'space-between',
37
42
  alignItems: 'center',
38
43
  marginBottom: 24,
39
44
  },
@@ -48,23 +53,37 @@ const styles = StyleSheet.create({
48
53
  marginBottom: 16,
49
54
  },
50
55
  textStation: {
51
- lineHeight: 22,
52
- marginBottom: 8,
53
- },
54
- textDeviceName: {
55
- marginLeft: 8,
56
+ textAlign: 'left',
57
+ paddingLeft: 16,
56
58
  },
57
59
  textRename: {
58
60
  marginTop: 16,
59
61
  },
60
- textInput: {
62
+ devicesWrapper: {
63
+ marginTop: 16,
64
+ paddingHorizontal: 16,
65
+ },
66
+ textInputRename: {
67
+ paddingRight: 0,
68
+ },
69
+ marginTop0: {
61
70
  marginTop: 0,
62
71
  },
63
- wrapRename: {
64
- marginHorizontal: 16,
72
+ viewIconSuccess: {
73
+ flex: 1,
74
+ alignItems: 'center',
75
+ justifyContent: 'center',
76
+ paddingTop: 32,
65
77
  },
66
- devicesWrapper: {
67
- paddingHorizontal: 16,
78
+ marginTop16: {
79
+ marginTop: 16,
80
+ },
81
+ flex1: {
82
+ flex: 1,
83
+ },
84
+ contentContainerScrollView: {
85
+ alignItems: 'flex-start',
86
+ justifyContent: 'flex-start',
68
87
  },
69
88
  });
70
89