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

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 (177) hide show
  1. package/index.js +0 -2
  2. package/package.json +4 -5
  3. package/src/Images/ThreeButton/buttonCircleBig.png +0 -0
  4. package/src/Images/ThreeButton/buttonCircleSmall.png +0 -0
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  7. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
  9. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -3
  10. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
  11. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +52 -0
  12. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +52 -0
  13. package/src/commons/ActionGroup/{__test__ → ThreeButtonTemplate/__test__}/ThreeButtonTemplate.test.js +21 -8
  14. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonCircle.js +103 -0
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonCircleStyles.js +31 -0
  16. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefault.js +96 -0
  17. package/src/commons/ActionGroup/{ThreeButtonTemplateStyle.js → ThreeButtonTemplate/components/ThreeButtonDefaultStyles.js} +11 -34
  18. package/src/commons/ActionGroup/{ThreeButtonTemplate.js → ThreeButtonTemplate/index.js} +48 -51
  19. package/src/commons/ActionGroup/ThreeButtonTemplate/styles.js +27 -0
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
  21. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +39 -34
  22. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +1 -1
  23. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
  24. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
  25. package/src/commons/ActionGroup/__test__/index.test.js +24 -16
  26. package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
  27. package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
  28. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  29. package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
  30. package/src/commons/CameraDevice/index.js +37 -22
  31. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
  32. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  33. package/src/commons/Device/ConnectedViewHeader.js +2 -1
  34. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  35. package/src/commons/Device/DisconnectedView.js +10 -14
  36. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  37. package/src/commons/Device/HorizontalBarChart.js +1 -1
  38. package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
  39. package/src/commons/Device/LinearChart.js +5 -1
  40. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  41. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  42. package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
  43. package/src/commons/Device/WindDirection/Compass/index.js +15 -23
  44. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
  45. package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
  46. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
  47. package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
  48. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  49. package/src/commons/DisplayChecking/index.js +4 -3
  50. package/src/commons/DisplayChecking/styles.js +2 -2
  51. package/src/commons/MediaPlayer/index.js +2 -1
  52. package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
  53. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
  54. package/src/commons/MediaPlayerDetail/index.js +2 -3
  55. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
  56. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
  57. package/src/commons/MenuActionList/index.js +8 -70
  58. package/src/commons/MenuActionList/styles.js +68 -0
  59. package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
  60. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
  61. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
  62. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
  63. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
  64. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
  65. package/src/commons/PreventAccess/index.js +3 -3
  66. package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
  67. package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
  68. package/src/commons/SubUnit/OneTap/index.js +6 -1
  69. package/src/commons/Today/__test__/Today.test.js +3 -3
  70. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  71. package/src/configs/IOPinConstants.js +285 -0
  72. package/src/configs/SCConfig.js +3 -0
  73. package/src/hooks/IoT/useBluetoothConnection.js +2 -1
  74. package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
  75. package/src/navigations/AllGatewayStack.js +3 -3
  76. package/src/navigations/UnitStack.js +0 -6
  77. package/src/screens/ActivityLog/__test__/index.test.js +16 -22
  78. package/src/screens/ActivityLog/index.js +2 -3
  79. package/src/screens/AddLocationMaps/index.js +1 -1
  80. package/src/screens/AddNewAction/SelectAction.js +3 -0
  81. package/src/screens/AddNewAction/SetupSensor.js +3 -3
  82. package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
  83. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
  84. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +4 -1
  85. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
  86. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
  87. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
  88. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
  89. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
  90. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  91. package/src/screens/AllCamera/index.js +1 -1
  92. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
  93. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
  94. package/src/screens/AllGateway/DetailConfigActionModbus/index.js +6 -4
  95. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
  96. package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
  97. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
  98. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
  99. package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
  100. package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +4 -1
  101. package/src/screens/AllGateway/GatewayConnectionMethods/index.js +4 -2
  102. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
  103. package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
  104. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +2 -1
  105. package/src/screens/AllGateway/components/Information/__test__/index.test.js +2 -1
  106. package/src/screens/AllGateway/components/Information/index.js +4 -2
  107. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  108. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  109. package/src/screens/AllGateway/hooks/useGateway.js +1 -0
  110. package/src/screens/AllGateway/test-utils.js +20 -0
  111. package/src/screens/Device/__test__/detail.test.js +8 -3
  112. package/src/screens/Device/components/SensorDisplayItem.js +1 -5
  113. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
  114. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
  115. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
  116. package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
  117. package/src/screens/GuestInfo/__test__/index.test.js +26 -14
  118. package/src/screens/GuestInfo/index.js +2 -2
  119. package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
  120. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
  121. package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
  122. package/src/screens/PlayBackCamera/Timer.js +2 -3
  123. package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
  124. package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
  125. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
  126. package/src/screens/SharedUnit/index.js +19 -17
  127. package/src/screens/Sharing/InfoMemberUnit.js +2 -2
  128. package/src/screens/SmartAccount/Connecting/index.js +2 -2
  129. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
  130. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
  131. package/src/screens/SmartAccount/ListDevice/index.js +1 -1
  132. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
  133. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
  134. package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
  135. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
  136. package/src/screens/SubUnit/EditSubUnit.js +6 -6
  137. package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
  138. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
  139. package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
  140. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
  141. package/src/screens/Template/EditTemplate.js +13 -3
  142. package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
  143. package/src/screens/Unit/Detail.js +157 -121
  144. package/src/screens/Unit/ManageUnit.js +3 -3
  145. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  146. package/src/screens/Unit/SelectAddress.js +1 -1
  147. package/src/screens/Unit/__test__/Detail.test.js +40 -20
  148. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
  149. package/src/screens/Unit/components/AutomateScript/index.js +9 -8
  150. package/src/screens/Unit/components/Header/index.js +1 -14
  151. package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
  152. package/src/screens/Unit/components/__test__/Header.test.js +14 -9
  153. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
  154. package/src/utils/I18n/translations/en.json +13 -12
  155. package/src/utils/I18n/translations/vi.json +12 -11
  156. package/src/utils/Route/index.js +1 -2
  157. package/src/utils/Utils.js +62 -2
  158. package/src/commons/Explore/ActivityIndicator/index.js +0 -49
  159. package/src/commons/Explore/CityItem/index.js +0 -116
  160. package/src/commons/Explore/HeaderExplore/index.js +0 -44
  161. package/src/commons/Explore/HeaderLabel/index.js +0 -46
  162. package/src/commons/Explore/LocationItem/index.js +0 -71
  163. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
  164. package/src/commons/Explore/SearchBox/index.js +0 -59
  165. package/src/commons/Explore/__test__/CityItem.test.js +0 -156
  166. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
  167. package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
  168. package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
  169. package/src/screens/Explore/__test__/Explore.test.js +0 -43
  170. package/src/screens/Explore/index.js +0 -201
  171. package/src/screens/Unit/MyAllUnit/index.js +0 -44
  172. package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
  173. package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
  174. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
  175. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  176. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  177. package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
@@ -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
- });
@@ -1,59 +0,0 @@
1
- import React, { memo, useCallback } from 'react';
2
- import { TextInput, View, StyleSheet, TouchableOpacity } from 'react-native';
3
- import { useNavigation } from '@react-navigation/native';
4
- import { useTranslations } from '../../../hooks/Common/useTranslations';
5
-
6
- import { Colors } from '../../../configs';
7
- import Theme from '../../../configs/Theme';
8
- import Search from '../../../../assets/images/Explore/Search.svg';
9
- import ArrowBack from '../../../../assets/images/Explore/ArrowBack.svg';
10
- import { AccessibilityLabel } from '../../../configs/Constants';
11
-
12
- const SearchBox = memo(({ isBack, style, onFocus }) => {
13
- const t = useTranslations();
14
- const { goBack } = useNavigation();
15
- const onBack = useCallback(() => {
16
- goBack();
17
- }, [goBack]);
18
- const onFocusInput = useCallback(() => {
19
- onFocus && onFocus();
20
- }, [onFocus]);
21
- return (
22
- <View style={[styles.searchBox, style]}>
23
- {isBack ? (
24
- <TouchableOpacity style={styles.backBtn} onPress={onBack}>
25
- <ArrowBack />
26
- </TouchableOpacity>
27
- ) : (
28
- <View>
29
- <Search />
30
- </View>
31
- )}
32
- <TextInput
33
- placeholder={t('text_search_location_placeholder')}
34
- placeholderTextColor={Colors.Gray7}
35
- style={Theme.textSearchInput}
36
- onFocus={onFocusInput}
37
- accessibilityLabel={AccessibilityLabel.ON_FOCUS_SEARCH_B0X}
38
- />
39
- </View>
40
- );
41
- });
42
-
43
- export default SearchBox;
44
- const styles = StyleSheet.create({
45
- searchBox: {
46
- ...Theme.flexRow,
47
- paddingHorizontal: 16,
48
- backgroundColor: Colors.White,
49
- borderWidth: 1,
50
- borderColor: Colors.Gray4,
51
- borderRadius: 5,
52
- marginTop: 8,
53
- height: 48,
54
- },
55
- backBtn: {
56
- padding: 12,
57
- marginHorizontal: -12,
58
- },
59
- });
@@ -1,156 +0,0 @@
1
- import React from 'react';
2
- import renderer, { act } from 'react-test-renderer';
3
- import CityItem from '../CityItem';
4
- import { TouchableOpacity } from 'react-native';
5
- import { API } from '../../../configs';
6
- import Pin from '../../../../assets/images/Explore/Pin.svg';
7
- import PinOutline from '../../../../assets/images/Explore/PinOutline.svg';
8
- import { SCProvider } from '../../../context';
9
- import { mockSCStore } from '../../../context/mockStore';
10
- import MockAdapter from 'axios-mock-adapter';
11
- import api from '../../../utils/Apis/axios';
12
-
13
- const mock = new MockAdapter(api.axiosInstance);
14
-
15
- const mockedDispatch = jest.fn();
16
-
17
- const wrapComponent = (item, mockeSelect) => (
18
- <SCProvider initState={mockSCStore({})}>
19
- <CityItem item={item} onSelect={mockeSelect} />
20
- </SCProvider>
21
- );
22
-
23
- jest.mock('react-redux', () => ({
24
- ...jest.requireActual('react-redux'),
25
- useDispatch: () => mockedDispatch,
26
- }));
27
-
28
- describe('Test CityItem', () => {
29
- let tree;
30
-
31
- it('render CityItem is_pin: true', async () => {
32
- const item = {
33
- id: 1,
34
- name: 'name',
35
- icon: 'icon',
36
- is_pin: true,
37
- count_pin: 1,
38
- };
39
- const mockeSelect = jest.fn();
40
- mock.onPost(API.UNIT.PIN_UNIT()).reply(200);
41
- await act(async () => {
42
- tree = await renderer.create(wrapComponent(item, mockeSelect));
43
- });
44
- const instance = tree.root;
45
- const buttons = instance.findAllByType(TouchableOpacity);
46
- expect(buttons.length).toBe(2);
47
- await buttons[0].props.onPress();
48
- expect(mockeSelect).toHaveBeenCalledTimes(1);
49
- const pin = instance.findAllByType(Pin);
50
- expect(pin.length).toBe(2);
51
- mock.onPost(API.UNIT.PIN_UNIT()).reply(200);
52
- await pin[1].props.onPress();
53
- const unpin = instance.findAllByType(PinOutline);
54
- mock.onPost(API.UNIT.UNPIN_UNIT(1)).reply(200);
55
- await unpin[1].props.onPress();
56
- expect(unpin.length).toBe(2);
57
- });
58
-
59
- it('render CityItem is_pin: false', async () => {
60
- const item = {
61
- id: 1,
62
- name: 'name',
63
- icon: 'icon',
64
- is_pin: false,
65
- count_pin: 1,
66
- };
67
- const mockeSelect = jest.fn();
68
- await act(async () => {
69
- tree = await renderer.create(wrapComponent(item, mockeSelect));
70
- });
71
- const instance = tree.root;
72
- const unpin = instance.findAllByType(PinOutline);
73
- mock.onPost(API.UNIT.PIN_UNIT(1)).reply(200);
74
- await unpin[1].props.onPress();
75
- expect(unpin.length).toBe(2);
76
- });
77
-
78
- it('render CityItem is_pin: false and call api false', async () => {
79
- const item = {
80
- id: 1,
81
- name: 'name',
82
- icon: 'icon',
83
- is_pin: false,
84
- count_pin: 1,
85
- };
86
- const mockeSelect = jest.fn();
87
- await act(async () => {
88
- tree = await renderer.create(wrapComponent(item, mockeSelect));
89
- });
90
- const instance = tree.root;
91
- const unpin = instance.findAllByType(PinOutline);
92
- mock.onPost(API.UNIT.PIN_UNIT(1)).reply(400);
93
- await unpin[1].props.onPress();
94
- expect(unpin.length).toBe(2);
95
- });
96
-
97
- it('render CityItem PinOutline axios.post response false', async () => {
98
- const item = {
99
- id: 1,
100
- name: 'name',
101
- icon: 'icon',
102
- is_pin: false,
103
- count_pin: 1,
104
- };
105
- const mockeSelect = jest.fn();
106
- mock.onPost(API.UNIT.PIN_UNIT()).reply(200, {});
107
- await act(async () => {
108
- tree = await renderer.create(wrapComponent(item, mockeSelect));
109
- });
110
- const instance = tree.root;
111
- const unpin = instance.findAllByType(PinOutline);
112
- await unpin[1].props.onPress();
113
- expect(unpin.length).toBe(2);
114
- });
115
-
116
- it('render CityItem Pin axios.post response false', async () => {
117
- const item = {
118
- id: 1,
119
- name: 'name',
120
- icon: 'icon',
121
- is_pin: true,
122
- count_pin: 1,
123
- };
124
- const mockeSelect = jest.fn();
125
- mock.onPost(API.UNIT.UNPIN_UNIT(1)).reply(400, {});
126
- await act(async () => {
127
- tree = await renderer.create(wrapComponent(item, mockeSelect));
128
- });
129
- const instance = tree.root;
130
- const pin = instance.findAllByType(Pin);
131
- await pin[1].props.onPress();
132
- expect(pin.length).toBe(2);
133
- });
134
-
135
- it('render CityItem icon null', async () => {
136
- const item = {
137
- id: 1,
138
- name: 'name',
139
- icon: '',
140
- is_pin: false,
141
- count_pin: 1,
142
- };
143
- const mockeSelect = jest.fn();
144
-
145
- await act(async () => {
146
- tree = await renderer.create(wrapComponent(item, mockeSelect));
147
- });
148
- const instance = tree.root;
149
- const buttons = instance.findAllByType(TouchableOpacity);
150
- expect(buttons.length).toBe(2);
151
- await act(async () => {
152
- await buttons[0].props.onPress();
153
- });
154
- expect(mockeSelect).toHaveBeenCalledTimes(1);
155
- });
156
- });