@eohjsc/react-native-smart-city 0.3.41 → 0.3.44

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 (54) hide show
  1. package/package.json +1 -1
  2. package/src/commons/AlertAction/index.js +22 -5
  3. package/src/commons/Device/FlatListItems.js +1 -1
  4. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
  5. package/src/commons/Device/WindSpeed/Anemometer/index.js +21 -17
  6. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
  7. package/src/commons/Processing/__test__/Connecting.test.js +1 -1
  8. package/src/commons/Processing/index.js +60 -6
  9. package/src/commons/Processing/styles.js +19 -0
  10. package/src/commons/SubUnit/ShortDetail.js +3 -4
  11. package/src/commons/SubUnit/__test__/ShortDetail.test.js +1 -2
  12. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +5 -2
  13. package/src/configs/AccessibilityLabel.js +1 -0
  14. package/src/hooks/Explore/useKeyboardAnimated.js +13 -22
  15. package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
  16. package/src/hooks/IoT/useRemoteControl.js +9 -2
  17. package/src/iot/RemoteControl/HomeAssistant.js +1 -1
  18. package/src/screens/AddNewGateway/ConnectingDevice.js +24 -7
  19. package/src/screens/AddNewGateway/ConnectingModbusDevice.js +42 -20
  20. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +24 -30
  21. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +3 -3
  22. package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +4 -5
  23. package/src/screens/AddNewGateway/PlugAndPlay/ConnectRouterGuide.js +7 -7
  24. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +69 -0
  25. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +71 -0
  26. package/src/screens/AddNewGateway/RenameNewDevices.js +6 -12
  27. package/src/screens/AddNewGateway/ScanModbusQR.js +9 -5
  28. package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +3 -3
  29. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +4 -7
  30. package/src/screens/AddNewGateway/SelectDeviceType.js +18 -19
  31. package/src/screens/AddNewGateway/SelectModbusGateway.js +5 -8
  32. package/src/screens/AddNewGateway/SelectZigbeeGateway.js +3 -4
  33. package/src/screens/AddNewGateway/ShareWifiPassword.js +13 -4
  34. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +5 -1
  35. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +6 -2
  36. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +8 -4
  37. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +64 -0
  38. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +3 -1
  39. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -2
  40. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -2
  41. package/src/screens/Device/EditDevice/index.js +4 -8
  42. package/src/screens/Device/detail.js +2 -1
  43. package/src/screens/Explore/index.js +22 -7
  44. package/src/screens/HanetCamera/MemberInfo.js +4 -8
  45. package/src/screens/ScriptDetail/index.js +3 -8
  46. package/src/screens/SubUnit/EditSubUnit.js +22 -41
  47. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +51 -59
  48. package/src/screens/Unit/ManageUnit.js +25 -47
  49. package/src/screens/Unit/ManageUnitStyles.js +0 -4
  50. package/src/screens/Unit/__test__/ManageUnit.test.js +6 -14
  51. package/src/utils/I18n/translations/en.json +8 -2
  52. package/src/utils/I18n/translations/vi.json +8 -2
  53. package/src/hooks/Common/useKeyboardShowTranslation.js +0 -120
  54. package/src/utils/runTiming.js +0 -52
@@ -1,25 +1,21 @@
1
1
  import React, { useState, useCallback, useEffect, useMemo } from 'react';
2
- import { View, TouchableOpacity, Image, Platform } from 'react-native';
3
- import Animated from 'react-native-reanimated';
4
- import { useTranslations } from '../../hooks/Common/useTranslations';
2
+ import { View, TouchableOpacity, Image } from 'react-native';
5
3
 
4
+ import { useTranslations } from '../../hooks/Common/useTranslations';
6
5
  import { Colors, API, Images } from '../../configs';
7
6
  import Routes from '../../utils/Route';
8
7
  import { ToastBottomHelper } from '../../utils/Utils';
9
8
  import { createFormData, axiosPatch } from '../../utils/Apis/axios';
10
9
  import useBoolean from '../../hooks/Common/useBoolean';
11
10
  import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
12
-
13
- import { AlertAction, ViewButtonBottom, ImagePicker } from '../../commons';
11
+ import { AlertAction, ImagePicker } from '../../commons';
14
12
  import Text from '../../commons/Text';
15
13
  import _TextInput from '../../commons/Form/TextInput';
16
14
  import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
17
-
18
15
  import { useIsOwnerOfUnit } from '../../hooks/Common';
19
16
  import { AccessibilityLabel } from '../../configs/Constants';
20
17
  import styles from './ManageUnitStyles';
21
18
  import { useNavigation } from '@react-navigation/native';
22
- import { ModalCustom } from '../../commons/Modal';
23
19
  import ButtonWrapper from './components/ButtonWrapper';
24
20
 
25
21
  const ManageUnit = ({ route }) => {
@@ -143,12 +139,7 @@ const ManageUnit = ({ route }) => {
143
139
  });
144
140
  }, [navigation, unit]);
145
141
 
146
- const [transY] = useKeyboardAnimated(-16);
147
- const animatedStyle = Platform.select({
148
- ios: {
149
- marginBottom: transY,
150
- },
151
- });
142
+ const transY = useKeyboardAnimated();
152
143
 
153
144
  const options = {
154
145
  mediaType: 'photo',
@@ -255,42 +246,29 @@ const ManageUnit = ({ route }) => {
255
246
  </Text>
256
247
  </TouchableOpacity>
257
248
  )}
258
- <ModalCustom
259
- isVisible={showEdit}
260
- onBackButtonPress={setHideEdit}
261
- onBackdropPress={setHideEdit}
262
- style={styles.modalContainer}
249
+ <AlertAction
250
+ visible={showEdit}
251
+ hideModal={setHideEdit}
252
+ title={t('rename_unit')}
253
+ leftButtonTitle={t('cancel')}
254
+ leftButtonClick={setHideEdit}
255
+ rightButtonTitle={t('rename')}
256
+ rightButtonClick={goRename}
257
+ transY={transY}
263
258
  accessibilityLabel={AccessibilityLabel.MANAGE_UNIT_MODAL_RENAME}
264
259
  >
265
- <Animated.View style={[styles.popoverStyle, animatedStyle]}>
266
- <View style={styles.modalWrapper}>
267
- <View style={styles.modalHeader}>
268
- <Text semibold style={styles.modalHeaderText}>
269
- {t('rename_unit')}
270
- </Text>
271
- </View>
272
- <_TextInput
273
- maxLength={50}
274
- defaultValue={unitData?.name}
275
- onChange={(value) => setUnitName(value)}
276
- textInputStyle={styles.textInputStyle}
277
- wrapStyle={styles.textInputWrapStyle}
278
- selectionColor={Colors.Primary}
279
- accessibilityLabel={
280
- AccessibilityLabel.MANAGE_UNIT_MODAL_RENAME_INPUT_NAME
281
- }
282
- />
283
-
284
- <ViewButtonBottom
285
- leftTitle={t('cancel')}
286
- onLeftClick={setHideEdit}
287
- rightTitle={t('rename')}
288
- onRightClick={goRename}
289
- accessibilityLabelPrefix={AccessibilityLabel.PREFIX.MANAGE_UNIT}
290
- />
291
- </View>
292
- </Animated.View>
293
- </ModalCustom>
260
+ <_TextInput
261
+ maxLength={50}
262
+ defaultValue={unitData?.name}
263
+ onChange={(value) => setUnitName(value)}
264
+ textInputStyle={styles.textInputStyle}
265
+ wrapStyle={styles.textInputWrapStyle}
266
+ selectionColor={Colors.Primary}
267
+ accessibilityLabel={
268
+ AccessibilityLabel.MANAGE_UNIT_MODAL_RENAME_INPUT_NAME
269
+ }
270
+ />
271
+ </AlertAction>
294
272
  <AlertAction
295
273
  visible={showRemove}
296
274
  hideModal={setHideRemove}
@@ -41,10 +41,6 @@ export default StyleSheet.create({
41
41
  rightButtonStyle: {
42
42
  color: Colors.Gray7,
43
43
  },
44
- modalContainer: {
45
- flex: 1,
46
- margin: 0,
47
- },
48
44
  popoverStyle: {
49
45
  width: '100%',
50
46
  backgroundColor: Colors.White,
@@ -12,6 +12,7 @@ import { mockSCStore } from '../../../context/mockStore';
12
12
  import api from '../../../utils/Apis/axios';
13
13
  import { API } from '../../../configs';
14
14
  import { getTranslate } from '../../../utils/I18n';
15
+ import { AlertAction } from '../../../commons';
15
16
 
16
17
  const mock = new MockAdapter(api.axiosInstance);
17
18
 
@@ -138,15 +139,11 @@ describe('Test Manage Unit', () => {
138
139
  await act(async () => {
139
140
  await changeName[0].props.onPress();
140
141
  });
141
- const bottomButton = instance.find(
142
- (item) =>
143
- item.props.accessibilityLabel ===
144
- `${AccessibilityLabel.PREFIX.MANAGE_UNIT}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
145
- );
142
+ const alertActions = instance.findAllByType(AlertAction);
146
143
  mock.onPatch(API.UNIT.MANAGE_UNIT(1)).reply(200, {});
147
144
  await act(async () => {
148
145
  await inputRename[0].props.onChange('input station');
149
- await bottomButton.props.onPress();
146
+ await alertActions[0].props.rightButtonClick();
150
147
  });
151
148
  expect(Toast.show).toBeCalledWith({
152
149
  position: 'bottom',
@@ -194,16 +191,11 @@ describe('Test Manage Unit', () => {
194
191
  await changeName[0].props.onPress();
195
192
  });
196
193
 
197
- const bottomButton = instance.find(
198
- (item) =>
199
- item.props.accessibilityLabel ===
200
- `${AccessibilityLabel.PREFIX.MANAGE_UNIT}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
201
- );
202
- mock.onPatch(API.UNIT.MANAGE_UNIT(1)).reply(200);
203
-
194
+ const alertActions = instance.findAllByType(AlertAction);
195
+ mock.onPatch(API.UNIT.MANAGE_UNIT(1)).reply(200, {});
204
196
  await act(async () => {
205
197
  await inputRename[0].props.onChange('input station');
206
- await bottomButton.props.onPress();
198
+ await alertActions[0].props.rightButtonClick();
207
199
  });
208
200
 
209
201
  expect(mockedDispatch).not.toBeCalled();
@@ -444,9 +444,9 @@
444
444
  "insufficient_water_input": "Insufficient water input.",
445
445
  "check_water_leak": "Check for water leak.",
446
446
  "exceed_5_filter": "Exceed 5hrs filtering. Tank is not yet full.",
447
- "exceed_%{hour}_filter": "Exceed %{hour}hrs filtering. Tank is not yet full.",
447
+ "exceed_{hour}_filter": "Exceed {hour}hrs filtering. Tank is not yet full.",
448
448
  "tank_is_full": "Tank is full.",
449
- "%{number}_filter_need_to_be_replaced": "%{number} filters need to be replaced.",
449
+ "{number}_filter_need_to_be_replaced": "{number} filters need to be replaced.",
450
450
  "replace_all_filters": "Replace all filters.",
451
451
  "directions": "Directions",
452
452
  "save": "Save",
@@ -1038,6 +1038,8 @@
1038
1038
  "select_all": "Select All",
1039
1039
  "turn_off_device": "Turn off device",
1040
1040
  "turn_off_device_when_scan_qr_guide": "Turn off the device you want to add new before scanning the QR code. Press ‘’OK’’ to continue.",
1041
+ "turn_on_device": "Turn on device",
1042
+ "turn_on_device_after_change_address_success": "Turn on the device you want to connect. Press ‘’OK’’ to continue.",
1041
1043
  "connect_to_router": "Connect to the Router",
1042
1044
  "connect_router_content": "Please plug in the gateway and connect it to the router, making sure your phone and the gateway are under the same network. Then, comfirm that the light is on and press “Next”",
1043
1045
  "turn_on_zigbee_device": "Turn on zigbee device",
@@ -1058,5 +1060,9 @@
1058
1060
  "connecting_modbus_device": "Connecting to modbus device",
1059
1061
  "connecting_zigbee_device": "Connecting to zigbee device",
1060
1062
  "connecting_to_gateway": "Connecting to gateway",
1063
+ "select_network": "Select your home network.",
1064
+ "wrong_wifi_password": "Wrong wifi's password",
1065
+ "fail_add_modbus_device": "Fail to add modbus device",
1066
+ "fail_add_zigbee_device": "Fail to add zigbee device",
1061
1067
  "click_here_to_setup_device": "Click here to setup device"
1062
1068
  }
@@ -53,9 +53,9 @@
53
53
  "insufficient_water_input": "Thiếu nước đầu vào.",
54
54
  "check_water_leak": "Kiểm tra rò rỉ nước.",
55
55
  "exceed_5_filter": "Lọc liên tục 5h nhưng bình không đầy",
56
- "exceed_%{hour}_filter": "Lọc liên tục %{hour}h nhưng bình không đầy",
56
+ "exceed_{hour}_filter": "Lọc liên tục {hour}h nhưng bình không đầy",
57
57
  "tank_is_full": "Nước đầy.",
58
- "%{number}_filter_need_to_be_replaced": "%{number} lõi lọc cần được thay thế.",
58
+ "{number}_filter_need_to_be_replaced": "{number} lõi lọc cần được thay thế.",
59
59
  "replace_all_filters": "Tất cả lõi lọc cần được thay thế.",
60
60
  "auth_already_have_an_account": "Bạn đã có tài khoản? ",
61
61
  "tds_information": "Chỉ số TDS",
@@ -1036,6 +1036,8 @@
1036
1036
  "select_all": "Chọn tất cả",
1037
1037
  "turn_off_device": "Tắt thiết bị",
1038
1038
  "turn_off_device_when_scan_qr_guide": "Tắt thiết bị bạn muốn thêm mới trước khi quét mã QR. Nhấn ‘’OK’’ để tiếp tục.",
1039
+ "turn_on_device": "Turn on device",
1040
+ "turn_on_device_after_change_address_success": "Bật thiết bị bạn muốn kết nối. Nhấn ‘’OK’’ để tiếp tục.",
1039
1041
  "connect_to_router": "Kết nối với Bộ định tuyến",
1040
1042
  "connect_router_content": "Vui lòng cắm cổng vào và kết nối nó với bộ định tuyến, đảm bảo rằng điện thoại của bạn và cổng kết nối nằm trong cùng một mạng. Sau đó, xác nhận rằng đèn đã sáng và nhấn “Tiếp theo”",
1041
1043
  "turn_on_zigbee_device": "Bật thiết bị zigbee",
@@ -1056,5 +1058,9 @@
1056
1058
  "connecting_modbus_device": "Kết nối với thiết bị modbus",
1057
1059
  "connecting_zigbee_device": "Kết nối với thiết bị zigbee",
1058
1060
  "connecting_to_gateway": "Kết nối với gateway",
1061
+ "select_network": "Chọn mạng của bạn.",
1062
+ "wrong_wifi_password": "Sai mật khẩu wifi",
1063
+ "fail_add_modbus_device": "Không thêm được thiết bị modbus",
1064
+ "fail_add_zigbee_device": "Không thêm được thiết bị zigbee",
1059
1065
  "click_here_to_setup_device": "Chọn thiết bị thêm vào phòng"
1060
1066
  }
@@ -1,120 +0,0 @@
1
- import {
2
- Clock,
3
- Value,
4
- interpolate,
5
- Extrapolate,
6
- Easing,
7
- cond,
8
- clockRunning,
9
- set,
10
- startClock,
11
- timing,
12
- debug,
13
- stopClock,
14
- block,
15
- } from 'react-native-reanimated';
16
- import { useMemo, useCallback, useEffect, useState } from 'react';
17
- import { Keyboard, Platform } from 'react-native';
18
- export const runTiming = (clock, value, dest, duration) => {
19
- const state = {
20
- finished: new Value(0),
21
- position: new Value(0),
22
- time: new Value(0),
23
- frameTime: new Value(0),
24
- };
25
-
26
- const config = {
27
- duration: duration || 200,
28
- toValue: new Value(0),
29
- easing: Easing.inOut(Easing.ease),
30
- };
31
-
32
- return block([
33
- cond(
34
- clockRunning(clock),
35
- [
36
- // if the clock is already running we update the toValue, in case a new dest has been passed in
37
- set(config.toValue, dest),
38
- ],
39
- [
40
- // if the clock isn't running we reset all the animation params and start the clock
41
- set(state.finished, 0),
42
- set(state.time, 0),
43
- set(state.position, value),
44
- set(state.frameTime, 0),
45
- set(config.toValue, dest),
46
- startClock(clock),
47
- ]
48
- ),
49
- // we run the step here that is going to update position
50
- timing(clock, state, config),
51
- // if the animation is over we stop the clock
52
- cond(state.finished, debug('stop clock', stopClock(clock))),
53
- // we made the block return the updated position
54
- state.position,
55
- ]);
56
- };
57
-
58
- export const useKeyboardShowTranslation = () => {
59
- const clock = new Clock();
60
- const [height, setHeight] = useState(0);
61
- const marginStart = useMemo(() => new Value(0), []);
62
- const marginEnd = useMemo(() => new Value(0), []);
63
- const _keyboardWillHide = useCallback(() => {
64
- marginStart.setValue(marginEnd);
65
- marginEnd.setValue(0);
66
- }, [marginStart, marginEnd]);
67
- const _keyboardWillShow = useCallback(
68
- (e) => {
69
- marginStart.setValue(marginEnd);
70
- marginEnd.setValue(e.endCoordinates.height);
71
- setHeight(e.endCoordinates.height);
72
- },
73
- [marginEnd, marginStart]
74
- );
75
-
76
- const transY = runTiming(clock, marginStart, marginEnd);
77
- const transOutY = interpolate(transY, {
78
- inputRange: [0, height],
79
- outputRange: [0, 200],
80
- extrapolate: Extrapolate.CLAMP,
81
- });
82
- const opacity = interpolate(transY, {
83
- inputRange: [0, height],
84
- outputRange: [1, 0],
85
- extrapolate: Extrapolate.CLAMP,
86
- });
87
-
88
- const action = Platform.OS === 'ios' ? 'Will' : 'Did';
89
- const animatedStyle = Platform.select({
90
- ios: {
91
- marginBottom: transY,
92
- },
93
- });
94
- const transOutStyle = {
95
- transform: [{ translateY: transOutY }],
96
- };
97
- const opacityStyle = {
98
- opacity: opacity,
99
- };
100
-
101
- useEffect(() => {
102
- // @ts-ignore
103
- Keyboard.addListener('keyboard' + action + 'Hide', _keyboardWillHide);
104
- // @ts-ignore
105
- Keyboard.addListener('keyboard' + action + 'Show', _keyboardWillShow);
106
- // cleanup function
107
- return () => {
108
- Keyboard.removeListener('keyboard' + action + 'Show', _keyboardWillShow);
109
- Keyboard.removeListener('keyboard' + action + 'Hide', _keyboardWillHide);
110
- };
111
- }, [_keyboardWillHide, _keyboardWillShow, action]);
112
-
113
- return {
114
- transY,
115
- animatedStyle,
116
- opacity,
117
- opacityStyle,
118
- transOutStyle,
119
- };
120
- };
@@ -1,52 +0,0 @@
1
- import {
2
- Easing,
3
- Value,
4
- cond,
5
- clockRunning,
6
- set,
7
- startClock,
8
- timing,
9
- debug,
10
- stopClock,
11
- block,
12
- } from 'react-native-reanimated';
13
-
14
- export function runTiming(clock, value, dest, duration) {
15
- const state = {
16
- finished: new Value(0),
17
- position: new Value(0),
18
- time: new Value(0),
19
- frameTime: new Value(0),
20
- };
21
-
22
- const config = {
23
- duration: duration || 200,
24
- toValue: new Value(0),
25
- easing: Easing.inOut(Easing.ease),
26
- };
27
-
28
- return block([
29
- cond(
30
- clockRunning(clock),
31
- [
32
- // if the clock is already running we update the toValue, in case a new dest has been passed in
33
- set(config.toValue, dest),
34
- ],
35
- [
36
- // if the clock isn't running we reset all the animation params and start the clock
37
- set(state.finished, 0),
38
- set(state.time, 0),
39
- set(state.position, value),
40
- set(state.frameTime, 0),
41
- set(config.toValue, dest),
42
- startClock(clock),
43
- ]
44
- ),
45
- // we run the step here that is going to update position
46
- timing(clock, state, config),
47
- // if the animation is over we stop the clock
48
- cond(state.finished, debug('stop clock', stopClock(clock))),
49
- // we made the block return the updated position
50
- state.position,
51
- ]);
52
- }