@eohjsc/react-native-smart-city 0.3.91 → 0.3.93

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 (237) hide show
  1. package/package.json +5 -1
  2. package/src/Images/Common/reorder.svg +3 -0
  3. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +1 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +3 -1
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -10
  7. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +1 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +1 -1
  9. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +13 -5
  10. package/src/commons/ActionGroup/SliderRangeTemplate.js +100 -69
  11. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +27 -27
  12. package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -1
  13. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
  14. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
  15. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
  16. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
  17. package/src/commons/ActionGroup/__test__/index.test.js +0 -19
  18. package/src/commons/ActionGroup/index.js +0 -3
  19. package/src/commons/ActionTemplate/CurtainAction.js +3 -3
  20. package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
  21. package/src/commons/ActionTemplate/OnOffButtonAction.js +2 -2
  22. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
  23. package/src/commons/ActionTemplate/OnOffSimpleAction.js +2 -2
  24. package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
  25. package/src/commons/ActionTemplate/OnOffSmartLockAction.js +2 -2
  26. package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
  27. package/src/commons/ActionTemplate/OneButtonAction.js +1 -1
  28. package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
  29. package/src/commons/ActionTemplate/ThreeButtonAction.js +3 -3
  30. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
  31. package/src/commons/AlertAction/index.js +5 -0
  32. package/src/commons/Auth/AccountList.js +1 -1
  33. package/src/commons/Auth/__test__/OtpInputList.test.js +13 -17
  34. package/src/commons/Automate/ItemAutomate.js +10 -4
  35. package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
  36. package/src/commons/BottomButtonView/index.js +22 -4
  37. package/src/commons/Button/index.js +5 -0
  38. package/src/commons/Device/ConnectedViewHeader.js +0 -1
  39. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  40. package/src/commons/Device/Emergency/EmergencyDetail.js +4 -2
  41. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +4 -2
  42. package/src/commons/Device/ProgressBar/index.js +7 -11
  43. package/src/commons/Device/ProgressBar/styles.js +9 -4
  44. package/src/commons/Device/WindSpeed/Anemometer/index.js +3 -1
  45. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
  46. package/src/commons/Device/WindSpeed/LinearChart/index.js +4 -2
  47. package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
  48. package/src/commons/FlatListDnD/index.js +37 -0
  49. package/src/commons/FlatListDnD/styles.js +12 -0
  50. package/src/commons/Form/__test__/TextInput.test.js +1 -1
  51. package/src/commons/Header/HeaderCustom.js +10 -19
  52. package/src/commons/HorizontalPicker/index.js +65 -38
  53. package/src/commons/IconComponent/index.js +3 -2
  54. package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
  55. package/src/commons/MediaPlayer/index.js +11 -7
  56. package/src/commons/MenuActionMore/index.js +6 -4
  57. package/src/commons/Modal/ModalBottom.js +2 -3
  58. package/src/commons/Modal/ModalCustom.js +2 -3
  59. package/src/commons/NavBar/index.js +48 -50
  60. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +1 -1
  61. package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
  62. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
  63. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
  64. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +1 -1
  65. package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
  66. package/src/commons/PreventAccess/index.js +1 -1
  67. package/src/commons/Sharing/StationDevicePermissions.js +4 -4
  68. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
  69. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +2 -2
  70. package/src/commons/SubUnit/OneTap/ItemOneTap.js +12 -59
  71. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +16 -20
  72. package/src/commons/SubUnit/OneTap/index.js +20 -7
  73. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
  74. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  75. package/src/commons/ViewButtonBottom/index.js +32 -4
  76. package/src/configs/API.js +9 -0
  77. package/src/configs/AccessibilityLabel.js +2 -0
  78. package/src/configs/BLE.js +1 -0
  79. package/src/configs/Colors.js +1 -1
  80. package/src/configs/Constants.js +12 -18
  81. package/src/context/actionType.ts +2 -1
  82. package/src/context/mockStore.ts +1 -0
  83. package/src/context/reducer.ts +12 -1
  84. package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
  85. package/src/hooks/Common/index.js +0 -2
  86. package/src/hooks/Common/useKeyboardShow.js +4 -4
  87. package/src/hooks/Common/useStatusBar.js +2 -2
  88. package/src/hooks/Common/useTitleHeader.js +5 -7
  89. package/src/hooks/Explore/useKeyboardAnimated.js +10 -4
  90. package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
  91. package/src/hooks/IoT/useBluetoothConnection.js +20 -29
  92. package/src/hooks/index.js +1 -2
  93. package/src/hooks/useMqtt.js +95 -0
  94. package/src/iot/Monitor.js +2 -1
  95. package/src/iot/RemoteControl/Bluetooth.js +56 -19
  96. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +140 -0
  97. package/src/iot/mqtt.js +233 -0
  98. package/src/navigations/UnitStack.js +44 -12
  99. package/src/screens/AddLocationMaps/index.js +18 -16
  100. package/src/screens/AddLocationMaps/indexStyle.js +3 -0
  101. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
  102. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
  103. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +5 -13
  104. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +9 -11
  105. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
  106. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
  107. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
  108. package/src/screens/AddNewGateway/index.js +1 -1
  109. package/src/screens/AllCamera/index.js +2 -3
  110. package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
  111. package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
  112. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
  113. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
  114. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseAction.js +78 -119
  115. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseConfig.js +45 -73
  116. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
  117. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/SelectDevices.js +3 -3
  118. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
  119. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +3 -3
  120. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
  121. package/src/screens/{AddNewAction → Automate/AddNewAction}/NewActionWrapper.js +5 -7
  122. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectControlDevices.js +11 -49
  123. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectMonitorDevices.js +10 -42
  124. package/src/screens/{AddNewAction → Automate/AddNewAction}/SetupConfigCondition.js +52 -101
  125. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
  126. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
  127. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +4 -2
  128. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseAction.test.js +10 -11
  129. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseConfig.test.js +26 -27
  130. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectControlDevices.test.js +9 -9
  131. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectMonitorDevices.test.js +5 -5
  132. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SetupSensor.test.js +52 -16
  133. package/src/screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart.js +25 -0
  134. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +78 -0
  135. package/src/screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart.js +29 -0
  136. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/__test__/AddNewAutoSmart.test.js +18 -41
  137. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/styles/AddNewAutoSmartStyles.js +1 -1
  138. package/src/screens/Automate/Components/InputName.js +64 -0
  139. package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +3 -3
  140. package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
  141. package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +17 -31
  142. package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +49 -51
  143. package/src/screens/Automate/MultiUnits.js +69 -67
  144. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
  145. package/src/screens/Automate/OneTap/index.js +16 -0
  146. package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
  147. package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
  148. package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
  149. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
  150. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
  151. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +110 -74
  152. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
  153. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
  154. package/src/screens/Automate/ScriptDetail/index.js +360 -0
  155. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/utils.js +32 -31
  156. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
  157. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
  158. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
  159. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
  160. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
  161. package/src/screens/Automate/SetSchedule/index.js +140 -0
  162. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
  163. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
  164. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
  165. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
  166. package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
  167. package/src/screens/Automate/__test__/MultiUnits.test.js +77 -121
  168. package/src/screens/Automate/__test__/index.test.js +3 -10
  169. package/src/screens/Automate/constants.js +0 -0
  170. package/src/screens/Automate/index.js +12 -23
  171. package/src/screens/ChangePosition/__test__/index.test.js +75 -0
  172. package/src/screens/ChangePosition/index.js +112 -0
  173. package/src/screens/ChangePosition/styles.js +87 -0
  174. package/src/screens/Device/__test__/detail.test.js +203 -258
  175. package/src/screens/Device/__test__/mqttDetail.test.js +599 -0
  176. package/src/screens/Device/__test__/sensorDisplayItem.test.js +4 -0
  177. package/src/screens/Device/components/SensorDisplayItem.js +3 -8
  178. package/src/screens/Device/components/VisualChart.js +55 -8
  179. package/src/screens/Device/detail.js +78 -30
  180. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
  181. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +13 -3
  182. package/src/screens/Device/hooks/useEvaluateValue.js +20 -2
  183. package/src/screens/Device/styles.js +7 -0
  184. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
  185. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
  186. package/src/screens/Notification/__test__/Notification.test.js +1 -1
  187. package/src/screens/PlayBackCamera/index.js +2 -3
  188. package/src/screens/SelectUnit/__test__/index.test.js +8 -13
  189. package/src/screens/SharedUnit/index.js +5 -4
  190. package/src/screens/Sharing/SelectUser.js +2 -2
  191. package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
  192. package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
  193. package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
  194. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
  195. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +8 -4
  196. package/src/screens/SmartAccount/index.js +9 -9
  197. package/src/screens/SmartAccount/style.js +8 -7
  198. package/src/screens/SubUnit/ManageSubUnit.js +4 -4
  199. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
  200. package/src/screens/TDSGuide/index.js +1 -1
  201. package/src/screens/Template/GatewayList.js +4 -1
  202. package/src/screens/Template/__test__/detail.test.js +14 -20
  203. package/src/screens/Template/detail.js +1 -0
  204. package/src/screens/UVIndexGuide/index.js +2 -2
  205. package/src/screens/Unit/Detail.js +10 -24
  206. package/src/screens/Unit/SelectAddToFavorites.js +1 -1
  207. package/src/screens/Unit/Summaries.js +6 -17
  208. package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
  209. package/src/screens/Unit/__test__/Detail.test.js +3 -1
  210. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
  211. package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
  212. package/src/screens/Unit/__test__/Summaries.test.js +2 -2
  213. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
  214. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
  215. package/src/screens/WaterQualityGuide/index.js +10 -5
  216. package/src/utils/FactoryGateway.js +525 -0
  217. package/src/utils/I18n/translations/en.json +28 -19
  218. package/src/utils/I18n/translations/vi.json +26 -20
  219. package/src/utils/Route/index.js +5 -1
  220. package/src/utils/Utils.js +40 -0
  221. package/src/utils/__test__/Utils.test.js +6 -0
  222. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
  223. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
  224. package/src/commons/Auth/SocialButton.js +0 -54
  225. package/src/commons/Auth/__test__/SocialButton.test.js +0 -46
  226. package/src/commons/Device/SensorConnectedStatus.js +0 -56
  227. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +0 -29
  228. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
  229. package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
  230. package/src/hooks/useInitDeepLink.js +0 -25
  231. package/src/screens/AddNewAutoSmart/index.js +0 -149
  232. package/src/screens/AddNewOneTap/index.js +0 -156
  233. package/src/screens/ScriptDetail/hooks/index.js +0 -136
  234. package/src/screens/ScriptDetail/index.js +0 -446
  235. package/src/screens/SetSchedule/index.js +0 -200
  236. /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
  237. /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
@@ -1,13 +1,23 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
+ import { Switch } from 'react-native';
3
4
 
4
5
  import { mockSCStore } from '../../../context/mockStore';
5
6
  import { SCProvider } from '../../../context';
6
7
  import SwitchButtonTemplate from '../OnOffTemplate/SwitchButtonTemplate';
8
+ import { useConfigGlobalState } from '../../../iot/states';
7
9
 
8
- const wrapComponent = (actionGroup, mockDoAction) => (
10
+ jest.mock('../../../iot/states', () => ({
11
+ useConfigGlobalState: jest.fn(),
12
+ }));
13
+
14
+ const wrapComponent = (actionGroup, mockDoAction, isOn) => (
9
15
  <SCProvider initState={mockSCStore({})}>
10
- <SwitchButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
16
+ <SwitchButtonTemplate
17
+ actionGroup={actionGroup}
18
+ doAction={mockDoAction}
19
+ isOn={isOn}
20
+ />
11
21
  </SCProvider>
12
22
  );
13
23
 
@@ -50,37 +60,64 @@ describe('Test SwitchButtonTemplate', () => {
50
60
  action_off_data: action_off_data,
51
61
  icon_off: 'caret-up',
52
62
  text_off: 'OFF',
63
+ config: 1,
53
64
  },
54
65
  };
55
66
  let wrapper;
56
67
 
57
- const assertRender = async () => {
68
+ const assertRender = async (state) => {
58
69
  const mockDoAction = jest.fn();
59
70
 
60
71
  await act(async () => {
61
- wrapper = create(wrapComponent(actionGroup, mockDoAction));
72
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction));
62
73
  });
63
74
 
64
75
  const renderJson = wrapper.toJSON();
76
+ const switchButton = wrapper.root.findByType(Switch);
77
+
65
78
  expect(renderJson[1].props?.visible).toEqual(false);
66
79
  expect(renderJson[1]?.type).toEqual('Modal');
80
+ expect(switchButton.props.value).toEqual(state);
67
81
  };
68
82
 
69
83
  it('render state on', async () => {
70
- await assertRender(true, 'ON');
84
+ useConfigGlobalState.mockImplementation(() => [
85
+ {
86
+ 1: {
87
+ value: 1,
88
+ },
89
+ },
90
+ jest.fn(),
91
+ ]);
92
+ await assertRender(true);
71
93
  });
72
94
 
73
95
  it('render state off', async () => {
74
- await assertRender(false, 'OFF');
96
+ useConfigGlobalState.mockImplementation(() => [
97
+ {
98
+ 1: {
99
+ value: 0,
100
+ },
101
+ },
102
+ jest.fn(),
103
+ ]);
104
+ await assertRender(false);
75
105
  });
76
106
 
77
107
  const assertActionCall = async (state, action_data) => {
78
108
  const mockDoAction = jest.fn();
79
109
  await act(async () => {
80
- wrapper = create(wrapComponent(actionGroup, mockDoAction));
110
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, state));
81
111
  });
82
-
83
112
  expect(mockDoAction).not.toHaveBeenCalled();
113
+ const root = wrapper.root;
114
+
115
+ const item = root.findByType(Switch);
116
+ await act(async () => {
117
+ item.props.onValueChange();
118
+ });
119
+
120
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null);
84
121
  };
85
122
 
86
123
  it('action state on', async () => {
@@ -487,25 +487,6 @@ describe('Test ActionGroup', () => {
487
487
  expect(options).toHaveLength(actionGroup.configuration.options.length);
488
488
  });
489
489
 
490
- it('render CurtainButtonTemplate', async () => {
491
- // todo Bang remove
492
- Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
493
- const actionGroup = {
494
- template: 'curtain_action_template',
495
- title: 'Timer',
496
- configuration: {},
497
- };
498
- const mockDoAction = jest.fn();
499
- await act(async () => {
500
- wrapper = renderer.create(
501
- wrapComponent(actionGroup, mockDoAction, sensor)
502
- );
503
- });
504
- const instance = wrapper.root;
505
- const texts = instance.findAllByType(TouchableOpacity);
506
- expect(texts).toHaveLength(3);
507
- });
508
-
509
490
  it('render SmartTiviActionTemplate', async () => {
510
491
  Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
511
492
  const actionGroup = {
@@ -7,7 +7,6 @@ import NumberUpDownActionTemplate from './NumberUpDownActionTemplate';
7
7
  import OptionsDropdownActionTemplate from './OptionsDropdownActionTemplate';
8
8
  import OnOffTemplate from './OnOffTemplate';
9
9
  import TimerActionTemplate from './TimerActionTemplate';
10
- import CurtainButtonTemplate from './CurtainButtonTemplate';
11
10
  import SmartTiviActionTemplate from './SmartTiviActionTemplate/SmartTiviActionTemplate';
12
11
  import ColorPickerTemplate from './ColorPickerTemplate';
13
12
  import SliderRangeTemplate from './SliderRangeTemplate';
@@ -37,8 +36,6 @@ export const getActionComponent = (template) => {
37
36
  return OptionsDropdownActionTemplate;
38
37
  case 'TimerActionTemplate':
39
38
  return TimerActionTemplate;
40
- case 'curtain_action_template':
41
- return CurtainButtonTemplate;
42
39
  case 'SmartTiviActionTemplate':
43
40
  return SmartTiviActionTemplate;
44
41
  case 'color_picker_template':
@@ -37,19 +37,19 @@ const CurtainAction = ({ configuration, onPress, template }) => {
37
37
  return (
38
38
  <>
39
39
  <TouchableOpacity onPress={onPressActionClose}>
40
- <Text type="H4" style={styles.textwithline}>
40
+ <Text type="H4" style={styles.textWithLine}>
41
41
  {text1}
42
42
  </Text>
43
43
  </TouchableOpacity>
44
44
 
45
45
  <TouchableOpacity onPress={onPressActionStop}>
46
- <Text type="H4" style={styles.textwithline}>
46
+ <Text type="H4" style={styles.textWithLine}>
47
47
  {text2}
48
48
  </Text>
49
49
  </TouchableOpacity>
50
50
 
51
51
  <TouchableOpacity onPress={onPressActionOpen}>
52
- <Text type="H4" style={styles.textwithline}>
52
+ <Text type="H4" style={styles.textWithLine}>
53
53
  {text3}
54
54
  </Text>
55
55
  </TouchableOpacity>
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -33,7 +33,7 @@ const OnOffButtonAction = ({ title, configuration, onPress, template }) => {
33
33
  <TouchableOpacity onPress={onPressActionOn}>
34
34
  <Text
35
35
  type="H4"
36
- style={styles.textwithline}
36
+ style={styles.textWithLine}
37
37
  accessibilityLabel={AccessibilityLabel.ON_OFF_BUTTON_ACTION_TITLE}
38
38
  >
39
39
  {title} {text_on}
@@ -42,7 +42,7 @@ const OnOffButtonAction = ({ title, configuration, onPress, template }) => {
42
42
  <TouchableOpacity onPress={onPressActionOff}>
43
43
  <Text
44
44
  type="H4"
45
- style={styles.textwithline}
45
+ style={styles.textWithLine}
46
46
  accessibilityLabel={AccessibilityLabel.ON_OFF_BUTTON_ACTION_TITLE}
47
47
  >
48
48
  {title} {text_off}
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -36,12 +36,12 @@ const OnOffSimpleAction = ({ configuration, onPress, template }) => {
36
36
  accessibilityLabel={AccessibilityLabel.ON_OFF_SIMPLE_ACTION_ON}
37
37
  onPress={onPressActionOn}
38
38
  >
39
- <Text type="H4" style={styles.textwithline}>
39
+ <Text type="H4" style={styles.textWithLine}>
40
40
  {t('text_on')}
41
41
  </Text>
42
42
  </TouchableOpacity>
43
43
  <TouchableOpacity onPress={onPressActionOff}>
44
- <Text type="H4" style={styles.textwithline}>
44
+ <Text type="H4" style={styles.textWithLine}>
45
45
  {t('text_off')}
46
46
  </Text>
47
47
  </TouchableOpacity>
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -31,13 +31,13 @@ const OnOffSmartLockAction = ({ configuration, onPress, template }) => {
31
31
  return (
32
32
  <>
33
33
  <TouchableOpacity onPress={onPressActionClose}>
34
- <Text type="H4" style={styles.textwithline}>
34
+ <Text type="H4" style={styles.textWithLine}>
35
35
  {text_off}
36
36
  </Text>
37
37
  </TouchableOpacity>
38
38
 
39
39
  <TouchableOpacity onPress={onPressActionOpen}>
40
- <Text type="H4" style={styles.textwithline}>
40
+ <Text type="H4" style={styles.textWithLine}>
41
41
  {text_on}
42
42
  </Text>
43
43
  </TouchableOpacity>
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -17,7 +17,7 @@ const OneButtonAction = ({ configuration, onPress, template }) => {
17
17
  return (
18
18
  <>
19
19
  <TouchableOpacity onPress={onPressAction}>
20
- <Text type="H4" style={styles.textwithline}>
20
+ <Text type="H4" style={styles.textWithLine}>
21
21
  {text}
22
22
  </Text>
23
23
  </TouchableOpacity>
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -35,19 +35,19 @@ const ThreeButtonAction = ({ configuration, onPress, template }) => {
35
35
  return (
36
36
  <>
37
37
  <TouchableOpacity onPress={onPressAction1}>
38
- <Text type="H4" style={styles.textwithline}>
38
+ <Text type="H4" style={styles.textWithLine}>
39
39
  {text1}
40
40
  </Text>
41
41
  </TouchableOpacity>
42
42
 
43
43
  <TouchableOpacity onPress={onPressAction2}>
44
- <Text type="H4" style={styles.textwithline}>
44
+ <Text type="H4" style={styles.textWithLine}>
45
45
  {text2}
46
46
  </Text>
47
47
  </TouchableOpacity>
48
48
 
49
49
  <TouchableOpacity onPress={onPressAction3}>
50
- <Text type="H4" style={styles.textwithline}>
50
+ <Text type="H4" style={styles.textWithLine}>
51
51
  {text3}
52
52
  </Text>
53
53
  </TouchableOpacity>
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
- textwithline: {
5
+ textWithLine: {
6
6
  paddingBottom: 16,
7
7
  paddingTop: 16,
8
8
  borderBottomWidth: 1,
@@ -80,6 +80,8 @@ const AlertAction = ({
80
80
  styleButtonLeft={boxLeftButtonStyle}
81
81
  styleButtonRight={boxRightButtonStyle}
82
82
  accessibilityLabelPrefix={accessibilityLabelPrefix}
83
+ wrapStyle={styles.wrapViewButtonStyle}
84
+ disableKeyBoardAnimated
83
85
  />
84
86
  </View>
85
87
  </Animated.View>
@@ -121,6 +123,9 @@ const styles = StyleSheet.create({
121
123
  descriptionText: {
122
124
  paddingHorizontal: 16,
123
125
  },
126
+ wrapViewButtonStyle: {
127
+ position: 'relative',
128
+ },
124
129
  });
125
130
 
126
131
  export default AlertAction;
@@ -7,7 +7,7 @@ const AccountList = ({ accounts }) => {
7
7
  return (
8
8
  <ScrollView scrollIndicatorInsets={{ right: 1 }}>
9
9
  {accounts.map((account) => (
10
- <AccountItem key={account.id || account.name} account={account} />
10
+ <AccountItem key={account.id} account={account} />
11
11
  ))}
12
12
  </ScrollView>
13
13
  );
@@ -10,7 +10,7 @@ describe('Test OtpInputList', () => {
10
10
  let tree;
11
11
 
12
12
  for (const code of list_code) {
13
- test(`create OtpInputList ${code} onfinishInputCode is func`, async () => {
13
+ it(`create OtpInputList ${code} onfinishInputCode is func`, async () => {
14
14
  await act(async () => {
15
15
  tree = await renderer.create(
16
16
  <OtpInputList onfinishInputCode={mockFunc} />
@@ -19,14 +19,12 @@ describe('Test OtpInputList', () => {
19
19
 
20
20
  const instance = tree.root;
21
21
  const textInputs = instance.findAllByType(TextInput);
22
- await Promise.all(
23
- textInputs.map(async (el, index) => {
24
- await act(async () => {
25
- el.props.onFocus(code); // TODO check onFocus(code)
26
- el.props.onChangeText('1');
27
- });
28
- })
29
- );
22
+ for (let index = 0; index < textInputs.length; index++) {
23
+ await act(async () => {
24
+ textInputs[index].props.onFocus(code);
25
+ textInputs[index].props.onChangeText('1');
26
+ });
27
+ }
30
28
  expect(mockFunc).toHaveBeenCalledWith('111111');
31
29
  });
32
30
  }
@@ -37,14 +35,12 @@ describe('Test OtpInputList', () => {
37
35
  });
38
36
  const instance = tree.root;
39
37
  const textInputs = instance.findAllByType(TextInput);
40
- await Promise.all(
41
- textInputs.map(async (el, index) => {
42
- await act(async () => {
43
- el.props.onFocus();
44
- el.props.onChangeText('');
45
- });
46
- })
47
- );
38
+ for (let index = 0; index < textInputs.length; index++) {
39
+ await act(async () => {
40
+ textInputs[index].props.onFocus();
41
+ textInputs[index].props.onChangeText('1');
42
+ });
43
+ }
48
44
  expect(mockFunc).toHaveBeenCalledWith('111111');
49
45
  });
50
46
  });
@@ -5,20 +5,26 @@ import { Colors } from '../../configs';
5
5
  import styles from './ItemAutomateStyles';
6
6
  import { AUTOMATES } from '../../configs/Constants';
7
7
  import { useTranslations } from '../../hooks/Common/useTranslations';
8
+ import { generateAutomationConditionText } from '../../screens/Automate/ScriptDetail/utils';
9
+ import { useGetEvaluateValue } from '../../screens/Device/hooks/useEvaluateValue';
8
10
 
9
11
  const ItemAutomate = ({
10
- type,
12
+ automate,
11
13
  isSelected = false,
12
14
  disabledOnPress = false,
13
- textCondition,
14
15
  index,
15
16
  setSelectedIndex,
16
17
  onPress,
17
18
  }) => {
18
19
  const t = useTranslations();
19
- const item = AUTOMATES[type];
20
- const isItemOneTap = AUTOMATES[type] === AUTOMATES.one_tap;
20
+ const item = AUTOMATES[automate?.type];
21
+ const isItemOneTap = AUTOMATES[automate?.type] === AUTOMATES.one_tap;
21
22
  const Icon = item?.icon;
23
+ const valueEvaluation = useGetEvaluateValue(automate?.config);
24
+
25
+ const textCondition = useMemo(() => {
26
+ return generateAutomationConditionText(automate, valueEvaluation, t);
27
+ }, [automate, t, valueEvaluation]);
22
28
 
23
29
  const renderText = useMemo(() => {
24
30
  if (textCondition) {
@@ -7,20 +7,17 @@ import { mockSCStore } from '../../../context/mockStore';
7
7
  import Text from '../../Text';
8
8
  import ItemAutomate from '../ItemAutomate';
9
9
 
10
- const wrapComponent = (rest) => (
10
+ const wrapComponent = (props) => (
11
11
  <SCProvider initState={mockSCStore({})}>
12
- <ItemAutomate {...rest} />
12
+ <ItemAutomate {...props} />
13
13
  </SCProvider>
14
14
  );
15
15
 
16
16
  describe('Test ItemAutomate', () => {
17
17
  let tree;
18
- let defaultProps = {
19
- type: 'one_tap',
20
- };
21
18
  it('Test render', async () => {
22
19
  await act(async () => {
23
- tree = await create(wrapComponent(defaultProps));
20
+ tree = await create(wrapComponent({ automate: { type: 'one_tap' } }));
24
21
  });
25
22
  const instance = tree.root;
26
23
  const texts = instance.findAllByType(Text);
@@ -29,12 +26,15 @@ describe('Test ItemAutomate', () => {
29
26
 
30
27
  it('Test render TouchableOpacity', async () => {
31
28
  const mockOnPress = jest.fn();
32
- defaultProps = {
33
- type: 'one_tap',
34
- onPress: mockOnPress,
35
- };
36
29
  await act(async () => {
37
- tree = await create(wrapComponent(defaultProps));
30
+ tree = await create(
31
+ wrapComponent({
32
+ automate: {
33
+ type: 'one_tap',
34
+ },
35
+ onPress: mockOnPress,
36
+ })
37
+ );
38
38
  });
39
39
  const instance = tree.root;
40
40
  const touchableOpacities = instance.findAllByType(TouchableOpacity);
@@ -1,7 +1,8 @@
1
- import React, { memo } from 'react';
2
- import { View, StyleSheet } from 'react-native';
1
+ import React, { memo, useState, useEffect } from 'react';
2
+ import { StyleSheet, Animated, Easing, Platform } from 'react-native';
3
3
 
4
4
  import { AccessibilityLabel } from '../../configs/Constants';
5
+ import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
5
6
  import Button from '../Button';
6
7
 
7
8
  const BottomButtonView = memo(
@@ -20,13 +21,28 @@ const BottomButtonView = memo(
20
21
  typeMain = 'primary',
21
22
  typeSecondary = 'cancel',
22
23
  accessibilityLabelPrefix = '',
24
+ disableBackgroundMainButton = false,
25
+ disableBackgroundSecondButton = false,
23
26
  }) => {
27
+ const transY = useKeyboardAnimated();
28
+ const [keyboardAnim] = useState(new Animated.Value(0));
29
+
30
+ useEffect(() => {
31
+ Animated.timing(keyboardAnim, {
32
+ toValue: transY,
33
+ duration: Platform.OS === 'ios' ? 220 : 0,
34
+ easing: Easing.linear(),
35
+ useNativeDriver: false,
36
+ }).start();
37
+ }, [keyboardAnim, transY]);
38
+
24
39
  return (
25
- <View
40
+ <Animated.View
26
41
  style={[
27
42
  typeMain === 'CardShadow'
28
43
  ? styleCustom.container1
29
44
  : styleCustom.container,
45
+ { bottom: keyboardAnim },
30
46
  rowButton && styleCustom.horizontalContainer,
31
47
  style,
32
48
  ]}
@@ -42,6 +58,7 @@ const BottomButtonView = memo(
42
58
  textType={textTypeMain}
43
59
  style={rowButton && styleCustom.buttonMainRow}
44
60
  accessibilityLabel={`${accessibilityLabelPrefix}${AccessibilityLabel.BOTTOM_VIEW_MAIN}`}
61
+ disableBackground={disableBackgroundMainButton}
45
62
  />
46
63
  )}
47
64
  {secondaryTitle && (
@@ -56,9 +73,10 @@ const BottomButtonView = memo(
56
73
  : styleCustom.buttonSecondaryColumn
57
74
  }
58
75
  accessibilityLabel={`${accessibilityLabelPrefix}${AccessibilityLabel.BOTTOM_VIEW_SECONDARY}`}
76
+ disableBackground={disableBackgroundSecondButton}
59
77
  />
60
78
  )}
61
- </View>
79
+ </Animated.View>
62
80
  );
63
81
  }
64
82
  );
@@ -133,6 +133,7 @@ export default ({
133
133
  textSemiBold = true,
134
134
  style,
135
135
  accessibilityLabel,
136
+ disableBackground = false,
136
137
  }) => {
137
138
  const styleButton = ButtonStyle[type];
138
139
  const textColor = TextColor[type];
@@ -153,6 +154,7 @@ export default ({
153
154
  isCardShadow && styles.buttonLeft,
154
155
  styleButton,
155
156
  style,
157
+ disableBackground && styles.disableBackground,
156
158
  ]}
157
159
  onPress={onPress}
158
160
  disabled={isDisabled}
@@ -202,4 +204,7 @@ const styles = StyleSheet.create({
202
204
  alignItems: 'flex-start',
203
205
  backgroundColor: Colors.Gray1,
204
206
  },
207
+ disableBackground: {
208
+ backgroundColor: Colors.Transparent,
209
+ },
205
210
  });
@@ -1,7 +1,6 @@
1
1
  import React, { memo } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
-
5
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
6
5
  import { Colors } from '../../configs';
7
6
  import Text from '../../commons/Text';
@@ -72,8 +72,9 @@ const DeviceAlertStatus = memo(
72
72
  return (
73
73
  <View style={[style, stylesOffset.moveDownOffset]}>
74
74
  {listStatus &&
75
- listStatus.map((status) => (
75
+ listStatus.map((status, index) => (
76
76
  <AlertStatusMachine
77
+ key={index}
77
78
  accessibilityLabel={AccessibilityLabel.ALERT_STATUS_MACHINE}
78
79
  message={
79
80
  (status.standard && t(status.standard)) ||
@@ -9,7 +9,6 @@ import { RowUser } from '../../RowUser';
9
9
  import { IconFill, IconOutline } from '@ant-design/icons-react-native';
10
10
  import { useEmeragencyContacts } from '../../../screens/EmergencyContacts/hook';
11
11
  import { useIsFocused } from '@react-navigation/native';
12
- import _ from 'lodash';
13
12
 
14
13
  const { standardizeHeight } = standardizeCameraScreenSize(
15
14
  Device.screenWidth + 86
@@ -17,6 +16,7 @@ const { standardizeHeight } = standardizeCameraScreenSize(
17
16
 
18
17
  const EmergencyDetail = memo(({ item }) => {
19
18
  const t = useTranslations();
19
+ const { uri, preview_uri } = item?.configuration?.camera;
20
20
  const groupId = item?.configuration?.device?.group?.id;
21
21
  const isFocused = useIsFocused();
22
22
  const { listContacts, getListContacts } = useEmeragencyContacts();
@@ -35,8 +35,10 @@ const EmergencyDetail = memo(({ item }) => {
35
35
  <View style={styles.first}>
36
36
  <Text type="H4">{t('camera')}</Text>
37
37
  <MediaPlayer
38
- uri={_.get(item, 'configuration.uri', '')}
38
+ uri={uri}
39
+ previewUri={preview_uri}
39
40
  style={styles.camera}
41
+ key={'camera-emergency'}
40
42
  />
41
43
  </View>
42
44
  <View style={styles.second}>
@@ -28,8 +28,10 @@ describe('Test EmergencyDetail', () => {
28
28
  it('create EmergencyDetail', async () => {
29
29
  const item = {
30
30
  configuration: {
31
- uri: '123',
32
- preview_uri: '123',
31
+ camera: {
32
+ uri: '123',
33
+ preview_uri: '123',
34
+ },
33
35
  device: {
34
36
  group: {
35
37
  id: 1,
@@ -15,7 +15,7 @@ const ProgressBar = memo(({ data = [], item }) => {
15
15
  }, [item?.configuration?.max_value]);
16
16
  const { value = 0, measure, unit } = data.length ? data[0] : {};
17
17
  const percent = value / maxValue; // a number between 0 and 1
18
-
18
+ const isNotValue = ['', null, undefined, NaN].includes(value);
19
19
  return (
20
20
  <View style={styles.container}>
21
21
  <Text size={16} style={styles.textLabel}>
@@ -28,19 +28,15 @@ const ProgressBar = memo(({ data = [], item }) => {
28
28
 
29
29
  <View style={styles.wrapProgressBar}>
30
30
  <Progress.Bar
31
- progress={percent}
31
+ style={styles.progressBar}
32
+ width={null}
32
33
  height={40}
33
- width={200}
34
- color={Colors.Blue16}
34
+ progress={percent}
35
35
  unfilledColor={Colors.Blue15}
36
- borderWidth={0}
37
- borderRadius={10}
38
36
  />
39
- <View>
40
- <Text numberOfLines={1} style={styles.textValue}>
41
- {value}
42
- </Text>
43
- </View>
37
+ <Text numberOfLines={1} style={styles.textValue}>
38
+ {isNotValue ? '--' : value}
39
+ </Text>
44
40
  </View>
45
41
  </View>
46
42
  );