@eohjsc/react-native-smart-city 0.3.7 → 0.3.10

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 (292) hide show
  1. package/README.md +36 -15
  2. package/package.json +10 -6
  3. package/react-native-smart-city.podspec +1 -0
  4. package/src/commons/Action/ItemQuickAction.js +16 -4
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  9. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
  14. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  15. package/src/commons/ActionGroup/OnOffTemplate/index.js +3 -2
  16. package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
  18. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
  21. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  22. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  25. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  26. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  27. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  28. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  29. package/src/commons/Auth/AccountList.js +1 -1
  30. package/src/commons/Automate/ItemAutomate.js +1 -3
  31. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  32. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  33. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
  34. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
  35. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  36. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
  37. package/src/commons/ConnectingProcess/index.js +76 -26
  38. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  39. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  40. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  41. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  42. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  43. package/src/commons/Device/HistoryChart.js +7 -3
  44. package/src/commons/Device/ItemDevice.js +34 -13
  45. package/src/commons/Device/LinearChart.js +15 -0
  46. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  47. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  48. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  49. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  50. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
  51. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  52. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  53. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  54. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  55. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  56. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  57. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  58. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  59. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  60. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  61. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  62. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  63. package/src/commons/Form/CurrencyInput.js +15 -1
  64. package/src/commons/Form/TextInputPassword.js +1 -1
  65. package/src/commons/FullLoading/index.js +2 -1
  66. package/src/commons/Header/HeaderCustom.js +2 -1
  67. package/src/commons/HeaderAni/index.js +6 -1
  68. package/src/commons/HorizontalPicker/index.js +2 -2
  69. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  70. package/src/commons/MediaPlayerDetail/index.js +29 -47
  71. package/src/commons/MenuActionAddnew/index.js +1 -0
  72. package/src/commons/MenuActionList/index.js +1 -0
  73. package/src/commons/MenuActionMore/index.js +1 -1
  74. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  75. package/src/commons/PreventAccess/index.js +9 -1
  76. package/src/commons/Sharing/MemberList.js +10 -2
  77. package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
  78. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  79. package/src/commons/SubUnit/Favorites/index.js +2 -3
  80. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  81. package/src/commons/SubUnit/OneTap/index.js +1 -2
  82. package/src/commons/SubUnit/ShortDetail.js +25 -9
  83. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  84. package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
  85. package/src/commons/Unit/SharedUnit.js +1 -0
  86. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  87. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +28 -1
  88. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  89. package/src/commons/UnitSummary/ConfigHistoryChart.js +55 -13
  90. package/src/commons/WheelDateTimePicker/index.js +4 -3
  91. package/src/configs/API.js +87 -143
  92. package/src/configs/Constants.js +80 -1
  93. package/src/configs/SCConfig.js +4 -0
  94. package/src/context/actionType.ts +11 -0
  95. package/src/context/mockStore.ts +12 -0
  96. package/src/context/reducer.ts +57 -2
  97. package/src/hooks/Common/index.js +2 -0
  98. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  99. package/src/hooks/Common/useGetIdUser.js +1 -5
  100. package/src/hooks/Common/useSensorsStatus.js +4 -4
  101. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
  102. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  103. package/src/hooks/IoT/index.js +4 -0
  104. package/src/hooks/IoT/useGGHomeConnection.js +93 -0
  105. package/src/hooks/IoT/useRemoteControl.js +79 -0
  106. package/src/hooks/index.js +4 -0
  107. package/src/hooks/useReceiveNotifications.js +12 -7
  108. package/src/iot/Monitor.js +3 -2
  109. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  110. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  111. package/src/iot/RemoteControl/Internet.js +1 -1
  112. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  114. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  115. package/src/iot/RemoteControl/index.js +52 -52
  116. package/src/navigations/UnitStack.js +11 -20
  117. package/src/navigations/UnitStackStyles.js +21 -0
  118. package/src/screens/AQIGuide/index.js +1 -1
  119. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  120. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  121. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  122. package/src/screens/ActivityLog/hooks/index.js +1 -1
  123. package/src/screens/ActivityLog/index.js +2 -2
  124. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  125. package/src/screens/AddCommon/SelectUnit.js +1 -0
  126. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  127. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  128. package/src/screens/AddLocationMaps/__test__/index.test.js +265 -0
  129. package/src/screens/AddLocationMaps/index.js +48 -21
  130. package/src/screens/AddNewAction/SelectAction.js +32 -13
  131. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  132. package/src/screens/AddNewAction/SetupSensor.js +67 -32
  133. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  134. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  135. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +2 -0
  136. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  137. package/src/screens/AddNewAutoSmart/index.js +5 -2
  138. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  139. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
  140. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  141. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  142. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  143. package/src/screens/AddNewDevice/index.js +1 -0
  144. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  145. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
  146. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
  147. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  148. package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
  149. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  150. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  151. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  152. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  153. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  154. package/src/screens/AddNewGateway/index.js +1 -0
  155. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  156. package/src/screens/AddNewOneTap/index.js +3 -2
  157. package/src/screens/AllCamera/index.js +4 -4
  158. package/src/screens/Automate/MultiUnits.js +8 -8
  159. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  160. package/src/screens/Automate/__test__/index.test.js +7 -12
  161. package/src/screens/Automate/index.js +5 -3
  162. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  163. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  164. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  165. package/src/screens/Device/EditDevice/index.js +17 -15
  166. package/src/screens/Device/__test__/detail.test.js +33 -86
  167. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  168. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
  169. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  170. package/src/screens/Device/detail.js +85 -26
  171. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  172. package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
  173. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  174. package/src/screens/EditActionsList/index.js +1 -1
  175. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  176. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  177. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  178. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  179. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  180. package/src/screens/EmergencySetting/index.js +4 -1
  181. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  182. package/src/screens/Explore/index.js +2 -0
  183. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  184. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  185. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  186. package/src/screens/HanetCamera/Detail.js +1 -1
  187. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  188. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  189. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  190. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  191. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  192. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  193. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  194. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  195. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  196. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  197. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  198. package/src/screens/ManageAccess/hooks/index.js +7 -4
  199. package/src/screens/ManageAccess/index.js +2 -1
  200. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  201. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  202. package/src/screens/Notification/__test__/Notification.test.js +31 -25
  203. package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
  204. package/src/screens/Notification/components/NotificationItem.js +17 -20
  205. package/src/screens/Notification/index.js +13 -2
  206. package/src/screens/PlayBackCamera/Timer.js +2 -2
  207. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  208. package/src/screens/PlayBackCamera/index.js +54 -35
  209. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  210. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  211. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  212. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  213. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  214. package/src/screens/ScriptDetail/index.js +19 -14
  215. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  216. package/src/screens/SelectUnit/index.js +9 -4
  217. package/src/screens/SetSchedule/index.js +15 -11
  218. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  219. package/src/screens/SharedUnit/index.js +2 -0
  220. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  221. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  222. package/src/screens/Sharing/MemberList.js +12 -11
  223. package/src/screens/Sharing/SelectPermission.js +136 -83
  224. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  225. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  226. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  227. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  228. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  229. package/src/screens/Sharing/hooks/index.js +3 -0
  230. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  231. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  232. package/src/screens/SideMenuDetail/index.js +148 -0
  233. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  234. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  235. package/src/screens/SubUnit/AddSubUnit.js +23 -17
  236. package/src/screens/SubUnit/Detail.js +1 -2
  237. package/src/screens/SubUnit/EditSubUnit.js +15 -13
  238. package/src/screens/SubUnit/ManageSubUnit.js +13 -7
  239. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
  240. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  241. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  242. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  243. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
  244. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  245. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  246. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
  247. package/src/screens/TDSGuide/index.js +4 -1
  248. package/src/screens/UVIndexGuide/index.js +1 -1
  249. package/src/screens/Unit/ChooseLocation.js +7 -14
  250. package/src/screens/Unit/Detail.js +32 -75
  251. package/src/screens/Unit/ManageUnit.js +1 -0
  252. package/src/screens/Unit/SelectAddress.js +45 -23
  253. package/src/screens/Unit/SmartAccount.js +4 -4
  254. package/src/screens/Unit/Station/index.js +4 -0
  255. package/src/screens/Unit/Summaries.js +18 -2
  256. package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
  257. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  258. package/src/screens/Unit/__test__/Detail.test.js +98 -199
  259. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  260. package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
  261. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  262. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  263. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  264. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  265. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  266. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  267. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  268. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  269. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  270. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  271. package/src/screens/Unit/styles.js +8 -0
  272. package/src/screens/UnitSummary/__test__/index.test.js +91 -30
  273. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  274. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  275. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  276. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  277. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  278. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  279. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  280. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  281. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
  282. package/src/screens/UnitSummary/index.js +15 -1
  283. package/src/screens/WaterQualityGuide/index.js +1 -1
  284. package/src/utils/Apis/axios.js +54 -31
  285. package/src/utils/Converter/time.js +0 -18
  286. package/src/utils/I18n/translations/en.json +11 -1
  287. package/src/utils/I18n/translations/vi.json +12 -1
  288. package/src/utils/Permission/common.js +67 -0
  289. package/src/utils/Route/index.js +1 -0
  290. package/src/utils/Setting/Location.js +30 -0
  291. package/src/utils/Utils.js +12 -7
  292. package/src/utils/__test__/Utils.test.js +12 -0
@@ -0,0 +1,179 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { mockSCStore } from '../../../../context/mockStore';
4
+ import { SCProvider } from '../../../../context';
5
+ import ScheduleField from '../index';
6
+ import { TESTID } from '../../../../configs/Constants';
7
+ import { TouchableOpacity } from 'react-native';
8
+
9
+ const mockSetState = jest.fn();
10
+
11
+ const wrapComponent = (
12
+ dataItem = {
13
+ type: 'schedule',
14
+ key: 'schedule',
15
+ action: {
16
+ type: 'action_zigbee',
17
+ id: {
18
+ always: 2,
19
+ recurring: 4,
20
+ temporary: 5,
21
+ },
22
+ },
23
+ },
24
+ index = 0,
25
+ dataForm = [
26
+ {
27
+ type: 'schedule',
28
+ key: 'schedule',
29
+ action: {
30
+ type: 'action_zigbee',
31
+ id: {
32
+ always: 2,
33
+ recurring: 4,
34
+ temporary: 5,
35
+ },
36
+ },
37
+ },
38
+ ]
39
+ ) => (
40
+ <SCProvider initState={mockSCStore({})}>
41
+ <ScheduleField
42
+ dataItem={dataItem}
43
+ index={index}
44
+ setDataForm={mockSetState}
45
+ dataForm={dataForm}
46
+ />
47
+ </SCProvider>
48
+ );
49
+
50
+ describe('Test ScheduleField', () => {
51
+ let tree;
52
+ beforeEach(() => {
53
+ Date.now = jest.fn(() => new Date('2022-05-30T15:50:36+01:00'));
54
+ });
55
+ afterEach(() => {
56
+ mockSetState.mockClear();
57
+ });
58
+
59
+ const onPressRecurring = async (instance, schedule) => {
60
+ await act(async () => {
61
+ await schedule.props.onPress();
62
+ });
63
+ const recurring = instance.find(
64
+ (el) =>
65
+ el.props.testID === '0' + TESTID.RECURRING_REPEAT_ITEM &&
66
+ el.type === TouchableOpacity
67
+ );
68
+ await act(async () => {
69
+ await recurring.props.onPress();
70
+ });
71
+ expect(mockSetState).toBeCalledWith([
72
+ {
73
+ key: 'schedule',
74
+ type: 'schedule',
75
+ data: {
76
+ access_schedule: 'recurring',
77
+ recurring_time_end: '2022-05-30T16:50:36+01:00',
78
+ recurring_time_repeat: ['6'],
79
+ recurring_time_start: '2022-05-30T15:50:36+01:00',
80
+ },
81
+ valid: true,
82
+ action: {
83
+ id: {
84
+ always: 2,
85
+ recurring: 4,
86
+ temporary: 5,
87
+ },
88
+ type: 'action_zigbee',
89
+ },
90
+ action_zigbee: 4,
91
+ },
92
+ ]);
93
+ mockSetState.mockClear();
94
+ };
95
+
96
+ const onPressTemporary = async (instance, schedule) => {
97
+ await act(async () => {
98
+ await schedule.props.onPress();
99
+ });
100
+
101
+ expect(mockSetState).toBeCalledWith([
102
+ {
103
+ key: 'schedule',
104
+ type: 'schedule',
105
+ data: {
106
+ access_schedule: 'temporary',
107
+ temporary_time_end: '2022-05-31T15:50:36+01:00',
108
+ temporary_time_start: '2022-05-30T15:50:36+01:00',
109
+ },
110
+ valid: true,
111
+ action: {
112
+ id: {
113
+ always: 2,
114
+ recurring: 4,
115
+ temporary: 5,
116
+ },
117
+ type: 'action_zigbee',
118
+ },
119
+ action_zigbee: 5,
120
+ },
121
+ ]);
122
+ const temporaryEnd = instance.find(
123
+ (el) =>
124
+ el.props.testID === TESTID.TEMPORARY_END_TEXT_BUTTON &&
125
+ el.type === TouchableOpacity
126
+ );
127
+ await act(async () => {
128
+ await temporaryEnd.props.onPress();
129
+ });
130
+ const dateTimePicker = instance.find(
131
+ (el) => el.props.testID === TESTID.WHEEL_DATE_TIME_PICKER
132
+ );
133
+ expect(dateTimePicker.props.isVisible).toBeTruthy();
134
+ const popupDateTimePickerDone = instance.find(
135
+ (el) =>
136
+ el.props.testID ===
137
+ `${TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}` &&
138
+ el.type === TouchableOpacity
139
+ );
140
+ await act(async () => {
141
+ await popupDateTimePickerDone.props.onPress();
142
+ });
143
+ expect(dateTimePicker.props.isVisible).toBeFalsy();
144
+ mockSetState.mockClear();
145
+ };
146
+
147
+ test('render ScheduleField choose schedule', async () => {
148
+ await act(async () => {
149
+ tree = await create(wrapComponent());
150
+ });
151
+ expect(mockSetState).toBeCalledWith([
152
+ {
153
+ key: 'schedule',
154
+ type: 'schedule',
155
+ data: { access_schedule: 'always' },
156
+ valid: true,
157
+ action: {
158
+ id: {
159
+ always: 2,
160
+ recurring: 4,
161
+ temporary: 5,
162
+ },
163
+ type: 'action_zigbee',
164
+ },
165
+ action_zigbee: 2,
166
+ },
167
+ ]);
168
+ mockSetState.mockClear();
169
+ const instance = tree.root;
170
+ const schedule = instance.findAll(
171
+ (el) =>
172
+ el.props.testID === TESTID.ACCESS_SCHEDULE_RADIO_BUTTON &&
173
+ el.type === TouchableOpacity
174
+ );
175
+ expect(schedule).toHaveLength(3);
176
+ await onPressRecurring(instance, schedule[1]);
177
+ await onPressTemporary(instance, schedule[2]);
178
+ });
179
+ });
@@ -0,0 +1,176 @@
1
+ import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import styles from './ScheduleFieldStyles';
4
+ import moment from 'moment';
5
+
6
+ import Text from '../../Text';
7
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
8
+ import AccessScheduleItem from '../../../screens/GuestInfo/components/AccessScheduleItem';
9
+ import RecurringDetail from '../../../screens/GuestInfo/components/RecurringDetail';
10
+ import TemporaryDetail from '../../../screens/GuestInfo/components/TemporaryDetail';
11
+ import { useBoolean } from '../../../hooks/Common';
12
+ import WheelDateTimePicker from '../../WheelDateTimePicker';
13
+ import { ACCESS_SCHEDULE } from '../../../screens/GuestInfo/constant';
14
+
15
+ const ScheduleField = ({ dataItem, index, setDataForm, dataForm }) => {
16
+ const t = useTranslations();
17
+ const [accessSchedule, setAccessSchedule] = useState('always');
18
+ const [lockShowing, releaseLockShowing, acquireLockShowing] =
19
+ useBoolean(true);
20
+
21
+ const [stateDateTimePicker, setStateDateTimePicker] = useState({
22
+ isVisible: false,
23
+ mode: 'time',
24
+ defaultValue: moment(),
25
+ setter: null,
26
+ });
27
+ const [recurringTimeStart, setRecurringTimeStart] = useState(moment());
28
+ const [recurringTimeEnd, setRecurringTimeEnd] = useState(
29
+ moment().add(1, 'hours')
30
+ );
31
+ const [recurringTimeRepeat, setRecurringTimeRepeat] = useState([]);
32
+ const [temporaryTimeStart, setTemporaryTimeStart] = useState(moment());
33
+ const [temporaryTimeEnd, setTemporaryTimeEnd] = useState(
34
+ moment().add(1, 'days')
35
+ );
36
+ useEffect(() => {
37
+ if (accessSchedule === ACCESS_SCHEDULE.ALWAYS) {
38
+ dataItem.valid = true;
39
+ dataItem.data = {
40
+ access_schedule: accessSchedule,
41
+ };
42
+ } else if (accessSchedule === ACCESS_SCHEDULE.RECURRING) {
43
+ dataItem.valid = true;
44
+ dataItem.data = {
45
+ access_schedule: accessSchedule,
46
+ recurring_time_start: recurringTimeStart.format(),
47
+ recurring_time_end: recurringTimeEnd.format(),
48
+ recurring_time_repeat: recurringTimeRepeat,
49
+ };
50
+ } else if (accessSchedule === ACCESS_SCHEDULE.TEMPORARY) {
51
+ if (temporaryTimeStart > temporaryTimeEnd) {
52
+ dataItem.valid = false;
53
+ } else {
54
+ dataItem.valid = true;
55
+ dataItem.data = {
56
+ access_schedule: accessSchedule,
57
+ temporary_time_start: temporaryTimeStart.format(),
58
+ temporary_time_end: temporaryTimeEnd.format(),
59
+ };
60
+ }
61
+ }
62
+ dataItem[dataItem.action.type] = dataItem.action.id[accessSchedule];
63
+ dataForm[index] = dataItem;
64
+ setDataForm([...dataForm]);
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, [
67
+ accessSchedule,
68
+ recurringTimeEnd,
69
+ recurringTimeRepeat,
70
+ recurringTimeStart,
71
+ temporaryTimeEnd,
72
+ temporaryTimeStart,
73
+ ]);
74
+ const onShowSetDateTime = useCallback(
75
+ (currentValue, setter, mode) => {
76
+ releaseLockShowing();
77
+ setStateDateTimePicker((state) => ({
78
+ ...state,
79
+ isVisible: true,
80
+ mode: mode,
81
+ defaultValue: currentValue,
82
+ setter: setter,
83
+ }));
84
+ },
85
+ [releaseLockShowing]
86
+ );
87
+
88
+ const onHideSetDateTime = useCallback(() => {
89
+ acquireLockShowing();
90
+ setStateDateTimePicker((state) => ({
91
+ ...state,
92
+ isVisible: false,
93
+ }));
94
+ }, [setStateDateTimePicker, acquireLockShowing]);
95
+
96
+ const onDateTimePicked = useCallback(
97
+ (timeData) => {
98
+ const setter = stateDateTimePicker.setter;
99
+ setter && setter(moment(timeData));
100
+ },
101
+ [stateDateTimePicker]
102
+ );
103
+
104
+ const listAccessSchedule = useMemo(
105
+ () => [
106
+ {
107
+ text: t(`${ACCESS_SCHEDULE.ALWAYS}`),
108
+ value: ACCESS_SCHEDULE.ALWAYS,
109
+ detail: () => <></>,
110
+ },
111
+ {
112
+ text: t(`${ACCESS_SCHEDULE.RECURRING}`),
113
+ value: ACCESS_SCHEDULE.RECURRING,
114
+ detail: () => (
115
+ <RecurringDetail
116
+ onShowSetDateTime={onShowSetDateTime}
117
+ recurringTimeStart={recurringTimeStart}
118
+ recurringTimeEnd={recurringTimeEnd}
119
+ recurringTimeRepeat={recurringTimeRepeat}
120
+ setRecurringTimeStart={setRecurringTimeStart}
121
+ setRecurringTimeEnd={setRecurringTimeEnd}
122
+ setRecurringTimeRepeat={setRecurringTimeRepeat}
123
+ />
124
+ ),
125
+ },
126
+ {
127
+ text: t(`${ACCESS_SCHEDULE.TEMPORARY}`),
128
+ value: ACCESS_SCHEDULE.TEMPORARY,
129
+ detail: () => (
130
+ <TemporaryDetail
131
+ onShowSetDateTime={onShowSetDateTime}
132
+ temporaryTimeStart={temporaryTimeStart}
133
+ temporaryTimeEnd={temporaryTimeEnd}
134
+ setTemporaryTimeStart={setTemporaryTimeStart}
135
+ setTemporaryTimeEnd={setTemporaryTimeEnd}
136
+ />
137
+ ),
138
+ },
139
+ ],
140
+ // eslint-disable-next-line react-hooks/exhaustive-deps
141
+ [
142
+ onShowSetDateTime,
143
+ recurringTimeEnd,
144
+ recurringTimeRepeat,
145
+ recurringTimeStart,
146
+ temporaryTimeEnd,
147
+ temporaryTimeStart,
148
+ ]
149
+ );
150
+
151
+ return (
152
+ <View style={styles.wrapper}>
153
+ <Text style={styles.textHeadLine}>{t('access_schedule')}</Text>
154
+
155
+ {listAccessSchedule.map((item, i) => (
156
+ <AccessScheduleItem
157
+ key={i}
158
+ item={item}
159
+ isSelected={item.value === accessSchedule}
160
+ onSelect={setAccessSchedule}
161
+ isSetupGeneratePasscode
162
+ />
163
+ ))}
164
+ <WheelDateTimePicker
165
+ mode={stateDateTimePicker.mode}
166
+ isVisible={stateDateTimePicker.isVisible && lockShowing}
167
+ defaultValue={stateDateTimePicker.defaultValue}
168
+ onPicked={onDateTimePicked}
169
+ onCancel={onHideSetDateTime}
170
+ onHide={releaseLockShowing}
171
+ />
172
+ </View>
173
+ );
174
+ };
175
+
176
+ export default memo(ScheduleField);
@@ -1,4 +1,10 @@
1
- import React, { useState, useRef, useCallback, useMemo } from 'react';
1
+ import React, {
2
+ useState,
3
+ useRef,
4
+ useCallback,
5
+ useMemo,
6
+ useEffect,
7
+ } from 'react';
2
8
  import {
3
9
  View,
4
10
  TextInput,
@@ -6,6 +12,7 @@ import {
6
12
  TouchableWithoutFeedback,
7
13
  Platform,
8
14
  } from 'react-native';
15
+ import AndroidKeyboardAdjust from 'react-native-android-keyboard-adjust';
9
16
  import Text from '../Text';
10
17
  import { Colors } from '../../configs';
11
18
 
@@ -125,6 +132,13 @@ const CurrencyInput = ({
125
132
  return textInputValue.toString().length < 2 ? -12 : 0;
126
133
  }, [textInputValue]);
127
134
 
135
+ useEffect(() => {
136
+ const isAndroid = Platform.OS === 'android';
137
+ isAndroid && AndroidKeyboardAdjust.setAdjustResize();
138
+
139
+ return () => isAndroid && AndroidKeyboardAdjust.setAdjustPan();
140
+ }, []);
141
+
128
142
  return (
129
143
  <TouchableWithoutFeedback onPress={focusInput}>
130
144
  <View style={styles.wrap}>
@@ -90,7 +90,7 @@ const styles = StyleSheet.create({
90
90
  borderRadius: 2,
91
91
  paddingTop: 12,
92
92
  paddingBottom: 12,
93
- paddingHorizontal: 20,
93
+ paddingRight: 20,
94
94
  backgroundColor: Colors.White,
95
95
  // ...Theme.shadow,
96
96
  shadowColor: Colors.Gray13,
@@ -22,7 +22,8 @@ const styles = StyleSheet.create({
22
22
  left: 0,
23
23
  bottom: 0,
24
24
  right: 0,
25
- zIndex: 10,
25
+ zIndex: 1000, // works on ios
26
+ elevation: 1000, // works on android
26
27
  },
27
28
  background: {
28
29
  backgroundColor: colorOpacity(Colors.White, 0.8),
@@ -6,6 +6,7 @@ import { Icon } from '@ant-design/react-native';
6
6
  import { useNavigation } from '@react-navigation/native';
7
7
  import styles from './Styles/HeaderCustomStyles';
8
8
  import { useTranslations } from '../../hooks/Common/useTranslations';
9
+ import { notImplemented } from '../../utils/Utils';
9
10
 
10
11
  const HeaderCustom = ({
11
12
  title = '',
@@ -33,7 +34,7 @@ const HeaderCustom = ({
33
34
  };
34
35
 
35
36
  const handleClose = useCallback(() => {
36
- onClose ? onClose() : alert(t('feature_under_development'));
37
+ onClose ? onClose() : notImplemented(t);
37
38
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
39
  }, []);
39
40
 
@@ -6,6 +6,7 @@ import { getStatusBarHeight } from 'react-native-iphone-x-helper';
6
6
 
7
7
  import Text from '../../commons/Text';
8
8
  import { Colors, Constants } from '../../configs';
9
+ import { TESTID } from '../../configs/Constants';
9
10
 
10
11
  const screenHeight = Constants.height;
11
12
  const default_height = 44;
@@ -89,7 +90,11 @@ const HeaderAni = memo(
89
90
  },
90
91
  ]}
91
92
  >
92
- <TouchableOpacity style={styles.btnBack} onPress={onPressLeft}>
93
+ <TouchableOpacity
94
+ style={styles.btnBack}
95
+ onPress={onPressLeft}
96
+ testID={TESTID.ICON_BACK}
97
+ >
93
98
  <Icon name={'left'} size={27} color={Colors.Gray9} />
94
99
  </TouchableOpacity>
95
100
  <View styles={styles.wrapRightComponent}>{rightComponent}</View>
@@ -76,8 +76,8 @@ const HorizontalPicker = ({
76
76
  }, [maximum, minimum, time]);
77
77
 
78
78
  useEffect(() => {
79
- const scrollListener = scrollX.addListener(({ value }) => {
80
- isCanChangeValue && onChangeValue && onChangeValue(value);
79
+ const scrollListener = scrollX.addListener(({ value: scrollValue }) => {
80
+ isCanChangeValue && onChangeValue && onChangeValue(scrollValue);
81
81
  });
82
82
  return () => scrollX.removeListener(scrollListener);
83
83
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -68,12 +68,6 @@ export default StyleSheet.create({
68
68
  right: 0,
69
69
  bottom: 0,
70
70
  },
71
- firstOpenCamera: {
72
- zIndex: -9999,
73
- position: 'absolute',
74
- width: 1,
75
- height: 1,
76
- },
77
71
  loading: {
78
72
  position: 'absolute',
79
73
  zIndex: 10,
@@ -13,7 +13,6 @@ import {
13
13
  Text,
14
14
  TouchableOpacity,
15
15
  Platform,
16
- ActivityIndicator,
17
16
  } from 'react-native';
18
17
  import { VLCPlayer } from 'react-native-vlc-media-player';
19
18
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -43,18 +42,14 @@ const MediaPlayerDetail = ({
43
42
  height,
44
43
  }) => {
45
44
  const { setAction } = useContext(SCContext);
46
- const { isFirstOpenCamera, camera_opened } = useSCContextSelector(
47
- (state) => state.app
48
- );
45
+ const { camera_opened } = useSCContextSelector((state) => state.app);
49
46
  const t = useTranslations();
50
47
  const [paused, setPaused] = useState(isPaused);
51
48
 
52
49
  const onTapPause = useCallback(() => {
53
- if (!isFirstOpenCamera) {
54
- setPaused(false);
55
- id && setAction(Action.CAMERA_STATUS_CHANGE, { id, status: true });
56
- }
57
- }, [id, isFirstOpenCamera, setAction]);
50
+ setPaused(false);
51
+ id && setAction(Action.CAMERA_STATUS_CHANGE, { id, status: true });
52
+ }, [id, setAction]);
58
53
 
59
54
  const onTapGoDetail = useCallback(() => {
60
55
  if (!paused) {
@@ -72,40 +67,46 @@ const MediaPlayerDetail = ({
72
67
  }, []);
73
68
 
74
69
  const getWidthHeight = useCallback(() => {
75
- let width = 0,
76
- height = 0;
70
+ let newWidth = 0,
71
+ newHeight = 0;
77
72
  switch (amount) {
78
73
  case 1:
79
- width = Constants.width;
80
- height = 224;
74
+ newWidth = Constants.width;
75
+ newHeight = 224;
81
76
  break;
82
77
  case 4:
83
- width = Constants.width / 2;
84
- height = 112;
78
+ newWidth =
79
+ Constants.width /
80
+ (Platform.OS === 'ios' && Constants.width < 400 ? 1.5 : 2);
81
+ newHeight = 112;
85
82
  break;
86
83
  case 6:
87
- width = Constants.width / 3;
88
- height = 112;
84
+ newWidth = Constants.width / 3;
85
+ newHeight = 112;
89
86
  break;
90
87
  default:
91
- width = Constants.width - 28;
92
- height = 162;
88
+ newWidth = Constants.width - 28;
89
+ newHeight = 162;
93
90
  break;
94
91
  }
95
92
  return {
96
- width,
97
- height,
93
+ width: newWidth,
94
+ height: newHeight,
98
95
  };
99
96
  }, [amount]);
100
97
 
101
98
  const renderCamera = useMemo(() => {
99
+ if (!uri) {
100
+ return null;
101
+ }
102
102
  return (
103
103
  <VLCPlayer
104
104
  autoAspectRatio={true}
105
+ resizeMode="cover"
105
106
  videoAspectRatio={
106
- width && height
107
- ? `${width}:${height}`
108
- : `${getWidthHeight().width}:${getWidthHeight().height}`
107
+ amount
108
+ ? `${getWidthHeight().width}:${getWidthHeight().height}`
109
+ : `${width}:${height}`
109
110
  }
110
111
  source={{
111
112
  initType: 2,
@@ -126,31 +127,20 @@ const MediaPlayerDetail = ({
126
127
  styles.player,
127
128
  style,
128
129
  {
129
- width: width || getWidthHeight().width,
130
- height: height || getWidthHeight().height,
130
+ width: amount ? getWidthHeight().width : width,
131
+ height: amount ? getWidthHeight().height : height,
131
132
  },
132
- isFirstOpenCamera && styles.firstOpenCamera,
133
133
  ]}
134
134
  isLive={true}
135
135
  />
136
136
  );
137
137
  // eslint-disable-next-line react-hooks/exhaustive-deps
138
- }, [uri, isFirstOpenCamera]);
138
+ }, [uri]);
139
139
 
140
140
  useEffect(() => {
141
141
  setPaused(isPaused);
142
142
  }, [isPaused]);
143
143
 
144
- useEffect(() => {
145
- if (isFirstOpenCamera) {
146
- const to = setTimeout(() => {
147
- setAction(Action.IS_FIRST_OPEN_CAMERA, false);
148
- clearTimeout(to);
149
- }, 1000);
150
- }
151
- // eslint-disable-next-line react-hooks/exhaustive-deps
152
- }, [isFirstOpenCamera]);
153
-
154
144
  useEffect(() => {
155
145
  if (id && !(camera_opened || []).some((item) => item === id)) {
156
146
  setPaused(true);
@@ -161,14 +151,6 @@ const MediaPlayerDetail = ({
161
151
  const source = !thumbnail || !thumbnail.uri ? Images.BgDevice : thumbnail;
162
152
  return (
163
153
  <View style={[styles.wrap, wrapStyles]}>
164
- {isFirstOpenCamera && Platform.OS === 'ios' && (
165
- <>
166
- {renderCamera}
167
- <View style={styles.loading}>
168
- <ActivityIndicator size={'small'} color={Colors.Primary} />
169
- </View>
170
- </>
171
- )}
172
154
  <View style={[styles.loadingWrap]}>
173
155
  <Text style={styles.loadingText}>{t('loading')}</Text>
174
156
  </View>
@@ -194,7 +176,7 @@ const MediaPlayerDetail = ({
194
176
  />
195
177
  </View>
196
178
  ) : (
197
- !isFirstOpenCamera && renderCamera
179
+ renderCamera
198
180
  )}
199
181
 
200
182
  <View style={styles.buttonView}>
@@ -59,6 +59,7 @@ const MenuActionAddnew = memo(
59
59
  data={dataActions}
60
60
  keyExtractor={keyExtractor}
61
61
  renderItem={renderItem}
62
+ scrollIndicatorInsets={{ right: 1 }}
62
63
  />
63
64
  </View>
64
65
  </View>
@@ -57,6 +57,7 @@ const MenuActionList = memo(
57
57
  data={listItem}
58
58
  keyExtractor={keyExtractor}
59
59
  renderItem={renderItem}
60
+ scrollIndicatorInsets={{ right: 1 }}
60
61
  />
61
62
  </View>
62
63
  </View>
@@ -50,7 +50,7 @@ const MenuActionMore = memo(
50
50
  isVisible={isVisible}
51
51
  arrowStyle={styles.wrap}
52
52
  >
53
- <ScrollView>
53
+ <ScrollView scrollIndicatorInsets={{ right: 1 }}>
54
54
  {listMenuItem.map((item, index) => {
55
55
  return (
56
56
  <TouchableOpacity