@eohjsc/react-native-smart-city 0.2.95 → 0.2.98

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 (113) hide show
  1. package/package.json +17 -5
  2. package/src/Images/Common/member.svg +4 -0
  3. package/src/Images/Common/owner.svg +3 -0
  4. package/src/commons/Action/ItemQuickAction.js +5 -2
  5. package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
  6. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +15 -3
  7. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +4 -1
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  9. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +12 -10
  10. package/src/commons/ActionGroup/OnOffTemplate/index.js +38 -5
  11. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +13 -3
  12. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +14 -4
  15. package/src/commons/ActionGroup/TimerActionTemplate.js +9 -1
  16. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +7 -3
  17. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  18. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  19. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  20. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +2 -2
  21. package/src/commons/Auth/AccountList.js +1 -1
  22. package/src/commons/Connecting/__test__/Connecting.test.js +23 -0
  23. package/src/commons/Connecting/index.js +67 -0
  24. package/src/commons/Connecting/styles.js +28 -0
  25. package/src/commons/ConnectingProcess/index.js +3 -54
  26. package/src/commons/Device/HistoryChart.js +6 -2
  27. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  28. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  29. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  30. package/src/commons/FullLoading/index.js +2 -1
  31. package/src/commons/MenuActionAddnew/index.js +1 -0
  32. package/src/commons/MenuActionList/index.js +1 -0
  33. package/src/commons/MenuActionMore/index.js +9 -2
  34. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  35. package/src/commons/PreventAccess/index.js +67 -0
  36. package/src/commons/PreventAccess/styles.js +33 -0
  37. package/src/commons/Sharing/MemberList.js +5 -10
  38. package/src/commons/Sharing/RowMember.js +128 -38
  39. package/src/commons/Sharing/__test__/MemberList.test.js +3 -3
  40. package/src/commons/Sharing/__test__/RowMember.test.js +4 -4
  41. package/src/configs/API.js +10 -0
  42. package/src/configs/Constants.js +14 -0
  43. package/src/context/actionType.ts +1 -0
  44. package/src/context/reducer.ts +3 -0
  45. package/src/hooks/Common/useSensorsStatus.js +33 -23
  46. package/src/iot/RemoteControl/GoogleHome.js +24 -11
  47. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +32 -0
  48. package/src/navigations/UnitStack.js +16 -0
  49. package/src/screens/AQIGuide/index.js +1 -1
  50. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  51. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  52. package/src/screens/AddCommon/SelectUnit.js +1 -0
  53. package/src/screens/AddLocationMaps/index.js +4 -1
  54. package/src/screens/AddNewAction/SelectSensorDevices.js +12 -2
  55. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +34 -92
  56. package/src/screens/AddNewDevice/index.js +1 -0
  57. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +12 -3
  58. package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +5 -1
  59. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +13 -2
  60. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  61. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  62. package/src/screens/AddNewGateway/index.js +1 -0
  63. package/src/screens/AddNewOneTap/index.js +1 -1
  64. package/src/screens/Automate/index.js +2 -0
  65. package/src/screens/Device/detail.js +25 -4
  66. package/src/screens/EditActionsList/Styles/indexStyles.js +1 -0
  67. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
  68. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +29 -11
  69. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +15 -0
  70. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +74 -0
  71. package/src/screens/EmergencySetting/index.js +4 -1
  72. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +124 -0
  73. package/src/screens/EnterPassword/index.js +84 -0
  74. package/src/screens/EnterPassword/styles.js +36 -0
  75. package/src/screens/Explore/index.js +2 -0
  76. package/src/screens/ManageAccess/index.js +1 -0
  77. package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
  78. package/src/screens/ScriptDetail/index.js +2 -2
  79. package/src/screens/SelectUnit/index.js +1 -0
  80. package/src/screens/SetSchedule/index.js +4 -1
  81. package/src/screens/SharedUnit/index.js +2 -0
  82. package/src/screens/Sharing/Components/ItemChangeRole.js +43 -0
  83. package/src/screens/Sharing/Components/SensorItem.js +7 -1
  84. package/src/screens/Sharing/Components/Styles/ItemChangeRoleStyles.js +35 -0
  85. package/src/screens/Sharing/Components/__test__/ItemChangeRole.test.js +37 -0
  86. package/src/screens/Sharing/Components/__test__/SensorItem.test.js +53 -0
  87. package/src/screens/Sharing/InfoMemberUnit.js +274 -0
  88. package/src/screens/Sharing/MemberList.js +44 -46
  89. package/src/screens/Sharing/SelectPermission.js +94 -12
  90. package/src/screens/Sharing/Styles/inforMemberUnitStyles.js +92 -0
  91. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +121 -0
  92. package/src/screens/Sharing/__test__/MemberList.test.js +9 -24
  93. package/src/screens/Sharing/__test__/SelectPermission.test.js +53 -0
  94. package/src/screens/Sharing/hooks/index.js +79 -32
  95. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  96. package/src/screens/SubUnit/ManageSubUnit.js +1 -0
  97. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  98. package/src/screens/TDSGuide/index.js +4 -1
  99. package/src/screens/UVIndexGuide/index.js +1 -1
  100. package/src/screens/Unit/Detail.js +28 -13
  101. package/src/screens/Unit/ManageUnit.js +5 -5
  102. package/src/screens/Unit/ManageUnitStyles.js +1 -0
  103. package/src/screens/Unit/SelectAddress.js +4 -1
  104. package/src/screens/Unit/Station/index.js +1 -0
  105. package/src/screens/Unit/Summaries.js +1 -1
  106. package/src/screens/Unit/__test__/Detail.test.js +25 -5
  107. package/src/screens/UnitSummary/__test__/index.test.js +32 -0
  108. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
  109. package/src/screens/WaterQualityGuide/index.js +1 -1
  110. package/src/utils/I18n/translations/en.json +16 -1
  111. package/src/utils/I18n/translations/vi.json +14 -1
  112. package/src/utils/Route/index.js +2 -0
  113. package/src/utils/Utils.js +21 -0
@@ -1,11 +1,25 @@
1
+ /* eslint-disable promise/prefer-await-to-callbacks */
1
2
  import { TESTID } from '../../../configs/Constants';
2
3
  import { watchMultiConfigs } from '../../../iot/Monitor';
3
4
  import React from 'react';
4
5
  import { View } from 'react-native';
6
+ import { useSelector } from 'react-redux';
5
7
  import { act, create } from 'react-test-renderer';
6
8
  import OnOffTemplate from '../OnOffTemplate';
7
9
  import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
8
10
  import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
11
+ import { mockSCStore } from '../../../context/mockStore';
12
+ import { SCProvider } from '../../../context';
13
+
14
+ const wrapComponent = (actionGroup, mockDoAction, sensor) => (
15
+ <SCProvider initState={mockSCStore({})}>
16
+ <OnOffTemplate
17
+ actionGroup={actionGroup}
18
+ doAction={mockDoAction}
19
+ sensor={sensor}
20
+ />
21
+ </SCProvider>
22
+ );
9
23
 
10
24
  jest.mock('../../../iot/Monitor');
11
25
 
@@ -13,9 +27,15 @@ jest.mock('../../../iot/states', () => ({
13
27
  useConfigGlobalState: () => [{ 5: 2 }, null],
14
28
  }));
15
29
 
30
+ jest.mock('react-redux', () => ({
31
+ ...jest.requireActual('react-redux'),
32
+ useSelector: jest.fn(),
33
+ }));
34
+
16
35
  describe('Test OnOffTemplate', () => {
17
- let wrapper;
18
36
  let actionGroup;
37
+ let tree;
38
+ let sensor;
19
39
 
20
40
  const action_data = {
21
41
  color: '#00979D',
@@ -62,20 +82,23 @@ describe('Test OnOffTemplate', () => {
62
82
  },
63
83
  title: 'Turn on / off',
64
84
  };
85
+
86
+ sensor = { name: 'Sensor' };
87
+
88
+ const localState = {
89
+ isOnSwich: false,
90
+ };
91
+ useSelector.mockImplementation((cb) => {
92
+ return cb(localState);
93
+ });
65
94
  });
66
95
 
67
96
  test('render with template OnOffSimpleActionTemplate', async () => {
68
97
  const mockDoAction = jest.fn();
69
98
  await act(async () => {
70
- wrapper = await create(
71
- <OnOffTemplate
72
- actionGroup={actionGroup}
73
- doAction={mockDoAction}
74
- sensor={{}}
75
- />
76
- );
99
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
77
100
  });
78
- const instance = wrapper.root;
101
+ const instance = tree.root;
79
102
  const template = instance.findAllByType(OnOffSimpleTemplate);
80
103
  expect(template).toHaveLength(1);
81
104
  });
@@ -84,15 +107,9 @@ describe('Test OnOffTemplate', () => {
84
107
  actionGroup.template = 'on_off_button_action_template';
85
108
  const mockDoAction = jest.fn();
86
109
  await act(async () => {
87
- wrapper = await create(
88
- <OnOffTemplate
89
- actionGroup={actionGroup}
90
- doAction={mockDoAction}
91
- sensor={{}}
92
- />
93
- );
110
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
94
111
  });
95
- const instance = wrapper.root;
112
+ const instance = tree.root;
96
113
  const template = instance.findAllByType(OnOffButtonTemplate);
97
114
  expect(template).toHaveLength(0);
98
115
  });
@@ -101,15 +118,9 @@ describe('Test OnOffTemplate', () => {
101
118
  actionGroup.template = 'wrong_template';
102
119
  const mockDoAction = jest.fn();
103
120
  await act(async () => {
104
- wrapper = await create(
105
- <OnOffTemplate
106
- actionGroup={actionGroup}
107
- doAction={mockDoAction}
108
- sensor={{}}
109
- />
110
- );
121
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
111
122
  });
112
- const instance = wrapper.root;
123
+ const instance = tree.root;
113
124
 
114
125
  const templateOnOffButton = instance.findAll(
115
126
  (el) =>
@@ -125,32 +136,20 @@ describe('Test OnOffTemplate', () => {
125
136
  test('render with template OnOffSimpleActionTemplate with is_managed_by_backend', async () => {
126
137
  const mockDoAction = jest.fn();
127
138
  await act(async () => {
128
- wrapper = await create(
129
- <OnOffTemplate
130
- actionGroup={actionGroup}
131
- doAction={mockDoAction}
132
- sensor={{ is_managed_by_backend: true }}
133
- />
134
- );
139
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
135
140
  });
136
- const instance = wrapper.root;
141
+ const instance = tree.root;
137
142
  const template = instance.findAllByType(OnOffSimpleTemplate);
138
143
  expect(template).toHaveLength(1);
139
- expect(watchMultiConfigs).toBeCalledTimes(1);
144
+ expect(watchMultiConfigs).toBeCalledTimes(0);
140
145
  });
141
146
 
142
147
  test('template OnOffSimpleActionTemplate doAction with is_on_value, match configValue', async () => {
143
148
  const mockDoAction = jest.fn();
144
149
  await act(async () => {
145
- wrapper = await create(
146
- <OnOffTemplate
147
- actionGroup={actionGroup}
148
- doAction={mockDoAction}
149
- sensor={{ name: 'Sensor name' }}
150
- />
151
- );
150
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
152
151
  });
153
- const instance = wrapper.root;
152
+ const instance = tree.root;
154
153
  const template = instance.findByType(OnOffSimpleTemplate);
155
154
  expect(template.props.isOn).toEqual(true);
156
155
 
@@ -160,7 +159,7 @@ describe('Test OnOffTemplate', () => {
160
159
  expect(mockDoAction).toHaveBeenCalledWith(
161
160
  action_off_data,
162
161
  null,
163
- 'Sensor name turn on / off off'
162
+ 'Sensor turn on / off off'
164
163
  );
165
164
  expect(watchMultiConfigs).toBeCalledTimes(0);
166
165
  });
@@ -169,15 +168,9 @@ describe('Test OnOffTemplate', () => {
169
168
  actionGroup.configuration.is_on_value = [1];
170
169
  const mockDoAction = jest.fn();
171
170
  await act(async () => {
172
- wrapper = await create(
173
- <OnOffTemplate
174
- actionGroup={actionGroup}
175
- doAction={mockDoAction}
176
- sensor={{ name: 'Sensor name' }}
177
- />
178
- );
171
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
179
172
  });
180
- const instance = wrapper.root;
173
+ const instance = tree.root;
181
174
  const template = instance.findByType(OnOffSimpleTemplate);
182
175
  expect(template.props.isOn).toEqual(false);
183
176
 
@@ -187,22 +180,16 @@ describe('Test OnOffTemplate', () => {
187
180
  expect(mockDoAction).toHaveBeenCalledWith(
188
181
  action_on_data,
189
182
  null,
190
- 'Sensor name turn on / off on'
183
+ 'Sensor turn on / off on'
191
184
  );
192
185
  });
193
186
 
194
187
  test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
195
188
  const mockDoAction = jest.fn();
196
189
  await act(async () => {
197
- wrapper = await create(
198
- <OnOffTemplate
199
- actionGroup={actionGroup}
200
- doAction={mockDoAction}
201
- sensor={{ name: 'Sensor name', is_managed_by_backend: true }}
202
- />
203
- );
190
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
204
191
  });
205
- const instance = wrapper.root;
192
+ const instance = tree.root;
206
193
  const template = instance.findByType(OnOffSimpleTemplate);
207
194
  expect(template.props.isOn).toEqual(true);
208
195
 
@@ -212,9 +199,9 @@ describe('Test OnOffTemplate', () => {
212
199
  expect(mockDoAction).toHaveBeenCalledWith(
213
200
  action_off_data,
214
201
  null,
215
- 'Sensor name turn on / off off'
202
+ 'Sensor turn on / off off'
216
203
  );
217
- expect(watchMultiConfigs).toBeCalledTimes(2);
204
+ expect(watchMultiConfigs).toBeCalledTimes(0);
218
205
  });
219
206
 
220
207
  test('render with template OnOffSimpleActionTemplate with just action_data', async () => {
@@ -230,15 +217,9 @@ describe('Test OnOffTemplate', () => {
230
217
  };
231
218
  const mockDoAction = jest.fn();
232
219
  await act(async () => {
233
- wrapper = await create(
234
- <OnOffTemplate
235
- actionGroup={actionGroup}
236
- doAction={mockDoAction}
237
- sensor={{ is_managed_by_backend: true }}
238
- />
239
- );
220
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
240
221
  });
241
- const instance = wrapper.root;
222
+ const instance = tree.root;
242
223
  const template = instance.findAllByType(OnOffSimpleTemplate);
243
224
  expect(template).toHaveLength(1);
244
225
  expect(template[0].props.disabled).toBeFalsy();
@@ -261,15 +242,9 @@ describe('Test OnOffTemplate', () => {
261
242
  };
262
243
  const mockDoAction = jest.fn();
263
244
  await act(async () => {
264
- wrapper = await create(
265
- <OnOffTemplate
266
- actionGroup={actionGroup}
267
- doAction={mockDoAction}
268
- sensor={{ is_managed_by_backend: true }}
269
- />
270
- );
245
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
271
246
  });
272
- const instance = wrapper.root;
247
+ const instance = tree.root;
273
248
  const template = instance.findAllByType(OnOffSimpleTemplate);
274
249
  expect(template).toHaveLength(1);
275
250
  expect(template[0].props.disabled).toBeTruthy();
@@ -1,8 +1,27 @@
1
+ /* eslint-disable promise/prefer-await-to-callbacks */
1
2
  import React from 'react';
2
3
  import { create, act } from 'react-test-renderer';
3
4
  import { TouchableOpacity } from 'react-native';
5
+ import { useSelector } from 'react-redux';
4
6
 
5
7
  import OneBigButtonTemplate from '../OneBigButtonTemplate';
8
+ import { mockSCStore } from '../../../context/mockStore';
9
+ import { SCProvider } from '../../../context';
10
+
11
+ const wrapComponent = (actionGroup, mockDoAction, sensor) => (
12
+ <SCProvider initState={mockSCStore({})}>
13
+ <OneBigButtonTemplate
14
+ actionGroup={actionGroup}
15
+ doAction={mockDoAction}
16
+ sensor={sensor}
17
+ />
18
+ </SCProvider>
19
+ );
20
+
21
+ jest.mock('react-redux', () => ({
22
+ ...jest.requireActual('react-redux'),
23
+ useSelector: jest.fn(),
24
+ }));
6
25
 
7
26
  describe('Test OneBigButtonTemplate', () => {
8
27
  const action_data = {
@@ -23,24 +42,25 @@ describe('Test OneBigButtonTemplate', () => {
23
42
  text: 'UP',
24
43
  },
25
44
  };
26
- const sensor = {
27
- name: 'Sensor name',
28
- };
29
- let wrapper;
45
+ let tree;
46
+ let sensor;
30
47
 
31
- test('render OneBigButtonTemplate', () => {
32
- const mockDoAction = jest.fn();
33
- act(() => {
34
- wrapper = create(
35
- <OneBigButtonTemplate
36
- actionGroup={actionGroup}
37
- doAction={mockDoAction}
38
- sensor={sensor}
39
- />
40
- );
48
+ beforeEach(() => {
49
+ const localState = {
50
+ isOnSwich: false,
51
+ };
52
+ useSelector.mockImplementation((cb) => {
53
+ return cb(localState);
41
54
  });
55
+ sensor = { name: 'Sensor' };
56
+ });
42
57
 
43
- const instance = wrapper.root;
58
+ test('render OneBigButtonTemplate', async () => {
59
+ const mockDoAction = jest.fn();
60
+ await act(async () => {
61
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
62
+ });
63
+ const instance = tree.root;
44
64
  const buttons = instance.findAllByType(TouchableOpacity);
45
65
  expect(buttons.length).toEqual(1);
46
66
 
@@ -49,10 +69,6 @@ describe('Test OneBigButtonTemplate', () => {
49
69
  });
50
70
 
51
71
  expect(mockDoAction).toHaveBeenCalledTimes(1);
52
- expect(mockDoAction).toHaveBeenCalledWith(
53
- action_data,
54
- null,
55
- 'Sensor name up'
56
- );
72
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null, 'Sensor up');
57
73
  });
58
74
  });
@@ -152,7 +152,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
152
152
 
153
153
  expect(mockDoAction).toHaveBeenCalledWith(
154
154
  action_data,
155
- 1,
155
+ JSON.stringify({ level: 1, key_code: 1 }),
156
156
  'Sensor name fan speed 1'
157
157
  );
158
158
  is_managed_by_backend
@@ -221,7 +221,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
221
221
 
222
222
  expect(mockDoAction).toHaveBeenCalledWith(
223
223
  action_data,
224
- 'level-1',
224
+ JSON.stringify({ level: 'level-1', key_code: 1 }),
225
225
  'Sensor name fan speed level-1'
226
226
  ); // doAction with text instead of int
227
227
 
@@ -5,7 +5,7 @@ import AccountItem from './AccountItem';
5
5
 
6
6
  const AccountList = ({ accounts }) => {
7
7
  return (
8
- <ScrollView>
8
+ <ScrollView scrollIndicatorInsets={{ right: 1 }}>
9
9
  {accounts.map((account) => (
10
10
  <AccountItem key={account.id || account.name} account={account} />
11
11
  ))}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import renderer, { act } from 'react-test-renderer';
3
+ import Connecting from '../index';
4
+ import Text from '../../Text';
5
+ import { SCProvider } from '../../../context';
6
+ import { mockSCStore } from '../../../context/mockStore';
7
+
8
+ const wrapComponent = (route) => (
9
+ <SCProvider initState={mockSCStore({})}>
10
+ <Connecting route={route} />
11
+ </SCProvider>
12
+ );
13
+ describe('Test Connecting', () => {
14
+ let tree;
15
+ test('create Connecting', () => {
16
+ act(() => {
17
+ tree = renderer.create(wrapComponent());
18
+ });
19
+ const instance = tree.root;
20
+ const text = instance.findAllByType(Text);
21
+ expect(text).toHaveLength(4);
22
+ });
23
+ });
@@ -0,0 +1,67 @@
1
+ import React, { useEffect, useCallback, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import * as Progress from 'react-native-progress';
4
+ import Text from '../Text';
5
+ import { Colors, Constants } from '../../configs';
6
+ import styles from './styles';
7
+ import { useTranslations } from '../../hooks/Common/useTranslations';
8
+ import { HeaderCustom } from '../Header';
9
+
10
+ const Connecting = ({ isLoading, isConnect, isPercentConnect }) => {
11
+ const t = useTranslations();
12
+ const [percent, setPercent] = useState(0);
13
+
14
+ useEffect(() => {
15
+ processLoading();
16
+ }, [processLoading]);
17
+
18
+ const processLoading = useCallback(() => {
19
+ let interval;
20
+ if (isLoading) {
21
+ interval = setInterval(() => {
22
+ setPercent((prev) => {
23
+ if (prev === 1) {
24
+ clearInterval(interval);
25
+ return 1;
26
+ } else if (prev === 0.8 && isConnect) {
27
+ clearInterval(interval);
28
+ return 0.8;
29
+ } else {
30
+ return prev + 0.2;
31
+ }
32
+ });
33
+ }, 180);
34
+ } else {
35
+ clearInterval(interval);
36
+ }
37
+ }, [isConnect, isLoading]);
38
+ return (
39
+ <View style={styles.screen}>
40
+ <HeaderCustom title={t('connect_device')} isShowSeparator />
41
+ <View style={styles.body}>
42
+ <View style={styles.connecting}>
43
+ <Text type="H4" bold>
44
+ {t('connecting')}
45
+ </Text>
46
+ </View>
47
+ <View style={styles.percentLoad}>
48
+ <Progress.Bar
49
+ progress={isPercentConnect || percent}
50
+ animated={true}
51
+ color={Colors.Primary}
52
+ indeterminateAnimationDuration={1000}
53
+ height={7}
54
+ width={Constants.width - 80}
55
+ useNativeDriver={true}
56
+ />
57
+ <Text style={styles.textPercentLoad}>{`${parseInt(
58
+ (isPercentConnect || percent) * 100,
59
+ 10
60
+ )}%`}</Text>
61
+ </View>
62
+ </View>
63
+ </View>
64
+ );
65
+ };
66
+
67
+ export default Connecting;
@@ -0,0 +1,28 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Constants } from '../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ screen: {
6
+ flex: 1,
7
+ width: '100%',
8
+ },
9
+ body: {
10
+ width: '100%',
11
+ height: Constants.height - 50,
12
+ justifyContent: 'center',
13
+ alignItems: 'center',
14
+ },
15
+ connecting: {
16
+ flexDirection: 'row',
17
+ justifyContent: 'center',
18
+ marginBottom: 10,
19
+ },
20
+ percentLoad: {
21
+ flexDirection: 'row',
22
+ justifyContent: 'center',
23
+ alignItems: 'center',
24
+ },
25
+ textPercentLoad: {
26
+ marginLeft: 10,
27
+ },
28
+ });
@@ -3,14 +3,14 @@ import { SafeAreaView, View, TouchableOpacity } from 'react-native';
3
3
  import { useTranslations } from '../../hooks/Common/useTranslations';
4
4
  import Routes from '../../utils/Route';
5
5
  import { useNavigation } from '@react-navigation/native';
6
- import * as Progress from 'react-native-progress';
7
6
  import ImageSuccessfully from '../../Images/Common/SuccessfullyConnected.svg';
8
7
 
9
8
  import Text from '../Text';
10
9
  import { axiosPost } from '../../utils/Apis/axios';
11
- import { API, Colors, Constants } from '../../configs';
10
+ import { API, Colors } from '../../configs';
12
11
  import styles from './styles';
13
12
  import DeviceItem from './DeviceItem/DeviceItem';
13
+ import Connecting from '../Connecting';
14
14
  import { useSCContextSelector } from '../../context';
15
15
 
16
16
  const ConnectingProcess = ({ route }) => {
@@ -29,31 +29,9 @@ const ConnectingProcess = ({ route }) => {
29
29
  wifi_pass,
30
30
  chip_id,
31
31
  } = route.params;
32
- const [percent, setPercent] = useState(0);
33
32
  const [isLoading, setIsLoading] = useState(true);
34
33
  const [sensor, setSensor] = useState(null);
35
34
  const user = useSCContextSelector((state) => state?.auth?.account?.user);
36
- useEffect(() => {
37
- processLoading();
38
- }, [processLoading]);
39
-
40
- const processLoading = useCallback(() => {
41
- let interval;
42
- if (isLoading) {
43
- interval = setInterval(() => {
44
- setPercent((prev) => {
45
- if (prev === 1) {
46
- clearInterval(interval);
47
- return 1;
48
- } else {
49
- return prev + 0.2;
50
- }
51
- });
52
- }, 180);
53
- } else {
54
- clearInterval(interval);
55
- }
56
- }, [isLoading]);
57
35
 
58
36
  const ConnectingDevice = useCallback(async () => {
59
37
  setIsLoading(true);
@@ -120,35 +98,6 @@ const ConnectingProcess = ({ route }) => {
120
98
  chip_id,
121
99
  ]);
122
100
 
123
- const Connecting = useCallback(() => {
124
- return (
125
- <>
126
- <View style={styles.progressBar}>
127
- <View style={styles.connecting}>
128
- <Text type="H4" bold>
129
- {t('connecting')}
130
- </Text>
131
- </View>
132
- </View>
133
- <View style={styles.percentLoad}>
134
- <Progress.Bar
135
- progress={percent}
136
- animated={true}
137
- color={Colors.Primary}
138
- indeterminateAnimationDuration={1000}
139
- height={7}
140
- width={Constants.width - 80}
141
- useNativeDriver={true}
142
- />
143
- <Text style={styles.textPercentLoad}>{`${parseInt(
144
- percent * 100,
145
- 10
146
- )}%`}</Text>
147
- </View>
148
- </>
149
- );
150
- }, [percent, t]);
151
-
152
101
  const ConnectingSuccess = useCallback(() => {
153
102
  return (
154
103
  <View style={styles.ConnectingSuccess}>
@@ -188,7 +137,7 @@ const ConnectingProcess = ({ route }) => {
188
137
  <Text bold style={styles.connectingText}>
189
138
  {t('connect_device')}
190
139
  </Text>
191
- {!!isLoading && <Connecting />}
140
+ {!!isLoading && <Connecting isLoading={isLoading} />}
192
141
  {!isLoading && <ConnectingSuccess />}
193
142
  </View>
194
143
  {!isLoading && (
@@ -234,19 +234,23 @@ const HistoryChart = memo(
234
234
  )}
235
235
  <DateTimePickerModal
236
236
  isVisible={eventPicker.showModalStart}
237
- date={eventPicker.startTime.toDate()}
237
+ date={eventPicker.startTime.valueOf()}
238
238
  mode={formatType || 'datetime'}
239
239
  onConfirm={onConfirmStart}
240
240
  onCancel={onCancel}
241
241
  display="spinner"
242
+ cancelTextIOS={t('cancel')}
243
+ confirmTextIOS={t('confirm')}
242
244
  />
243
245
  <DateTimePickerModal
244
246
  isVisible={eventPicker.showModalEnd}
245
- date={eventPicker.endTime.toDate()}
247
+ date={eventPicker.endTime.valueOf()}
246
248
  mode={formatType || 'datetime'}
247
249
  onConfirm={onConfirmEnd}
248
250
  onCancel={onCancel}
249
251
  display="spinner"
252
+ cancelTextIOS={t('cancel')}
253
+ confirmTextIOS={t('confirm')}
250
254
  />
251
255
  </View>
252
256
  );
@@ -1,4 +1,5 @@
1
1
  import React, { memo, useCallback } from 'react';
2
+ import { View } from 'react-native';
2
3
  import { FlatList } from 'react-native';
3
4
  import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
4
5
  import styles from './PMSensorIndicatorStyles';
@@ -26,18 +27,21 @@ const PMSensorIndicatior = memo(({ data, style }) => {
26
27
  const isScrollMode = data.length > 3;
27
28
 
28
29
  return (
29
- <FlatList
30
- bounces={false}
31
- numColumns={1}
32
- horizontal={true}
33
- contentContainerStyle={[
34
- styles.standard,
35
- !isScrollMode && styles.centerItem,
36
- ]}
37
- data={data}
38
- keyExtractor={keyExtractor}
39
- renderItem={renderItem}
40
- />
30
+ <View style={styles.wrap}>
31
+ <FlatList
32
+ bounces={false}
33
+ numColumns={1}
34
+ horizontal={true}
35
+ contentContainerStyle={[
36
+ styles.standard,
37
+ !isScrollMode && styles.centerItem,
38
+ ]}
39
+ data={data}
40
+ keyExtractor={keyExtractor}
41
+ renderItem={renderItem}
42
+ scrollIndicatorInsets={{ right: 1 }}
43
+ />
44
+ </View>
41
45
  );
42
46
  });
43
47
 
@@ -10,4 +10,7 @@ export default StyleSheet.create({
10
10
  flex: 1,
11
11
  justifyContent: 'center',
12
12
  },
13
+ wrap: {
14
+ marginVertical: 16,
15
+ },
13
16
  });
@@ -27,6 +27,7 @@ const ListQualityIndicator = ({ data, style }) => {
27
27
  showsHorizontalScrollIndicator={false}
28
28
  nestedScrollEnabled
29
29
  contentContainerStyle={[styles.flatlistContent, style]}
30
+ scrollIndicatorInsets={{ right: 1 }}
30
31
  />
31
32
  </View>
32
33
  );
@@ -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),
@@ -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>