@eohjsc/react-native-smart-city 0.3.85 → 0.3.86

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 +3 -2
  2. package/src/Images/Common/logo.png +0 -0
  3. package/src/Images/Common/logo@2x.png +0 -0
  4. package/src/Images/Common/logo@3x.png +0 -0
  5. package/src/Images/Common/unit_default_background.png +0 -0
  6. package/src/Images/Common/unit_default_background@2x.png +0 -0
  7. package/src/Images/Common/unit_default_background@3x.png +0 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  9. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -13
  10. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +0 -1
  11. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +4 -4
  12. package/src/commons/ActionGroup/__test__/index.test.js +1 -1
  13. package/src/commons/Automate/__test__/ItemAutomate.test.js +25 -3
  14. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +37 -0
  15. package/src/commons/Dashboard/MyUnit/index.js +28 -6
  16. package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
  17. package/src/commons/Device/ProgressBar/index.js +4 -2
  18. package/src/commons/Device/ProgressBar/styles.js +1 -0
  19. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  20. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  21. package/src/commons/Device/WindSpeed/Anemometer/index.js +96 -14
  22. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +89 -2
  23. package/src/commons/ModalPopupCT/index.js +21 -2
  24. package/src/commons/ModalPopupCT/styles.js +7 -0
  25. package/src/commons/WrapParallaxScrollView/index.js +5 -4
  26. package/src/configs/API.js +3 -2
  27. package/src/configs/AccessibilityLabel.js +3 -0
  28. package/src/configs/Constants.js +1 -0
  29. package/src/configs/Images.js +1 -0
  30. package/src/context/actionType.ts +3 -0
  31. package/src/context/mockStore.ts +1 -0
  32. package/src/context/reducer.ts +19 -0
  33. package/src/screens/AddNewAction/__test__/LoadingSelectAction.test.js +16 -0
  34. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  35. package/src/screens/AllCamera/index.js +2 -2
  36. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +179 -111
  37. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +48 -50
  38. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +4 -0
  39. package/src/screens/AllGateway/DeviceInternalDetail/index.js +14 -1
  40. package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +25 -0
  41. package/src/screens/AllGateway/GatewayConnectionMethods/index.js +59 -35
  42. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +14 -4
  43. package/src/screens/AllGateway/GatewayInfo/index.js +21 -2
  44. package/src/screens/AllGateway/components/Detail/__test__/index.test.js +28 -1
  45. package/src/screens/AllGateway/components/Detail/index.js +8 -2
  46. package/src/screens/AllGateway/components/Information/index.js +4 -1
  47. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  48. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  49. package/src/screens/AllGateway/components/TabPaneCT/styles.js +1 -1
  50. package/src/screens/ConfirmUnitDeletion/index.js +6 -2
  51. package/src/screens/Unit/ManageUnit.js +7 -3
  52. package/src/utils/I18n/translations/en.json +3 -0
  53. package/src/utils/I18n/translations/vi.json +3 -0
  54. package/src/utils/Utils.js +6 -0
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import { Text } from 'react-native-svg';
4
4
  import Anemometer from '../Anemometer';
5
+ import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
5
6
 
6
7
  describe('Test Anemometer', () => {
7
8
  let wrapper;
@@ -16,7 +17,7 @@ describe('Test Anemometer', () => {
16
17
  });
17
18
  const instance = wrapper.root;
18
19
  const text = instance.findAllByType(Text);
19
- expect(text.length).toBe(7);
20
+ expect(text.length).toBe(5);
20
21
  });
21
22
  it('render Anemometer data null', async () => {
22
23
  let data = [];
@@ -25,6 +26,92 @@ describe('Test Anemometer', () => {
25
26
  });
26
27
  const instance = wrapper.root;
27
28
  const text = instance.findAllByType(Text);
28
- expect(text.length).toBe(7);
29
+ expect(text.length).toBe(5);
30
+ });
31
+
32
+ it('test render value font size length < 4', async () => {
33
+ let data = [
34
+ {
35
+ value: 123,
36
+ },
37
+ ];
38
+ await act(async () => {
39
+ wrapper = renderer.create(<Anemometer data={data} maxValue={1} />);
40
+ });
41
+ let instance = wrapper.root;
42
+ const text = instance.findAllByType(Text);
43
+ expect(text.length).toBe(5);
44
+ expect(text[0].props.fontSize).toEqual(56);
45
+ });
46
+
47
+ it('test render value font size length < 7', async () => {
48
+ let data = [
49
+ {
50
+ value: 123456,
51
+ },
52
+ ];
53
+ await act(async () => {
54
+ wrapper = renderer.create(<Anemometer data={data} maxValue={1} />);
55
+ });
56
+ let instance = wrapper.root;
57
+ const text = instance.findAllByType(Text);
58
+ expect(text.length).toBe(5);
59
+ expect(text[0].props.fontSize).toEqual(35);
60
+ });
61
+
62
+ it('test render value font size length < 10', async () => {
63
+ let data = [
64
+ {
65
+ value: 123456789,
66
+ },
67
+ ];
68
+ await act(async () => {
69
+ wrapper = renderer.create(<Anemometer data={data} maxValue={1} />);
70
+ });
71
+ let instance = wrapper.root;
72
+ const text = instance.findAllByType(Text);
73
+ expect(text.length).toBe(5);
74
+ expect(text[0].props.fontSize).toEqual(26);
75
+ });
76
+
77
+ it('test render toolTipTranslateX', async () => {
78
+ let data = [
79
+ {
80
+ value: 123456,
81
+ },
82
+ ];
83
+ await act(async () => {
84
+ wrapper = renderer.create(<Anemometer data={data} maxValue={1} />);
85
+ });
86
+ let instance = wrapper.root;
87
+ const text = instance.findAllByType(Text);
88
+ await act(async () => {
89
+ text[0].props.onPressIn();
90
+ });
91
+ const view = instance.findByProps({
92
+ accessibilityLabel: AccessibilityLabel.WRAP_TOOL_TIP,
93
+ });
94
+ expect(view.props.style.transform[0].translateX).toEqual(-40);
95
+ });
96
+
97
+ it('test render toolTipTranslateX long value', async () => {
98
+ let data = [
99
+ {
100
+ value: 123456789,
101
+ },
102
+ ];
103
+ await act(async () => {
104
+ wrapper = renderer.create(<Anemometer data={data} maxValue={1} />);
105
+ });
106
+ let instance = wrapper.root;
107
+ const text = instance.findAllByType(Text);
108
+ expect(text).toHaveLength(5);
109
+ await act(async () => {
110
+ text[0].props.onPressIn();
111
+ });
112
+ const view = instance.findByProps({
113
+ accessibilityLabel: AccessibilityLabel.WRAP_TOOL_TIP,
114
+ });
115
+ expect(view.props.style.transform[0].translateX).toEqual(-50);
29
116
  });
30
117
  });
@@ -71,6 +71,15 @@ const ModalPopupCT = ({
71
71
  disabled={false}
72
72
  value={isChecked}
73
73
  onValueChange={setIsChecked}
74
+ lineWidth={3}
75
+ boxType="square"
76
+ onTintColor={Colors.Primary}
77
+ onFillColor={Colors.Primary}
78
+ onCheckColor={Colors.White}
79
+ tintColor={Colors.Gray14}
80
+ onAnimationType="bounce"
81
+ offAnimationType="bounce"
82
+ style={styles.checkbox}
74
83
  />
75
84
  </View>
76
85
  <TouchableOpacity
@@ -91,7 +100,12 @@ const ModalPopupCT = ({
91
100
  onPress={onPressCancel}
92
101
  style={styles.buttonCancel}
93
102
  >
94
- <Text type="H4" bold color={Colors.Gray9}>
103
+ <Text
104
+ type="H4"
105
+ bold
106
+ color={Colors.Gray9}
107
+ style={styles.paddingBottom3}
108
+ >
95
109
  {t('cancel')}
96
110
  </Text>
97
111
  </TouchableOpacity>
@@ -100,7 +114,12 @@ const ModalPopupCT = ({
100
114
  onPress={onPressConfirm}
101
115
  disabled={isUnHideButton ? !isUnHideButton : !isChecked}
102
116
  >
103
- <Text type="H4" bold color={Colors.White}>
117
+ <Text
118
+ type="H4"
119
+ bold
120
+ color={Colors.White}
121
+ style={styles.paddingBottom3}
122
+ >
104
123
  {t((type === 'reboot' && 'reboot') || 'delete')}
105
124
  </Text>
106
125
  </TouchableOpacity>
@@ -92,4 +92,11 @@ export default StyleSheet.create({
92
92
  backgroundColor: Colors.White,
93
93
  opacity: 0.7,
94
94
  },
95
+ paddingBottom3: {
96
+ paddingBottom: 3,
97
+ },
98
+ checkbox: {
99
+ width: 24,
100
+ height: 24,
101
+ },
95
102
  });
@@ -1,12 +1,13 @@
1
1
  import React, { useCallback } from 'react';
2
- import { Image, StatusBar, View, StyleSheet } from 'react-native';
3
- import ParallaxScrollView from '../../libs/react-native-parallax-scroll-view';
2
+ import { StatusBar, View, StyleSheet } from 'react-native';
4
3
  import LinearGradient from 'react-native-linear-gradient';
5
4
 
6
5
  import { Colors, Device, Images } from '../../configs';
7
6
  import Text from '../Text';
8
7
  import HeaderUnit from '../Unit/HeaderUnit';
9
8
  import { AccessibilityLabel } from '../../configs/Constants';
9
+ import FImage from '../FImage';
10
+ import ParallaxScrollView from '../../libs/react-native-parallax-scroll-view';
10
11
 
11
12
  const stickyHeaderHeight =
12
13
  Device.TopbarHeight + (Device.isIOS ? 0 : StatusBar.currentHeight);
@@ -62,9 +63,9 @@ const WrapParallaxScrollView = ({
62
63
  const renderBackground = useCallback(
63
64
  () => (
64
65
  <View style={styles.image}>
65
- <Image
66
+ <FImage
66
67
  style={styles.image}
67
- source={{ uri: uriImg }}
68
+ source={uriImg ? { uri: uriImg } : Images.unitDefaultBackground}
68
69
  defaultSource={Images.BgUnit}
69
70
  resizeMode="cover"
70
71
  />
@@ -222,6 +222,7 @@ const API = {
222
222
  REBOOT: (id) => `/chip_manager/developer_mode_chips/${id}/reboot_chip/`,
223
223
  },
224
224
  ARDUINO: {
225
+ DETAIL: (id) => `/iot/modules/arduino/gateways/${id}/`,
225
226
  DEVICE: (gatewayId) =>
226
227
  `/iot/modules/arduino/gateways/${gatewayId}/devices/`,
227
228
  DEVICE_DETAIL: (gatewayId, deviceId) =>
@@ -236,6 +237,7 @@ const API = {
236
237
  `/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/actions/${actionId}/`,
237
238
  },
238
239
  ZIGBEE: {
240
+ DETAIL: (id) => `/iot/modules/zigbee/gateways/${id}/`,
239
241
  SEARCH_DEVICE: (id) => `/iot/modules/zigbee/chips/${id}/search_device/`,
240
242
  DEVICE_CONFIGURATION: (id, deviceId) =>
241
243
  `/iot/modules/zigbee/chips/${id}/sensors/${deviceId}/configuration/`,
@@ -250,6 +252,7 @@ const API = {
250
252
  `/iot/modules/zigbee/gateways/${gatewayId}/devices/${deviceId}/zigbee_actions/`,
251
253
  },
252
254
  MODBUS: {
255
+ DETAIL: (id) => `/iot/modules/modbus/gateways/${id}/`,
253
256
  DEVICE: (gatewayId) =>
254
257
  `/iot/modules/modbus/gateways/${gatewayId}/devices/`,
255
258
  DEVICE_DETAIL: (gatewayId, deviceId) =>
@@ -260,8 +263,6 @@ const API = {
260
263
  `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/actions/`,
261
264
  ACTION_DETAIL: (gatewayId, deviceId, actionId) =>
262
265
  `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/actions/${actionId}/`,
263
- ACTION_ITEM_DETAIL: (actionId, actionItemId) =>
264
- `/iot/modules/modbus/actions/${actionId}/items/${actionItemId}/`,
265
266
  },
266
267
  },
267
268
  };
@@ -358,6 +358,9 @@ export default {
358
358
  STATION_DEVICE_PERMISSIONS: 'STATION_DEVICE_PERMISSIONS',
359
359
  TEXT_NO_DATA_STATIONS: 'TEXT_NO_DATA_STATIONS',
360
360
 
361
+ // Gauge widget
362
+ WRAP_TOOL_TIP: 'WRAP_TOOL_TIP',
363
+
361
364
  // Manage Unit
362
365
  MANAGE_UNIT_CHANGE_NAME: 'MANAGE_UNIT_CHANGE_NAME',
363
366
  MANAGE_UNIT_CHANGE_LOCATION: 'MANAGE_UNIT_CHANGE_LOCATION',
@@ -90,6 +90,7 @@ export const PERMISSION_TYPE = {
90
90
  CONFIG: 'CONFIG',
91
91
  CONFIG_WRITE: 'CONFIG_WRITE',
92
92
  CONFIG_READ: 'CONFIG_READ',
93
+ VIRTUAL_PIN: 'VIRTUAL_PIN',
93
94
  };
94
95
 
95
96
  const marginItem = 12;
@@ -26,4 +26,5 @@ export default {
26
26
  lg: require('../Images/SmartAccount/LG.png'),
27
27
  inforCode: require('../Images/DevMode/inforCode.png'),
28
28
  activeCurrentSensor: require('../Images/Common/Sunny.png'),
29
+ unitDefaultBackground: require('../Images/Common/unit_default_background.png'),
29
30
  };
@@ -33,6 +33,8 @@ export const Action = {
33
33
  REFRESH_PERCENT: 'REFRESH_PERCENT',
34
34
  PROCESS_DONE: 'PROCESS_DONE',
35
35
  IS_EMERGENCY_POPUP: 'IS_EMERGENCY_POPUP',
36
+ DELETE_UNIT_SUCCESSFULLY: 'DELETE_UNIT_SUCCESSFULLY',
37
+ RESET_DELETE_UNIT_ACTION: 'RESET_DELETE_UNIT_ACTION',
36
38
  // NOTE: DEV MODE
37
39
  SET_WIDGET_DRAGGING: 'SET_WIDGET_DRAGGING',
38
40
  SET_IS_EDITING_TEMPLATE: 'SET_IS_EDITING_TEMPLATE',
@@ -96,6 +98,7 @@ export type AppType = {
96
98
  notificationData: any;
97
99
  popoverAnimating: boolean;
98
100
  isLockWhenPickColor: boolean;
101
+ isDeleteUnitSuccessFully: boolean;
99
102
  };
100
103
 
101
104
  export type IoTType = {
@@ -92,6 +92,7 @@ export const mockSCStore = (data: ContextData): ContextData => {
92
92
  isConnectWifiGateway: false,
93
93
  isNetworkConnected: true,
94
94
  isLockWhenPickColor: false,
95
+ ...data.app,
95
96
  },
96
97
  unit: {
97
98
  favoriteDeviceIds: [
@@ -69,6 +69,7 @@ export const initialState = {
69
69
  popoverAnimating: false,
70
70
  isLockWhenPickColor: false,
71
71
  isEmergencyPopupScreen: false,
72
+ isDeleteUnitSuccessFully: false,
72
73
  },
73
74
  iot: {
74
75
  bluetooth: {
@@ -496,6 +497,24 @@ export const reducer = (currentState: ContextData, action: Action) => {
496
497
  ...currentState,
497
498
  };
498
499
 
500
+ case Action.DELETE_UNIT_SUCCESSFULLY:
501
+ return {
502
+ ...currentState,
503
+ app: {
504
+ ...currentState.app,
505
+ isDeleteUnitSuccessFully: true,
506
+ },
507
+ };
508
+
509
+ case Action.RESET_DELETE_UNIT_ACTION:
510
+ return {
511
+ ...currentState,
512
+ app: {
513
+ ...currentState.app,
514
+ isDeleteUnitSuccessFully: false,
515
+ },
516
+ };
517
+
499
518
  default:
500
519
  return currentState;
501
520
  }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { act, create } from 'react-test-renderer';
4
+
5
+ import LoadingSelectAction from '../Components/LoadingSelectAction';
6
+ describe('Test LoadingSelectAction', () => {
7
+ let tree;
8
+ it('Test render', async () => {
9
+ await act(async () => {
10
+ tree = await create(<LoadingSelectAction />);
11
+ });
12
+ const instance = tree.root;
13
+ const views = instance.findAllByType(View);
14
+ expect(views).toHaveLength(1);
15
+ });
16
+ });
@@ -4,7 +4,7 @@ import AllCamera from '..';
4
4
  import { act, create } from 'react-test-renderer';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
- import Carousel from 'react-native-snap-carousel';
7
+ import Carousel from 'react-native-new-snap-carousel';
8
8
 
9
9
  const arrCameras = [
10
10
  {
@@ -8,9 +8,9 @@ import React, {
8
8
  import { View, Text, TouchableOpacity, Platform, Image } from 'react-native';
9
9
  import { useRoute, useNavigation } from '@react-navigation/native';
10
10
  import { chunk } from 'lodash';
11
- import Carousel from 'react-native-snap-carousel';
12
-
11
+ import Carousel from 'react-native-new-snap-carousel';
13
12
  import { useTranslations } from '../../hooks/Common/useTranslations';
13
+
14
14
  import { Images, Colors } from '../../configs';
15
15
  import { useHiddenStatusBar } from '../../hooks/Common/useStatusBar';
16
16
  import { HeaderCustom } from '../../commons/Header';