@eohjsc/react-native-smart-city 0.2.19 → 0.2.23

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 (242) hide show
  1. package/assets/images/Add.svg +5 -0
  2. package/assets/images/AddLocationMaps/Point.svg +3 -0
  3. package/assets/images/CheckCircle.svg +4 -0
  4. package/assets/images/Close.svg +3 -0
  5. package/assets/images/Event.svg +9 -0
  6. package/assets/images/HowToStart.svg +14 -0
  7. package/assets/images/OneTap.svg +14 -0
  8. package/assets/images/Rearrange.svg +3 -0
  9. package/assets/images/Schedule.svg +39 -0
  10. package/assets/images/WeatherChange.svg +49 -0
  11. package/index.js +2 -0
  12. package/package.json +7 -4
  13. package/src/Images/Common/ActiveButton.png +0 -0
  14. package/src/Images/Common/ActiveButton@2x.png +0 -0
  15. package/src/Images/Common/ActiveButton@3x.png +0 -0
  16. package/src/Images/Common/file@2x.png +0 -0
  17. package/src/Images/Common/file@3x.png +0 -0
  18. package/src/Images/Common/fullscreen@2x.png +0 -0
  19. package/src/Images/Common/fullscreen@3x.png +0 -0
  20. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -3
  21. package/src/commons/ActionGroup/StatesGridActionTemplate.js +10 -1
  22. package/src/commons/ActionGroup/ThreeButtonTemplate.js +13 -6
  23. package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +1 -1
  24. package/src/commons/ActionGroup/TimerActionTemplate.js +158 -33
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +2 -1
  26. package/src/commons/ActionGroup/hooks/useDropdownAction.js +2 -1
  27. package/src/commons/Automate/ItemAddNewScriptAction.js +30 -0
  28. package/src/commons/Automate/ItemAddNewScriptActionStyles.js +38 -0
  29. package/src/commons/Automate/ItemAutomate.js +63 -0
  30. package/src/commons/Automate/ItemAutomateStyles.js +30 -0
  31. package/src/commons/Automate/ItemScriptAction.js +41 -0
  32. package/src/commons/Automate/ItemScriptActionStyles.js +38 -0
  33. package/src/commons/BottomScrollPicker/index.js +58 -0
  34. package/src/commons/BottomScrollPicker/styles.js +13 -0
  35. package/src/commons/BottomSheet/index.js +36 -0
  36. package/src/commons/BottomSheet/styles.js +37 -0
  37. package/src/commons/Button/index.js +6 -1
  38. package/src/commons/CameraDevice/index.js +22 -10
  39. package/src/commons/ChartLoading/index.js +2 -1
  40. package/src/commons/DateTimeRangeChange/index.js +2 -1
  41. package/src/commons/Device/ConnectedViewHeader.js +3 -1
  42. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  43. package/src/commons/Device/DisconnectedView.js +34 -26
  44. package/src/commons/Device/Emergency/EmergencyButton.js +2 -1
  45. package/src/commons/Device/Emergency/EmergencyDetail.js +2 -1
  46. package/src/commons/Device/FlatListItems.js +2 -1
  47. package/src/commons/Device/FooterInfo.js +2 -1
  48. package/src/commons/Device/HistoryChart.js +2 -1
  49. package/src/commons/Device/HorizontalBarChart.js +3 -3
  50. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +7 -2
  51. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -1
  52. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +3 -1
  53. package/src/commons/Device/SensorConnectedStatus.js +2 -1
  54. package/src/commons/Device/WindDirection/Compass/index.js +1 -1
  55. package/src/commons/Device/WindSpeed/LinearChart/index.js +2 -1
  56. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +2 -1
  57. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -1
  58. package/src/commons/EmergencyButton/AlertSent.js +3 -2
  59. package/src/commons/Explore/CityItem/index.js +2 -1
  60. package/src/commons/Explore/HeaderExplore/index.js +2 -1
  61. package/src/commons/Explore/HeaderLabel/index.js +2 -1
  62. package/src/commons/Explore/SearchBox/index.js +2 -1
  63. package/src/commons/Header/HeaderCustom.js +36 -10
  64. package/src/commons/Header/Styles/HeaderCustomStyles.js +8 -3
  65. package/src/commons/HeaderAni/index.js +6 -3
  66. package/src/commons/IconComponent/index.js +18 -3
  67. package/src/commons/ImagePicker/index.js +3 -1
  68. package/src/commons/MediaPlayer/index.js +118 -62
  69. package/src/commons/MediaPlayer/styles.js +56 -0
  70. package/src/commons/MediaPlayerDetail/MediaPlayerDetailStyles.js +15 -0
  71. package/src/commons/MediaPlayerDetail/index.js +149 -64
  72. package/src/commons/MenuActionAddnew/index.js +2 -1
  73. package/src/commons/Modal/ModalCustom.js +22 -0
  74. package/src/commons/Modal/ModalFullVideo.js +48 -0
  75. package/src/commons/Modal/Styles/ModalFullVideoStyles.js +26 -0
  76. package/src/commons/Modal/index.js +4 -0
  77. package/src/commons/NavBar/index.js +2 -2
  78. package/src/commons/Sharing/DevicePermissionsCheckbox.js +2 -1
  79. package/src/commons/Sharing/MemberList.js +3 -1
  80. package/src/commons/Sharing/RowMember.js +3 -2
  81. package/src/commons/Sharing/StationDevicePermissions.js +2 -1
  82. package/src/commons/SubUnit/OneTap/ItemOneTap.js +86 -0
  83. package/src/commons/SubUnit/OneTap/ItemOneTapStyles.js +41 -0
  84. package/src/commons/SubUnit/OneTap/OneTapStyles.js +36 -0
  85. package/src/commons/SubUnit/OneTap/index.js +29 -0
  86. package/src/commons/SubUnit/ShortDetail.js +3 -1
  87. package/src/commons/Today/index.js +2 -1
  88. package/src/commons/Unit/SharedUnit.js +2 -1
  89. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -2
  90. package/src/commons/UnitSummary/AirQuality/index.js +5 -120
  91. package/src/commons/UnitSummary/AirQuality/styles.js +112 -0
  92. package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -1
  93. package/src/commons/WheelDateTimePicker/Picker.js +57 -0
  94. package/src/commons/WheelDateTimePicker/index.js +160 -0
  95. package/src/commons/WheelDateTimePicker/styles.js +21 -0
  96. package/src/configs/API.js +25 -3
  97. package/src/configs/Colors.js +1 -0
  98. package/src/configs/Constants.js +4 -0
  99. package/src/configs/Images.js +4 -0
  100. package/src/configs/SCConfig.js +94 -0
  101. package/src/context/SCContext.tsx +5 -11
  102. package/src/context/reducer.ts +2 -0
  103. package/src/hooks/Common/useStatusBar.js +3 -0
  104. package/src/hooks/Common/useTranslations.ts +34 -0
  105. package/src/iot/Monitor.js +2 -1
  106. package/src/iot/RemoteControl/Bluetooth.js +2 -6
  107. package/src/iot/RemoteControl/GoogleHome.js +1 -1
  108. package/src/iot/RemoteControl/Internet.js +1 -1
  109. package/src/iot/RemoteControl/LG.js +57 -15
  110. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +2 -1
  111. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +2 -1
  112. package/src/iot/RemoteControl/__test__/Internet.test.js +2 -1
  113. package/src/iot/RemoteControl/__test__/index.test.js +2 -1
  114. package/src/iot/RemoteControl/index.js +1 -1
  115. package/src/iot/states.js +1 -0
  116. package/src/navigations/AddGatewayStack.js +5 -0
  117. package/src/navigations/AddNewActionStack.js +23 -0
  118. package/src/navigations/SharedStack.js +2 -1
  119. package/src/navigations/UnitStack.js +72 -1
  120. package/src/screens/AQIGuide/index.js +2 -2
  121. package/src/screens/ActivityLog/hooks/index.js +1 -1
  122. package/src/screens/ActivityLog/index.js +2 -1
  123. package/src/screens/AddCommon/SelectSubUnit.js +143 -0
  124. package/src/screens/AddCommon/SelectSubUnitStyles.js +55 -0
  125. package/src/screens/AddCommon/SelectUnit.js +3 -2
  126. package/src/screens/AddLocationMaps/index.js +2 -1
  127. package/src/screens/AddNewAction/Device/DeviceStyles.js +43 -0
  128. package/src/screens/AddNewAction/Device/index.js +33 -0
  129. package/src/screens/AddNewAction/SelectDevice.js +106 -0
  130. package/src/screens/AddNewAction/Styles/SelectDeviceStyles.js +36 -0
  131. package/src/screens/AddNewDevice/ConnectDevices.js +2 -1
  132. package/src/screens/AddNewDevice/ConnectingDevices.js +2 -1
  133. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +2 -1
  134. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +2 -1
  135. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +2 -1
  136. package/src/screens/AddNewDevice/hooks/useStateAlertRename.js +2 -1
  137. package/src/screens/AddNewDevice/index.js +23 -4
  138. package/src/screens/AddNewGateway/AddNewGatewayStyles.js +29 -0
  139. package/src/screens/AddNewGateway/ConnectedGateway.js +2 -1
  140. package/src/screens/AddNewGateway/ConnectingGateway.js +100 -25
  141. package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +92 -0
  142. package/src/screens/AddNewGateway/SetupGatewayWifi.js +25 -3
  143. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +6 -1
  144. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +2 -1
  145. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +2 -1
  146. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +2 -1
  147. package/src/screens/AddNewGateway/hooks/useStateAlertRename.js +2 -1
  148. package/src/screens/AddNewGateway/index.js +28 -110
  149. package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +43 -0
  150. package/src/screens/AddNewOneTap/index.js +67 -0
  151. package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +27 -0
  152. package/src/screens/AddNewScriptAction/index.js +92 -0
  153. package/src/screens/AllCamera/Styles/index.js +101 -0
  154. package/src/screens/AllCamera/index.js +208 -0
  155. package/src/screens/Device/HeaderDevice/styles.js +2 -2
  156. package/src/screens/Device/__test__/detail.test.js +2 -1
  157. package/src/screens/Device/detail.js +66 -23
  158. package/src/screens/Device/hooks/useEmergencyButton.js +7 -6
  159. package/src/screens/Device/styles.js +3 -0
  160. package/src/screens/DeviceInfo/index.js +3 -2
  161. package/src/screens/EditActionsList/Styles/indexStyles.js +73 -0
  162. package/src/screens/EditActionsList/index.js +122 -0
  163. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -2
  164. package/src/screens/EmergencyContacts/EmergencyContactsList.js +9 -2
  165. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
  166. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +2 -1
  167. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -1
  168. package/src/screens/EmergencyContacts/hook.js +3 -2
  169. package/src/screens/Explore/index.js +3 -2
  170. package/src/screens/GuestInfo/components/AccessScheduleItem.js +27 -0
  171. package/src/screens/GuestInfo/components/AccessScheduleSheet.js +193 -0
  172. package/src/screens/GuestInfo/components/HeaderGuestInfo.js +31 -0
  173. package/src/screens/GuestInfo/components/RecurringDetail.js +99 -0
  174. package/src/screens/GuestInfo/components/RowGuestInfo.js +31 -0
  175. package/src/screens/GuestInfo/components/TemporaryDetail.js +46 -0
  176. package/src/screens/GuestInfo/constant.js +59 -0
  177. package/src/screens/GuestInfo/index.js +151 -0
  178. package/src/screens/GuestInfo/styles/AccessScheduleDetailStyles.js +31 -0
  179. package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +22 -0
  180. package/src/screens/GuestInfo/styles/HeaderGuestInfoStyles.js +31 -0
  181. package/src/screens/GuestInfo/styles/indexStyles.js +38 -0
  182. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +82 -0
  183. package/src/screens/ManageAccess/hooks/index.js +32 -0
  184. package/src/screens/ManageAccess/index.js +126 -0
  185. package/src/screens/ManageAccess/styles/ManageAccessStyles.js +72 -0
  186. package/src/screens/PlayBackCamera/Styles/TimerStyles.js +22 -0
  187. package/src/screens/PlayBackCamera/Styles/index.js +81 -0
  188. package/src/screens/PlayBackCamera/Timer.js +127 -0
  189. package/src/screens/PlayBackCamera/index.js +233 -0
  190. package/src/screens/ScanChipQR/components/QRScan/index.js +2 -1
  191. package/src/screens/ScanChipQR/hooks/index.js +4 -11
  192. package/src/screens/ScriptDetail/Styles/indexStyles.js +140 -0
  193. package/src/screens/ScriptDetail/index.js +241 -0
  194. package/src/screens/SharedUnit/TabHeader.js +2 -1
  195. package/src/screens/SharedUnit/index.js +3 -2
  196. package/src/screens/Sharing/MemberList.js +2 -1
  197. package/src/screens/Sharing/SelectPermission.js +2 -1
  198. package/src/screens/Sharing/SelectUser.js +3 -2
  199. package/src/screens/Sharing/__test__/MemberList.test.js +2 -1
  200. package/src/screens/Sharing/__test__/SelectUser.test.js +2 -1
  201. package/src/screens/Sharing/hooks/index.js +22 -17
  202. package/src/screens/SubUnit/AddSubUnit.js +14 -72
  203. package/src/screens/SubUnit/AddSubUnitStyles.js +66 -0
  204. package/src/screens/SubUnit/Detail.js +5 -63
  205. package/src/screens/SubUnit/DetailStyles.js +46 -0
  206. package/src/screens/SubUnit/ManageSubUnit.js +5 -4
  207. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +2 -1
  208. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +2 -1
  209. package/src/screens/SyncLGDevice/AddLGDevice.js +3 -2
  210. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +2 -1
  211. package/src/screens/TDSGuide/index.js +2 -1
  212. package/src/screens/UVIndexGuide/index.js +2 -1
  213. package/src/screens/Unit/AddMenu.js +3 -2
  214. package/src/screens/Unit/Detail.js +75 -20
  215. package/src/screens/Unit/ManageUnit/index.js +4 -3
  216. package/src/screens/Unit/ManageUnit.js +4 -3
  217. package/src/screens/Unit/MoreMenu.js +3 -2
  218. package/src/screens/Unit/SelectLocation.js +10 -2
  219. package/src/screens/Unit/SelectLocationStyles.js +11 -0
  220. package/src/screens/Unit/components/Header/index.js +2 -1
  221. package/src/screens/Unit/components/ListMyAllUnit/index.js +2 -1
  222. package/src/screens/Unit/components/MyUnit/index.js +2 -1
  223. package/src/screens/Unit/components/SearchLocation/index.js +2 -1
  224. package/src/screens/Unit/components/SharedUnit/index.js +2 -1
  225. package/src/screens/Unit/styles.js +4 -0
  226. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
  227. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
  228. package/src/screens/UnitSummary/components/Temperature/index.js +2 -1
  229. package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -1
  230. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -1
  231. package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -1
  232. package/src/screens/UnitSummary/index.js +2 -1
  233. package/src/screens/WaterQualityGuide/index.js +2 -1
  234. package/src/utils/Converter/__test__/time.test.js +3 -1
  235. package/src/utils/Converter/array.js +4 -0
  236. package/src/utils/Converter/time.js +29 -4
  237. package/src/utils/I18n/index.ts +6 -0
  238. package/src/utils/I18n/translations/en.json +51 -2
  239. package/src/utils/I18n/translations/vi.json +48 -1
  240. package/src/utils/I18n/translations.ts +45 -0
  241. package/src/utils/Route/index.js +11 -0
  242. package/src/utils/I18n/index.js +0 -19
@@ -1,25 +1,21 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
- import { View, StyleSheet } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { get } from 'lodash';
5
- import { t } from 'i18n-js';
5
+ import { useTranslations } from '../../hooks/Common/useTranslations';
6
6
 
7
- import { Device, Colors, Theme } from '../../configs';
8
- import { standardizeCameraScreenSize } from '../../utils/Utils';
9
7
  import Routes from '../../utils/Route';
10
- import { useAndroidTranslucentStatusBar, usePopover } from '../../hooks/Common';
8
+ import { usePopover } from '../../hooks/Common';
11
9
  import Text from '../../commons/Text';
12
10
  import ItemDevice from '../../commons/Device/ItemDevice';
13
11
  import WrapParallaxScrollView from '../../commons/WrapParallaxScrollView';
14
12
  import MediaPlayer from '../../commons/MediaPlayer';
15
13
  import { MenuActionMore } from '../../commons';
16
14
  import { useSCContextSelector } from '../../context';
17
-
18
- const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
19
- Device.screenWidth - 32
20
- );
15
+ import styles from './DetailStyles';
21
16
 
22
17
  const SubUnitDetail = ({ route }) => {
18
+ const t = useTranslations();
23
19
  const { unit, station, isGGHomeConnected } = route.params;
24
20
  const language = useSCContextSelector((state) => state.language);
25
21
  const navigation = useNavigation();
@@ -33,21 +29,6 @@ const SubUnitDetail = ({ route }) => {
33
29
  const canManageSubUnit = useCallback(() => {
34
30
  return currentUserId === unit.user_id;
35
31
  }, [currentUserId, unit]);
36
-
37
- useAndroidTranslucentStatusBar();
38
-
39
- // TODO remove redux
40
- // const arrStation = useSelector((state) => state.unit.unitDetail.stations);
41
-
42
- // const checkID = useCallback(() => {
43
- // const result = arrStation.find((x) => x.id === station.id)
44
- // ? 'true'
45
- // : 'false';
46
- // return result;
47
- // }, [arrStation, station]);
48
- // const idExists = checkID();
49
- // const stationState =
50
- // idExists === 'true' ? arrStation.find((x) => x.id === station.id) : station;
51
32
  const stationState = station;
52
33
 
53
34
  const devices = stationState.sensors;
@@ -168,43 +149,4 @@ const SubUnitDetail = ({ route }) => {
168
149
  );
169
150
  };
170
151
 
171
- const styles = StyleSheet.create({
172
- wrap: {
173
- flex: 1,
174
- },
175
- boxCamera: {
176
- height: standardizeHeight,
177
- width: standardizeWidth,
178
- alignSelf: 'center',
179
- borderRadius: 10,
180
- ...Theme.shadow,
181
- },
182
- subUnitTitle: {
183
- fontSize: 20,
184
- lineHeight: 28,
185
- color: Colors.Gray8,
186
- marginLeft: 16,
187
- marginTop: 24,
188
- marginBottom: 8,
189
- },
190
- emptyDevice: {
191
- fontStyle: 'normal',
192
- fontWeight: 'normal',
193
- fontSize: 18,
194
- lineHeight: 28,
195
- color: Colors.Border,
196
- },
197
- boxDevices: {
198
- flexWrap: 'wrap',
199
- flexDirection: 'row',
200
- paddingHorizontal: 16,
201
- justifyContent: 'space-between',
202
- },
203
- boxEmptyDevices: {
204
- flexDirection: 'row',
205
- justifyContent: 'center',
206
- paddingTop: 16,
207
- },
208
- });
209
-
210
152
  export default SubUnitDetail;
@@ -0,0 +1,46 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Device, Colors, Theme } from '../../configs';
3
+ import { standardizeCameraScreenSize } from '../../utils/Utils';
4
+
5
+ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
6
+ Device.screenWidth - 32
7
+ );
8
+
9
+ export default StyleSheet.create({
10
+ wrap: {
11
+ flex: 1,
12
+ },
13
+ boxCamera: {
14
+ height: standardizeHeight,
15
+ width: standardizeWidth,
16
+ alignSelf: 'center',
17
+ borderRadius: 10,
18
+ ...Theme.shadow,
19
+ },
20
+ subUnitTitle: {
21
+ fontSize: 20,
22
+ lineHeight: 28,
23
+ color: Colors.Gray8,
24
+ marginLeft: 16,
25
+ marginTop: 24,
26
+ marginBottom: 8,
27
+ },
28
+ emptyDevice: {
29
+ fontStyle: 'normal',
30
+ fontWeight: 'normal',
31
+ fontSize: 18,
32
+ lineHeight: 28,
33
+ color: Colors.Border,
34
+ },
35
+ boxDevices: {
36
+ flexWrap: 'wrap',
37
+ flexDirection: 'row',
38
+ paddingHorizontal: 16,
39
+ justifyContent: 'space-between',
40
+ },
41
+ boxEmptyDevices: {
42
+ flexDirection: 'row',
43
+ justifyContent: 'center',
44
+ paddingTop: 16,
45
+ },
46
+ });
@@ -4,7 +4,7 @@ import Modal from 'react-native-modal';
4
4
  import { connect } from 'react-redux';
5
5
  import { useIsFocused, useNavigation } from '@react-navigation/native';
6
6
  import { SafeAreaView } from 'react-native-safe-area-context';
7
- import { t } from 'i18n-js';
7
+ import { useTranslations } from '../../hooks/Common/useTranslations';
8
8
 
9
9
  import { Colors, API, Device } from '../../configs';
10
10
  import { ToastBottomHelper } from '../../utils/Utils';
@@ -26,6 +26,7 @@ import { IconOutline } from '@ant-design/icons-react-native';
26
26
  import { useEmeragencyContacts } from './hooks/useEmergencyContacts';
27
27
 
28
28
  const ManageSubUnit = (props) => {
29
+ const t = useTranslations();
29
30
  const { station } = props.route.params;
30
31
  //TODO remove redux
31
32
  // const unit = useSelector((state) => state.unit.unitDetail);
@@ -82,7 +83,7 @@ const ManageSubUnit = (props) => {
82
83
  ToastBottomHelper.success(t('text_rename_sub_unit_success'));
83
84
  }
84
85
  },
85
- [unit, station]
86
+ [unit.id, station.id, t]
86
87
  );
87
88
  const updateBackground = useCallback(
88
89
  async (headers) => {
@@ -97,7 +98,7 @@ const ManageSubUnit = (props) => {
97
98
  ToastBottomHelper.success(t('text_change_background_sub_unit_success'));
98
99
  }
99
100
  },
100
- [unit, station, imageUrl]
101
+ [imageUrl, unit.id, station.id, t]
101
102
  );
102
103
 
103
104
  const onPressRemove = useCallback(() => {
@@ -120,7 +121,7 @@ const ManageSubUnit = (props) => {
120
121
  } else {
121
122
  ToastBottomHelper.error(t('text_remove_sub_unit_fail'));
122
123
  }
123
- }, [unit, station, onBack, setHideModalRemoveSubUnit]);
124
+ }, [setHideModalRemoveSubUnit, unit.id, station.id, t, onBack]);
124
125
 
125
126
  const goRename = useCallback(() => {
126
127
  updateSubUnit({ name: inputName }, {});
@@ -5,7 +5,7 @@ import { ImagePicker, ViewButtonBottom } from '../../../commons';
5
5
  import { act, create } from 'react-test-renderer';
6
6
  import Toast from 'react-native-toast-message';
7
7
  import Routes from '../../../utils/Route';
8
- import { t } from 'i18n-js';
8
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
9
9
  import { createSubUnit } from '../../../redux/Actions/unit';
10
10
  import { TESTID } from '../../../configs/Constants';
11
11
  import _TextInput from '../../../commons/Form/TextInput';
@@ -36,6 +36,7 @@ jest.mock('@react-navigation/native', () => {
36
36
  });
37
37
 
38
38
  describe('Test AddSubUnit', () => {
39
+ const t = useTranslations();
39
40
  let route;
40
41
 
41
42
  beforeEach(() => {
@@ -10,7 +10,7 @@ import Toast from 'react-native-toast-message';
10
10
 
11
11
  import Routes from '../../../utils/Route';
12
12
  import ManageSubUnit from '../ManageSubUnit';
13
- import { t } from 'i18n-js';
13
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
14
14
  import { removeSubUnit, manageSubUnit } from '../../../redux/Actions/unit';
15
15
  import { TESTID } from '../../../configs/Constants';
16
16
  import Text from '../../../commons/Text';
@@ -49,6 +49,7 @@ jest.mock('@react-navigation/native', () => {
49
49
  });
50
50
 
51
51
  describe('Test ManageSubUnit', () => {
52
+ const t = useTranslations();
52
53
  let route;
53
54
 
54
55
  beforeEach(() => {
@@ -1,7 +1,7 @@
1
1
  import React, { memo, useCallback, useEffect, useState } from 'react';
2
2
  import { ScrollView, SafeAreaView } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
- import { t } from 'i18n-js';
4
+ import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
 
6
6
  import styles from './AddLGDeviceStyles';
7
7
  import { API, Colors } from '../../configs';
@@ -15,6 +15,7 @@ import { ToastBottomHelper } from '../../utils/Utils';
15
15
  import { SCConfig } from '../../configs';
16
16
 
17
17
  const AddLGDevice = memo(({ route }) => {
18
+ const t = useTranslations();
18
19
  const { unit_id, code, backend_url } = route.params;
19
20
  const { navigate, goBack } = useNavigation();
20
21
  const [unit, setUnit] = useState({ stations: [] });
@@ -68,7 +69,7 @@ const AddLGDevice = memo(({ route }) => {
68
69
 
69
70
  ToastBottomHelper.success(t('lg_sync_success'));
70
71
  navigate(Routes.Dashboard);
71
- }, [backend_url, code, navigate, stationId]);
72
+ }, [backend_url, code, navigate, stationId, t]);
72
73
 
73
74
  const stations = unit.stations.map((item) => ({
74
75
  ...item,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import { t } from 'i18n-js';
3
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
4
4
  import axios from 'axios';
5
5
 
6
6
  import AddLGDevice from '../AddLGDevice';
@@ -27,6 +27,7 @@ jest.mock('@react-navigation/native', () => {
27
27
  });
28
28
 
29
29
  describe('Test Add LG Device', () => {
30
+ const t = useTranslations();
30
31
  let tree;
31
32
  let route;
32
33
 
@@ -1,6 +1,6 @@
1
1
  import React, { memo } from 'react';
2
2
  import { StyleSheet, SafeAreaView } from 'react-native';
3
- import { t } from 'i18n-js';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
4
  import i18n from 'i18n-js';
5
5
  import { TESTID } from '../../configs/Constants';
6
6
 
@@ -9,6 +9,7 @@ import Text from '../../commons/Text';
9
9
  import useTitleHeader from '../../hooks/Common/useTitleHeader';
10
10
 
11
11
  const TDSGuide = memo(() => {
12
+ const t = useTranslations();
12
13
  useTitleHeader(t('tds_infomation'));
13
14
  const currentLanguage = i18n.currentLocale();
14
15
 
@@ -6,7 +6,7 @@ import {
6
6
  TouchableOpacity,
7
7
  SafeAreaView,
8
8
  } from 'react-native';
9
- import { t } from 'i18n-js';
9
+ import { useTranslations } from '../../hooks/Common/useTranslations';
10
10
 
11
11
  import { Colors, Theme } from '../../configs';
12
12
  import Text from '../../commons/Text';
@@ -15,6 +15,7 @@ import { TESTID } from '../../configs/Constants';
15
15
  import { useSCContextSelector } from '../../context';
16
16
 
17
17
  const UVIndexGuide = memo(() => {
18
+ const t = useTranslations();
18
19
  useTitleHeader(t('UV Index Guide'));
19
20
  const language = useSCContextSelector((state) => state.language);
20
21
 
@@ -1,6 +1,6 @@
1
1
  import MenuActionAddnew from '../../commons/MenuActionAddnew';
2
2
  import React, { memo, useCallback, useMemo } from 'react';
3
- import { t } from 'i18n-js';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
4
  import Routes from '../../utils/Route';
5
5
  import AddSubUnitIcon from '../../../assets/images/Popover/Dashboard/AddSubUnit.svg';
6
6
  import AddDeviceIcon from '../../../assets/images/Popover/Dashboard/AddDevice.svg';
@@ -8,6 +8,7 @@ import AddMemberIcon from '../../../assets/images/Popover/Dashboard/AddMember.sv
8
8
  import { useNavigation } from '@react-navigation/native';
9
9
 
10
10
  const AddMenu = memo(({ unit, afterItemClick, showAdd, setHideAdd }) => {
11
+ const t = useTranslations();
11
12
  const navigation = useNavigation();
12
13
 
13
14
  const onItemClick = useCallback(
@@ -50,7 +51,7 @@ const AddMenu = memo(({ unit, afterItemClick, showAdd, setHideAdd }) => {
50
51
  data: { screen: Routes.SetupGatewayWifi, params: { unit_id: unit.id } },
51
52
  },
52
53
  ];
53
- }, [unit]);
54
+ }, [t, unit]);
54
55
 
55
56
  const hideAddModal = useCallback(() => {
56
57
  setHideAdd(false);
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useContext, useEffect, useState } from 'react';
2
2
  import { AppState, RefreshControl, View } from 'react-native';
3
3
  import { useIsFocused } from '@react-navigation/native';
4
- import { t } from 'i18n-js';
4
+ import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
 
6
6
  import styles from './styles';
7
7
  import AddMenu from './AddMenu';
@@ -21,44 +21,70 @@ import WrapParallaxScrollView from '../../commons/WrapParallaxScrollView';
21
21
  import { SCContext } from '../../context';
22
22
  import { Action } from '../../context/actionType';
23
23
  import CameraDevice from '../../commons/CameraDevice';
24
+ import { ModalFullVideo } from '../../commons/Modal';
25
+ import { useNavigation } from '@react-navigation/native';
26
+ import Routes from '../../utils/Route';
27
+ import SubUnitOneTap from '../../commons/SubUnit/OneTap';
24
28
 
25
29
  const UnitDetail = ({ route }) => {
30
+ const t = useTranslations();
26
31
  const { unitId, unitData } = route.params;
27
32
  const isFocused = useIsFocused();
28
33
  const { stateData, setAction } = useContext(SCContext);
34
+ const { navigate } = useNavigation();
29
35
 
30
36
  const [unit, setUnit] = useState(unitData || { id: unitId });
31
37
  const [appState, setAppState] = useState(AppState.currentState);
32
38
  const [listMenuItem, setListMenuItem] = useState([]);
33
39
  const [listStation, setListStation] = useState([]);
40
+ const [automates, setAutomates] = useState([]);
34
41
  const [isGGHomeConnected, setIsGGHomeConnected] = useState(false);
35
42
  const [station, setStation] = useState([]);
36
43
  const [indexStation, setIndexStation] = useState(0);
37
44
  const [showAdd, setShowAdd, setHideAdd] = useBoolean();
45
+ const [isFullScreen, setIsFullScreen] = useState(false);
46
+ const [dataFullScreen, setDataFullScreen] = useState();
38
47
 
39
48
  const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
40
49
  usePopover();
41
50
 
42
51
  const { isOwner } = useIsOwnerOfUnit(unit.user_id);
43
52
 
44
- const prepareData = useCallback((rawUnitData) => {
45
- const favorites = {
46
- isFakeStation: true,
47
- isFavorites: true,
48
- name: t('favorites'),
49
- sensors: [],
50
- };
51
- rawUnitData.stations.unshift(favorites);
52
- rawUnitData.stations.forEach((stationItem) => {
53
- if (stationItem.sensors) {
54
- const favoriteDevices = stationItem.sensors.filter(
55
- (sensorItem) => sensorItem.is_favourite
56
- );
57
- favorites.sensors = favorites.sensors.concat(favoriteDevices);
58
- }
59
- });
53
+ const handleFullScreen = (data) => {
54
+ setIsFullScreen(!isFullScreen);
55
+ setDataFullScreen(data);
56
+ };
57
+
58
+ const onClose = useCallback(() => {
59
+ setIsFullScreen(false);
60
60
  }, []);
61
61
 
62
+ const prepareData = useCallback(
63
+ (rawUnitData) => {
64
+ const oneTap = {
65
+ isOneTap: true,
66
+ name: 'One-Tap',
67
+ };
68
+ rawUnitData.stations.unshift(oneTap);
69
+ const favorites = {
70
+ isFakeStation: true,
71
+ isFavorites: true,
72
+ name: t('favorites'),
73
+ sensors: [],
74
+ };
75
+ rawUnitData.stations.unshift(favorites);
76
+ rawUnitData.stations.forEach((stationItem) => {
77
+ if (stationItem.sensors) {
78
+ const favoriteDevices = stationItem.sensors.filter(
79
+ (sensorItem) => sensorItem.is_favourite
80
+ );
81
+ favorites.sensors = favorites.sensors.concat(favoriteDevices);
82
+ }
83
+ });
84
+ },
85
+ [t]
86
+ );
87
+
62
88
  const fetchDetails = useCallback(async () => {
63
89
  await fetchWithCache(API.UNIT.UNIT_DETAIL(unitId), {}, (response) => {
64
90
  const { success, data } = response;
@@ -69,6 +95,15 @@ const UnitDetail = ({ route }) => {
69
95
  });
70
96
  }, [setUnit, unitId, prepareData]);
71
97
 
98
+ const getScriptOneTap = useCallback(async () => {
99
+ await fetchWithCache(API.UNIT.AUTOMATE(unitId), {}, (response) => {
100
+ const { success, data } = response;
101
+ if (success) {
102
+ setAutomates(data);
103
+ }
104
+ });
105
+ }, [unitId]);
106
+
72
107
  const onRefresh = useCallback(() => {
73
108
  fetchDetails();
74
109
  }, [fetchDetails]);
@@ -150,8 +185,9 @@ const UnitDetail = ({ route }) => {
150
185
  useEffect(() => {
151
186
  if (isFocused) {
152
187
  fetchDetails();
188
+ getScriptOneTap();
153
189
  }
154
- }, [fetchDetails, isFocused]);
190
+ }, [fetchDetails, getScriptOneTap, isFocused]);
155
191
 
156
192
  useEffect(() => {
157
193
  if (unit.stations) {
@@ -174,9 +210,22 @@ const UnitDetail = ({ route }) => {
174
210
  // eslint-disable-next-line react-hooks/exhaustive-deps
175
211
  [unit, indexStation]
176
212
  );
213
+
214
+ const goToPlayBack = (item, thumbnail) => () => {
215
+ navigate(Routes.PlaybackCamera, { item, thumbnail });
216
+ };
217
+
177
218
  const renderDetailSubUnit = () => {
178
219
  if (station.camera_devices) {
179
- return <CameraDevice station={station} />;
220
+ return (
221
+ <CameraDevice
222
+ station={station}
223
+ handleFullScreen={handleFullScreen}
224
+ goToPlayBack={goToPlayBack}
225
+ />
226
+ );
227
+ } else if (station.isOneTap) {
228
+ return <SubUnitOneTap automates={automates} />;
180
229
  } else if (station) {
181
230
  return (
182
231
  <ShortDetailSubUnit
@@ -190,7 +239,7 @@ const UnitDetail = ({ route }) => {
190
239
  return (
191
240
  <WrapParallaxScrollView
192
241
  uriImg={unit.background}
193
- title={t('Welcome %{name}', {
242
+ title={t('Welcome {name}', {
194
243
  name: unit.name ? unit.name : '',
195
244
  })}
196
245
  refreshControl={
@@ -229,6 +278,12 @@ const UnitDetail = ({ route }) => {
229
278
  childRef={childRef}
230
279
  showingPopover={showingPopover}
231
280
  />
281
+ <ModalFullVideo
282
+ isVisible={isFullScreen}
283
+ data={dataFullScreen}
284
+ modalStyles={styles.modal}
285
+ onClose={onClose}
286
+ />
232
287
  </WrapParallaxScrollView>
233
288
  );
234
289
  };
@@ -8,7 +8,7 @@ import {
8
8
  } from 'react-native';
9
9
  import Modal from 'react-native-modal';
10
10
  import Animated from 'react-native-reanimated';
11
- import { t } from 'i18n-js';
11
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
12
12
 
13
13
  import { Colors, API, Device } from '../../../configs';
14
14
  import Routes from '../../../utils/Route';
@@ -37,6 +37,7 @@ import { useIsOwnerOfUnit } from '../../../hooks/Common';
37
37
  import { TESTID } from '../../../configs/Constants';
38
38
 
39
39
  const ManageUnit = ({ route }) => {
40
+ const t = useTranslations();
40
41
  const { unit } = route.params;
41
42
  const { isOwner } = useIsOwnerOfUnit(unit.user_id);
42
43
  const [showEdit, setshowEdit, setHideEdit] = useBoolean();
@@ -57,7 +58,7 @@ const ManageUnit = ({ route }) => {
57
58
  ToastBottomHelper.success(t('unit_updated_successfully'));
58
59
  }
59
60
  },
60
- [unit.id, imageUrl]
61
+ [imageUrl, unit.id, t]
61
62
  );
62
63
 
63
64
  const goRename = useCallback(async () => {
@@ -85,7 +86,7 @@ const ManageUnit = ({ route }) => {
85
86
  ToastBottomHelper.success(t('unit_deleted_successfully'));
86
87
  navigate(Routes.Dashboard);
87
88
  }
88
- }, [unit.id, setHideEdit]);
89
+ }, [unit.id, setHideEdit, t]);
89
90
 
90
91
  const [transY] = useKeyboardAnimated(-16);
91
92
  const animatedStyle = Platform.select({
@@ -2,7 +2,7 @@ import React, { useState, useCallback, useEffect } from 'react';
2
2
  import { View, TouchableOpacity, Image, Platform } from 'react-native';
3
3
  import Modal from 'react-native-modal';
4
4
  import Animated from 'react-native-reanimated';
5
- import { t } from 'i18n-js';
5
+ import { useTranslations } from '../../hooks/Common/useTranslations';
6
6
 
7
7
  import { Colors, API, Device, Images } from '../../configs';
8
8
  import Routes from '../../utils/Route';
@@ -62,6 +62,7 @@ const ButtonWrapper = ({
62
62
  };
63
63
 
64
64
  const ManageUnit = ({ route }) => {
65
+ const t = useTranslations();
65
66
  const { unit } = route.params;
66
67
  const navigation = useNavigation();
67
68
  const { isOwner } = useIsOwnerOfUnit(unit.user_id);
@@ -90,7 +91,7 @@ const ManageUnit = ({ route }) => {
90
91
  ToastBottomHelper.success(t('unit_updated_successfully'));
91
92
  }
92
93
  },
93
- [unit.id, setUnitData]
94
+ [unit.id, t]
94
95
  );
95
96
 
96
97
  const updateLocation = useCallback(
@@ -137,7 +138,7 @@ const ManageUnit = ({ route }) => {
137
138
  ToastBottomHelper.success(t('unit_deleted_successfully'));
138
139
  navigate(Routes.Dashboard);
139
140
  }
140
- }, [unit.id, setHideEdit]);
141
+ }, [unit.id, setHideEdit, t]);
141
142
 
142
143
  const [transY] = useKeyboardAnimated(-16);
143
144
  const animatedStyle = Platform.select({
@@ -1,11 +1,12 @@
1
1
  import React, { memo, useCallback, useMemo } from 'react';
2
- import { t } from 'i18n-js';
2
+ import { useTranslations } from '../../hooks/Common/useTranslations';
3
3
  import Routes from '../../utils/Route';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { MenuActionMore } from '../../commons';
6
6
 
7
7
  const MoreMenu = memo(
8
8
  ({ unit, isOwner, hidePopover, childRef, showingPopover }) => {
9
+ const t = useTranslations();
9
10
  const navigation = useNavigation();
10
11
 
11
12
  const onItemClick = useCallback(
@@ -30,7 +31,7 @@ const MoreMenu = memo(
30
31
  return isOwner
31
32
  ? [RouteManageUnit, RouteUnitMemberList]
32
33
  : [RouteUnitMemberList];
33
- }, [unit, isOwner]);
34
+ }, [t, unit, isOwner]);
34
35
 
35
36
  return (
36
37
  <MenuActionMore
@@ -5,7 +5,7 @@ import { View } from 'react-native';
5
5
  import MapView, { Marker, PROVIDER_GOOGLE } from 'react-native-maps';
6
6
  import BottomButtonView from '../../commons/BottomButtonView';
7
7
 
8
- import { t } from 'i18n-js';
8
+ import { useTranslations } from '../../hooks/Common/useTranslations';
9
9
  import { API } from '../../configs';
10
10
  import styles from './SelectLocationStyles';
11
11
  import SearchBarLocation from './components/SearchLocation';
@@ -14,6 +14,7 @@ import { axiosGet } from '../../utils/Apis/axios';
14
14
  import { ScrollView } from 'react-native-gesture-handler';
15
15
  import { useNavigation } from '@react-navigation/native';
16
16
  import { SCConfig } from '../../configs';
17
+ import Point from '../../../assets/images/AddLocationMaps/Point.svg';
17
18
 
18
19
  const initialRegion = {
19
20
  latitudeDelta: 0.0922,
@@ -24,6 +25,7 @@ const DEFAULT_LATITUDE = 10.7974046; // EoH center
24
25
  const DEFAULT_LONGITUDE = 106.7035663;
25
26
 
26
27
  const SelectLocation = memo(({ route }) => {
28
+ const t = useTranslations();
27
29
  const { updateLocation } = route.params;
28
30
  const { goBack } = useNavigation();
29
31
  const [input, setInput] = useState('');
@@ -75,6 +77,8 @@ const SelectLocation = memo(({ route }) => {
75
77
  }, []);
76
78
 
77
79
  const onPressRowLocation = useCallback(async (item) => {
80
+ setInput(item.description);
81
+ setSearchData([]);
78
82
  const body = {
79
83
  params: {
80
84
  place_id: item.place_id,
@@ -134,7 +138,11 @@ const SelectLocation = memo(({ route }) => {
134
138
  longitude: searchedLocation.longitude,
135
139
  }}
136
140
  tracksViewChanges={false}
137
- />
141
+ >
142
+ <View style={styles.pointCircle}>
143
+ <Point />
144
+ </View>
145
+ </Marker>
138
146
  )}
139
147
  </MapView>
140
148
  <BottomButtonView
@@ -15,6 +15,17 @@ export default StyleSheet.create({
15
15
  bottomButton: {
16
16
  backgroundColor: Colors.White,
17
17
  },
18
+ pointCircle: {
19
+ flex: 1,
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ width: 109,
23
+ height: 109,
24
+ borderRadius: 50,
25
+ backgroundColor: Colors.BlueTransparent5,
26
+ borderWidth: 1,
27
+ borderColor: Colors.Blue10,
28
+ },
18
29
  searchLocation: {
19
30
  paddingVertical: 8,
20
31
  position: 'absolute',
@@ -3,7 +3,7 @@ import { Dimensions, View, TouchableOpacity, StyleSheet } from 'react-native';
3
3
  import Popover from 'react-native-popover-view';
4
4
  import Modal from 'react-native-modal';
5
5
  import { IconOutline } from '@ant-design/icons-react-native';
6
- import { t } from 'i18n-js';
6
+ import { useTranslations } from '../../../../hooks/Common/useTranslations';
7
7
 
8
8
  import { Colors } from '../../../../configs';
9
9
  import Text from '../../../../commons/Text';
@@ -30,6 +30,7 @@ const HeaderComponent = ({
30
30
  fixedHeight, // when height of header is fixed
31
31
  style,
32
32
  }) => {
33
+ const t = useTranslations();
33
34
  const popoverRef = useRef();
34
35
  const [menu, setMenu] = useState(false);
35
36
  const [showModal, setShowModal] = useState(false);