@eohjsc/react-native-smart-city 0.3.71 → 0.3.72

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 (151) hide show
  1. package/index.js +0 -2
  2. package/package.json +4 -5
  3. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  5. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
  6. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
  7. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -3
  8. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
  9. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
  10. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +39 -34
  11. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +1 -1
  12. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
  13. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
  14. package/src/commons/ActionGroup/__test__/index.test.js +24 -16
  15. package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
  16. package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
  17. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  18. package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
  19. package/src/commons/CameraDevice/index.js +37 -22
  20. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
  21. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  22. package/src/commons/Device/ConnectedViewHeader.js +2 -1
  23. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  24. package/src/commons/Device/DisconnectedView.js +10 -14
  25. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  26. package/src/commons/Device/HorizontalBarChart.js +1 -1
  27. package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
  28. package/src/commons/Device/LinearChart.js +5 -1
  29. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  30. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  31. package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
  32. package/src/commons/Device/WindDirection/Compass/index.js +15 -23
  33. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
  34. package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
  35. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
  36. package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
  37. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  38. package/src/commons/DisplayChecking/index.js +4 -3
  39. package/src/commons/DisplayChecking/styles.js +2 -2
  40. package/src/commons/MediaPlayer/index.js +2 -1
  41. package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
  42. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
  43. package/src/commons/MediaPlayerDetail/index.js +2 -3
  44. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
  45. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
  46. package/src/commons/MenuActionList/index.js +8 -70
  47. package/src/commons/MenuActionList/styles.js +68 -0
  48. package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
  49. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
  50. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
  51. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
  52. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
  53. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
  54. package/src/commons/PreventAccess/index.js +3 -3
  55. package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
  56. package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
  57. package/src/commons/SubUnit/OneTap/index.js +6 -1
  58. package/src/commons/Today/__test__/Today.test.js +3 -3
  59. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  60. package/src/configs/IOPinConstants.js +285 -0
  61. package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
  62. package/src/navigations/AllGatewayStack.js +3 -3
  63. package/src/navigations/UnitStack.js +0 -6
  64. package/src/screens/ActivityLog/__test__/index.test.js +16 -22
  65. package/src/screens/ActivityLog/index.js +2 -3
  66. package/src/screens/AddNewAction/SelectAction.js +3 -0
  67. package/src/screens/AddNewAction/SetupSensor.js +3 -3
  68. package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
  69. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
  70. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
  71. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
  72. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
  73. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
  74. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
  75. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  76. package/src/screens/AllCamera/index.js +1 -1
  77. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
  78. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
  79. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
  80. package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
  81. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
  82. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
  83. package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
  84. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
  85. package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
  86. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  87. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  88. package/src/screens/AllGateway/hooks/useGateway.js +1 -0
  89. package/src/screens/AllGateway/test-utils.js +20 -0
  90. package/src/screens/Device/__test__/detail.test.js +8 -3
  91. package/src/screens/Device/components/SensorDisplayItem.js +1 -5
  92. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
  93. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
  94. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
  95. package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
  96. package/src/screens/GuestInfo/__test__/index.test.js +26 -14
  97. package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
  98. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
  99. package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
  100. package/src/screens/PlayBackCamera/Timer.js +2 -3
  101. package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
  102. package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
  103. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
  104. package/src/screens/SharedUnit/index.js +19 -17
  105. package/src/screens/SmartAccount/Connecting/index.js +2 -2
  106. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
  107. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
  108. package/src/screens/SmartAccount/ListDevice/index.js +1 -1
  109. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
  110. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
  111. package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
  112. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
  113. package/src/screens/SubUnit/EditSubUnit.js +6 -6
  114. package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
  115. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
  116. package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
  117. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
  118. package/src/screens/Template/EditTemplate.js +13 -3
  119. package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
  120. package/src/screens/Unit/Detail.js +157 -121
  121. package/src/screens/Unit/ManageUnit.js +3 -3
  122. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  123. package/src/screens/Unit/__test__/Detail.test.js +40 -20
  124. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
  125. package/src/screens/Unit/components/AutomateScript/index.js +9 -8
  126. package/src/screens/Unit/components/Header/index.js +1 -14
  127. package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
  128. package/src/screens/Unit/components/__test__/Header.test.js +14 -9
  129. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
  130. package/src/utils/Route/index.js +1 -2
  131. package/src/utils/Utils.js +62 -2
  132. package/src/commons/Explore/ActivityIndicator/index.js +0 -49
  133. package/src/commons/Explore/CityItem/index.js +0 -116
  134. package/src/commons/Explore/HeaderExplore/index.js +0 -44
  135. package/src/commons/Explore/HeaderLabel/index.js +0 -46
  136. package/src/commons/Explore/LocationItem/index.js +0 -71
  137. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
  138. package/src/commons/Explore/SearchBox/index.js +0 -59
  139. package/src/commons/Explore/__test__/CityItem.test.js +0 -156
  140. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
  141. package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
  142. package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
  143. package/src/screens/Explore/__test__/Explore.test.js +0 -43
  144. package/src/screens/Explore/index.js +0 -201
  145. package/src/screens/Unit/MyAllUnit/index.js +0 -44
  146. package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
  147. package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
  148. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
  149. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  150. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  151. package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
@@ -5,6 +5,8 @@ import { AUTOMATE_TYPE } from '../../../../configs/Constants';
5
5
  import { SCProvider } from '../../../../context';
6
6
  import { mockSCStore } from '../../../../context/mockStore';
7
7
  import AutomateScript from '../AutomateScript';
8
+ import Text from '../../../../commons/Text';
9
+ import FImage from '../../../../commons/FImage';
8
10
 
9
11
  const mockOnPress = jest.fn();
10
12
 
@@ -19,8 +21,10 @@ const wrapComponent = (isSelected, automate = 'automate') => (
19
21
  );
20
22
 
21
23
  describe('test AutomateScript screen', () => {
22
- let tree,
24
+ let tree, automate;
25
+ beforeEach(() => {
23
26
  automate = { type: '' };
27
+ });
24
28
  it('Test isSelected=false', async () => {
25
29
  await act(async () => {
26
30
  tree = await create(wrapComponent(false, automate));
@@ -70,47 +74,17 @@ describe('test AutomateScript screen', () => {
70
74
  tree = await create(wrapComponent(true, automate));
71
75
  });
72
76
  const instance = tree.root;
73
- const Views = instance.findAllByType(View);
74
- expect(Views).toHaveLength(9);
75
- });
76
-
77
- it('Test render ONE_TAP', async () => {
78
- automate = { ...automate, type: AUTOMATE_TYPE.ONE_TAP };
79
- await act(async () => {
80
- tree = await create(wrapComponent(true, automate));
81
- });
82
- const instance = tree.root;
83
- const Views = instance.findAllByType(View);
84
- expect(Views).toHaveLength(9);
85
- });
86
-
87
- it('Test render EVENT', async () => {
88
- automate = { ...automate, type: AUTOMATE_TYPE.EVENT };
89
- await act(async () => {
90
- tree = await create(wrapComponent(true, automate));
91
- });
92
- const instance = tree.root;
93
- const Views = instance.findAllByType(View);
94
- expect(Views).toHaveLength(9);
95
- });
96
-
97
- it('Test render SCHEDULE', async () => {
98
- automate = { ...automate, type: AUTOMATE_TYPE.SCHEDULE };
99
- await act(async () => {
100
- tree = await create(wrapComponent(true, automate));
101
- });
102
- const instance = tree.root;
103
- const Views = instance.findAllByType(View);
104
- expect(Views).toHaveLength(9);
77
+ expect(instance.findAllByType(FImage)).toHaveLength(0);
105
78
  });
106
79
 
107
80
  it('Test render with iconKit', async () => {
108
- automate = { ...automate, script: { icon_kit: 'iconKit' } };
81
+ automate = { ...automate, script: { icon_kit: 'iconKit', name: 'xxx' } };
109
82
  await act(async () => {
110
83
  tree = await create(wrapComponent(true, automate));
111
84
  });
112
85
  const instance = tree.root;
113
- const Views = instance.findAllByType(View);
114
- expect(Views).toHaveLength(10);
86
+ const texts = instance.findAllByType(Text);
87
+ expect(texts[0].props.children).toEqual('xxx');
88
+ expect(instance.findAllByType(FImage)).toHaveLength(1);
115
89
  });
116
90
  });
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
- import Modal from 'react-native-modal';
4
3
  import Popover from '../../../../commons/Popover';
5
4
 
6
5
  import { SCProvider } from '../../../../context';
@@ -9,6 +8,8 @@ import Header from '../Header';
9
8
  import ImageButton from '../../../../commons/ImageButton';
10
9
  import Routes from '../../../../utils/Route';
11
10
  import { TouchableOpacity } from 'react-native';
11
+ import { ModalCustom } from '../../../../commons/Modal';
12
+ import HeaderCustom from '../../../../commons/Header/HeaderCustom';
12
13
 
13
14
  const wrapComponent = (title, goBack, dark, hideRight) => (
14
15
  <SCProvider initState={mockSCStore({})}>
@@ -36,7 +37,7 @@ describe('Test Header', () => {
36
37
  tree = renderer.create(wrapComponent());
37
38
  });
38
39
  const instance = tree.root;
39
- const modal = instance.findAllByType(Modal);
40
+ const modal = instance.findAllByType(ModalCustom);
40
41
  await act(async () => {
41
42
  modal[0].props.onBackButtonPress();
42
43
  });
@@ -48,7 +49,15 @@ describe('Test Header', () => {
48
49
  tree = renderer.create(wrapComponent());
49
50
  });
50
51
  const instance = tree.root;
51
- const modal = instance.findAllByType(Modal);
52
+ const modal = instance.findAllByType(ModalCustom);
53
+
54
+ const headerCustom = instance.findByType(HeaderCustom);
55
+ const touchableOpacity = headerCustom.findAllByType(TouchableOpacity);
56
+ await act(async () => {
57
+ touchableOpacity[1].props.onPress();
58
+ });
59
+ expect(modal[0].props.isVisible).toBeTruthy();
60
+
52
61
  const imageButton = instance.findByType(ImageButton);
53
62
  await act(async () => {
54
63
  imageButton.props.onPress(Routes.Sharing);
@@ -73,16 +82,12 @@ describe('Test Header', () => {
73
82
  tree = renderer.create(wrapComponent());
74
83
  });
75
84
  const instance = tree.root;
76
- const touchableOpacity = instance.findAllByType(TouchableOpacity);
85
+ const popover = instance.findByType(HeaderCustom);
86
+ const touchableOpacity = popover.findAllByType(TouchableOpacity);
77
87
 
78
88
  await act(async () => {
79
89
  touchableOpacity[0].props.onPress();
80
- touchableOpacity[1].props.onPress();
81
- touchableOpacity[2].props.onPress();
82
- touchableOpacity[3].props.onPress();
83
90
  });
84
- expect(touchableOpacity).toHaveLength(4);
85
- expect(touchableOpacity).toBeDefined();
86
91
  expect(mockedGoBack).toHaveBeenCalled();
87
92
  });
88
93
  });
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
2
+ import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
4
  import { SCProvider } from '../../../../context';
5
5
  import { mockSCStore } from '../../../../context/mockStore';
6
6
  import MyUnitDevice from '../MyUnitDevice';
7
7
  import ItemQuickAction from '../../../../commons/Action/ItemQuickAction';
8
+ import Text from '../../../../commons/Text';
8
9
 
9
10
  const mockNavigate = jest.fn();
10
11
  jest.mock('@react-navigation/native', () => {
@@ -50,8 +51,6 @@ describe('Test MyUnitDevice', () => {
50
51
  tree = await create(wrapComponent(props));
51
52
  });
52
53
  const instance = tree.root;
53
- const Views = instance.findAllByType(View);
54
- expect(Views).toHaveLength(11);
55
54
 
56
55
  const touches = instance.findAllByType(TouchableOpacity);
57
56
  expect(touches).toHaveLength(1);
@@ -67,8 +66,8 @@ describe('Test MyUnitDevice', () => {
67
66
  tree = await create(wrapComponent(props));
68
67
  });
69
68
  const instance = tree.root;
70
- const Views = instance.findAllByType(View);
71
- expect(Views).toHaveLength(11);
69
+ const text = instance.findAllByType(Text)[1];
70
+ expect(text.props.children).toEqual(['', '']);
72
71
  });
73
72
 
74
73
  it('Test render with quick action', async () => {
@@ -18,7 +18,6 @@ const Routes = {
18
18
  SmartIrStack: 'SmartIrStack',
19
19
  EditSubUnit: 'EditSubUnit',
20
20
  Language: 'Language',
21
- MyAllUnit: 'MyAllUnit',
22
21
  SubUnit: 'SubUnit',
23
22
  SubUnitDetail: 'SubUnitDetail',
24
23
  DeviceDetail: 'DeviceDetail',
@@ -182,7 +181,7 @@ const Routes = {
182
181
  SuccessfullyConnected: 'SuccessfullyConnected',
183
182
  AllGatewayStack: 'AllGatewayStack',
184
183
  AllGateway: 'AllGateway',
185
- DetailConfigActionInterval: 'DetailConfigActionInterval',
184
+ DetailConfigActionInternal: 'DetailConfigActionInternal',
186
185
  DeviceInternalDetail: 'DeviceInternalDetail',
187
186
  };
188
187
 
@@ -1,8 +1,24 @@
1
1
  import { PixelRatio, Linking, Alert } from 'react-native';
2
2
  import Toast from 'react-native-toast-message';
3
3
  import validator from 'validator';
4
- import { Constants } from '../configs';
5
4
  import api from './Apis/axios';
5
+ import {
6
+ ESP32_DIGITAL,
7
+ ESP32_ANALOG_READ,
8
+ ESP32_ANALOG_WRITE,
9
+ RASPBERRY_PI_DIGITAL,
10
+ RASPBERRY_PI_ANALOG_WRITE,
11
+ RASPBERRY_PI_ANALOG_READ,
12
+ STM32_DIGITAL_READ,
13
+ STM32_ANALOG_READ,
14
+ STM32_DIGITAL_WRITE,
15
+ STM32_ANALOG_WRITE,
16
+ READ_DIGITAL_PIN_MODE,
17
+ READ_ANALOG_PIN_MODE,
18
+ WRITE_DIGITAL_PIN_MODE,
19
+ WRITE_ANALOG_PIN_MODE,
20
+ LANGUAGE,
21
+ } from '../configs/IOPinConstants';
6
22
 
7
23
  export const setAxiosDefaultAuthToken = (token) => {
8
24
  api.setHeaders({ Authorization: `Token ${token}` });
@@ -10,7 +26,7 @@ export const setAxiosDefaultAuthToken = (token) => {
10
26
 
11
27
  export const setAxiosDefaultLanguage = (language) => {
12
28
  api.setHeaders({
13
- 'Accept-Language': language || Constants.LANGUAGE.DEFAULT,
29
+ 'Accept-Language': language || LANGUAGE.DEFAULT,
14
30
  });
15
31
  };
16
32
 
@@ -140,6 +156,50 @@ export const roundNumber = (value, round = 2) => {
140
156
  return value;
141
157
  };
142
158
 
159
+ export const PIN_MODE_MAPPING = {
160
+ read: {
161
+ boolean: READ_DIGITAL_PIN_MODE,
162
+ integer: READ_ANALOG_PIN_MODE,
163
+ },
164
+ write: {
165
+ boolean: WRITE_DIGITAL_PIN_MODE,
166
+ integer: WRITE_ANALOG_PIN_MODE,
167
+ },
168
+ };
169
+
170
+ export const PIN_MAPPING = {
171
+ esp32: {
172
+ read: {
173
+ boolean: ESP32_DIGITAL,
174
+ integer: ESP32_ANALOG_READ,
175
+ },
176
+ write: {
177
+ boolean: ESP32_DIGITAL,
178
+ integer: ESP32_ANALOG_WRITE,
179
+ },
180
+ },
181
+ stm32: {
182
+ read: {
183
+ boolean: STM32_DIGITAL_READ,
184
+ integer: STM32_ANALOG_READ,
185
+ },
186
+ write: {
187
+ boolean: STM32_DIGITAL_WRITE,
188
+ integer: STM32_ANALOG_WRITE,
189
+ },
190
+ },
191
+ raspberry_pi: {
192
+ read: {
193
+ boolean: RASPBERRY_PI_DIGITAL,
194
+ integer: RASPBERRY_PI_ANALOG_READ,
195
+ },
196
+ write: {
197
+ boolean: RASPBERRY_PI_DIGITAL,
198
+ integer: RASPBERRY_PI_ANALOG_WRITE,
199
+ },
200
+ },
201
+ };
202
+
143
203
  export default {
144
204
  validateEmail,
145
205
  isObjectEmpty,
@@ -1,49 +0,0 @@
1
- import * as React from 'react';
2
- import { Easing, Animated } from 'react-native';
3
- import { useEffect, useMemo, useRef } from 'react';
4
- import { AccessibilityLabel } from '../../../configs/Constants';
5
-
6
- function SvgComponent(props) {
7
- const rotateValue = useRef(new Animated.Value(0)).current;
8
- useEffect(() => {
9
- Animated.loop(
10
- Animated.timing(rotateValue, {
11
- toValue: 1,
12
- duration: 2000,
13
- easing: Easing.linear,
14
- useNativeDriver: true,
15
- }),
16
- { iterations: -1 }
17
- ).start();
18
- }, [rotateValue]);
19
-
20
- const rotate = useMemo(
21
- () =>
22
- rotateValue.interpolate({
23
- inputRange: [0, 1],
24
- outputRange: ['0deg', '360deg'],
25
- }),
26
- [rotateValue]
27
- );
28
- const style = {
29
- height: 16,
30
- width: 16,
31
- transform: [
32
- {
33
- rotate: rotate,
34
- },
35
- ],
36
- };
37
-
38
- return (
39
- <Animated.View
40
- style={style}
41
- accessibilityLabel={AccessibilityLabel.COMMON_LOADING_ANIMATION}
42
- >
43
- {props.icon}
44
- </Animated.View>
45
- );
46
- }
47
-
48
- const SvgActivityIndicator = React.memo(SvgComponent);
49
- export default SvgActivityIndicator;
@@ -1,116 +0,0 @@
1
- import React, { memo, useCallback } from 'react';
2
- import { View, Image, StyleSheet, TouchableOpacity } from 'react-native';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
-
5
- import { Colors } from '../../../configs';
6
- import Text from '../../../commons/Text';
7
- import { API } from '../../../configs';
8
- import Pin from '../../../../assets/images/Explore/Pin.svg';
9
- import Follower from '../../../../assets/images/Explore/Follower.svg';
10
- import PinOutline from '../../../../assets/images/Explore/PinOutline.svg';
11
- import { formatNumberCompact } from '../../../utils/Utils';
12
- import { axiosPost } from '../../../utils/Apis/axios';
13
-
14
- const CityItem = memo(({ item, onSelect }) => {
15
- const t = useTranslations();
16
- const { id, name, icon, is_pin, count_pin } = item;
17
-
18
- const onPressPinPublicUnit = useCallback(async () => {
19
- const { success } = await axiosPost(API.UNIT.PIN_UNIT(id));
20
- if (success) {
21
- //TODO remove redux
22
- //dispatch(pinPublicUnitSuccess(id));
23
- }
24
- }, [id]);
25
-
26
- const onPressUnPinPublicUnit = useCallback(async () => {
27
- const { success } = await axiosPost(API.UNIT.UNPIN_UNIT(id));
28
- if (success) {
29
- //TODO remove redux
30
- //dispatch(unpinPublicUnitSuccess(id));
31
- }
32
- }, [id]);
33
-
34
- return (
35
- <TouchableOpacity
36
- style={styles.container}
37
- onPress={onSelect}
38
- activeOpacity={0.4}
39
- >
40
- <View>
41
- <Image source={{ uri: icon || '' }} style={styles.image} />
42
- </View>
43
- <View style={styles.info}>
44
- <Text size={16} style={styles.textName}>
45
- {name}
46
- </Text>
47
- <View style={styles.pinView}>
48
- <Follower width={16} height={16} />
49
- <Text size={12} color={Colors.Gray8}>
50
- {`${formatNumberCompact(count_pin)}` + ` ${t('text_pins')}`}
51
- </Text>
52
- </View>
53
- </View>
54
- <TouchableOpacity activeOpacity={0.7} style={styles.pin}>
55
- {is_pin ? (
56
- <Pin onPress={onPressUnPinPublicUnit} width={24} height={24} />
57
- ) : (
58
- <PinOutline onPress={onPressPinPublicUnit} width={24} height={24} />
59
- )}
60
- </TouchableOpacity>
61
- </TouchableOpacity>
62
- );
63
- });
64
- export default CityItem;
65
-
66
- const styles = StyleSheet.create({
67
- container: {
68
- flexDirection: 'row',
69
- paddingBottom: 8,
70
- borderBottomWidth: 1,
71
- borderBottomColor: Colors.Gray4,
72
- marginBottom: 17,
73
- marginHorizontal: 16,
74
- },
75
- image: {
76
- width: 54,
77
- height: 54,
78
- borderRadius: 5,
79
- },
80
- info: {
81
- flex: 1,
82
- marginLeft: 16,
83
- },
84
- textName: {
85
- color: Colors.Black,
86
- lineHeight: 24,
87
- marginBottom: 2,
88
- },
89
- pinView: {
90
- flexDirection: 'row',
91
- alignItems: 'center',
92
- marginBottom: 6,
93
- },
94
- weatherInfo: {
95
- flexDirection: 'row',
96
- },
97
- rowInfo: {
98
- marginRight: 24,
99
- },
100
- value: {
101
- color: Colors.Black,
102
- lineHeight: 24,
103
- },
104
- weatherAttribute: {
105
- lineHeight: 20,
106
- },
107
- qualityEvaluate: {
108
- lineHeight: 24,
109
- },
110
- pin: {
111
- padding: 4,
112
- height: 32,
113
- marginTop: -4,
114
- marginRight: -4,
115
- },
116
- });
@@ -1,44 +0,0 @@
1
- import React, { memo } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
- import Theme from '../../../configs/Theme';
5
-
6
- import { Colors } from '../../../configs';
7
- import Text from '../../../commons/Text';
8
- import { useSCContextSelector } from '../../../context';
9
-
10
- const HeaderExplore = memo(() => {
11
- const t = useTranslations();
12
- useSCContextSelector((state) => state.language);
13
- return (
14
- <View style={styles.container}>
15
- <Text size={20} semibold={true} style={styles.textTitle}>
16
- {t('text_explore')}
17
- </Text>
18
- {/* <SearchBox onFocusInput={onFocusTextInput} /> */}
19
- </View>
20
- );
21
- });
22
-
23
- export default HeaderExplore;
24
-
25
- const styles = StyleSheet.create({
26
- container: {
27
- paddingHorizontal: 16,
28
- paddingTop: 8,
29
- paddingBottom: 16,
30
- },
31
- textTitle: {
32
- lineHeight: 28,
33
- },
34
- searchBox: {
35
- ...Theme.flexRow,
36
- paddingHorizontal: 16,
37
- backgroundColor: Colors.White,
38
- borderWidth: 1,
39
- borderColor: Colors.Gray4,
40
- borderRadius: 5,
41
- marginTop: 8,
42
- height: 48,
43
- },
44
- });
@@ -1,46 +0,0 @@
1
- import React, { memo } from 'react';
2
- import { View, StyleSheet, TouchableOpacity } from 'react-native';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
-
5
- import { Colors } from '../../../configs';
6
- import Text from '../../../commons/Text';
7
-
8
- const HeaderLabel = memo(({ title, style, onPress, seeMore }) => {
9
- const t = useTranslations();
10
- return (
11
- <View style={[styles.labelHeader, style]}>
12
- <Text fontSize={14} color={Colors.Gray8} style={styles.textLineHeight}>
13
- {title}
14
- </Text>
15
- {seeMore && (
16
- <TouchableOpacity onPress={onPress} style={styles.btnStyle}>
17
- <Text
18
- fontSize={14}
19
- color={Colors.Primary}
20
- style={styles.textLineHeight}
21
- >
22
- {t('see_more')}
23
- </Text>
24
- </TouchableOpacity>
25
- )}
26
- </View>
27
- );
28
- });
29
-
30
- const styles = StyleSheet.create({
31
- labelHeader: {
32
- flexDirection: 'row',
33
- justifyContent: 'space-between',
34
- },
35
- textLineHeight: {
36
- lineHeight: 20,
37
- },
38
- btnStyle: {
39
- marginTop: -8,
40
- marginBottom: -8,
41
- paddingTop: 8,
42
- paddingBottom: 8,
43
- },
44
- });
45
-
46
- export default HeaderLabel;
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import { View, Image, StyleSheet, TouchableOpacity } from 'react-native';
3
-
4
- import Text from '../../../commons/Text';
5
- import { Colors } from '../../../configs';
6
-
7
- const LocationItem = ({ item, onPress, margin }) => {
8
- return (
9
- <TouchableOpacity
10
- style={[styles.container, { marginTop: margin, marginLeft: margin }]}
11
- onPress={onPress}
12
- >
13
- <Image source={{ uri: item.background || '' }} style={styles.image} />
14
- <View style={styles.contentView}>
15
- <Text
16
- size={14}
17
- semibold={true}
18
- style={styles.textMargin}
19
- numberOfLines={1}
20
- >
21
- {item.name || ''}
22
- </Text>
23
- <Text
24
- numberOfLines={2}
25
- size={12}
26
- color={Colors.Gray8}
27
- style={styles.textAddress}
28
- >
29
- {item.address || ''}
30
- </Text>
31
- <Text color={Colors.Orange} size={14} style={styles.textMargin}>
32
- {item.distance || ''}
33
- </Text>
34
- </View>
35
- </TouchableOpacity>
36
- );
37
- };
38
-
39
- export default LocationItem;
40
-
41
- const styles = StyleSheet.create({
42
- container: {
43
- width: 167,
44
- height: 200,
45
- paddingBottom: 8,
46
- borderRadius: 10,
47
- borderWidth: 1,
48
- borderColor: Colors.Gray4,
49
- marginRight: 8,
50
- backgroundColor: Colors.White,
51
- },
52
- textMargin: {
53
- lineHeight: 22,
54
- marginTop: 8,
55
- },
56
- image: {
57
- width: 167,
58
- height: 80,
59
- borderTopLeftRadius: 10,
60
- borderTopRightRadius: 10,
61
- },
62
- contentView: {
63
- paddingHorizontal: 12,
64
- justifyContent: 'space-between',
65
- flexDirection: 'column',
66
- flex: 1,
67
- },
68
- textAddress: {
69
- lineHeight: 20,
70
- },
71
- });
@@ -1,58 +0,0 @@
1
- import SearchBox from '../index';
2
- import React from 'react';
3
- import { TouchableOpacity } from 'react-native';
4
- import renderer, { act } from 'react-test-renderer';
5
- import { SCProvider } from '../../../../context';
6
- import { mockSCStore } from '../../../../context/mockStore';
7
- import { TextInput } from 'react-native';
8
- import { AccessibilityLabel } from '../../../../configs/Constants';
9
-
10
- const mockedNavigate = jest.fn();
11
-
12
- const wrapComponent = () => (
13
- <SCProvider initState={mockSCStore({})}>
14
- <SearchBox isBack={true} />
15
- </SCProvider>
16
- );
17
-
18
- jest.mock('@react-navigation/native', () => {
19
- return {
20
- ...jest.requireActual('@react-navigation/native'),
21
- useNavigation: () => ({
22
- goBack: mockedNavigate,
23
- }),
24
- };
25
- });
26
-
27
- describe('Test SearchBox', () => {
28
- let wrapper;
29
- it('SearchBox render', async () => {
30
- await act(async () => {
31
- wrapper = renderer.create(wrapComponent());
32
- });
33
- const instance = wrapper.root;
34
- const button = instance.findByType(TouchableOpacity);
35
-
36
- await act(async () => {
37
- button.props.onPress();
38
- });
39
- expect(mockedNavigate.mock.calls.length).toBe(1);
40
- });
41
-
42
- it('Onfocus searchBox', async () => {
43
- await act(async () => {
44
- wrapper = renderer.create(wrapComponent());
45
- });
46
- const instance = wrapper.root;
47
- const textInput = instance.find(
48
- (item) =>
49
- item.props.accessibilityLabel ===
50
- AccessibilityLabel.ON_FOCUS_SEARCH_B0X && item.type === TextInput
51
- );
52
-
53
- await act(async () => {
54
- textInput.props.onFocus();
55
- });
56
- expect(textInput).toBeDefined();
57
- });
58
- });