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

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 (204) hide show
  1. package/package.json +1 -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/Auth/AccountList.js +1 -1
  32. package/src/commons/Auth/__test__/OtpInputList.test.js +13 -17
  33. package/src/commons/Automate/ItemAutomate.js +10 -4
  34. package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
  35. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  36. package/src/commons/Device/ProgressBar/index.js +5 -11
  37. package/src/commons/Device/ProgressBar/styles.js +11 -3
  38. package/src/commons/Device/WindSpeed/Anemometer/index.js +2 -0
  39. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
  40. package/src/commons/Device/WindSpeed/LinearChart/index.js +4 -2
  41. package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
  42. package/src/commons/FlatListDnD/index.js +37 -0
  43. package/src/commons/FlatListDnD/styles.js +12 -0
  44. package/src/commons/Form/__test__/TextInput.test.js +1 -1
  45. package/src/commons/Header/HeaderCustom.js +2 -1
  46. package/src/commons/HorizontalPicker/index.js +65 -38
  47. package/src/commons/IconComponent/index.js +3 -2
  48. package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
  49. package/src/commons/MediaPlayer/index.js +11 -7
  50. package/src/commons/MenuActionMore/index.js +6 -4
  51. package/src/commons/Modal/ModalBottom.js +2 -3
  52. package/src/commons/Modal/ModalCustom.js +2 -3
  53. package/src/commons/NavBar/index.js +48 -50
  54. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +1 -1
  55. package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
  56. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
  57. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
  58. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +1 -1
  59. package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
  60. package/src/commons/PreventAccess/index.js +1 -1
  61. package/src/commons/Sharing/StationDevicePermissions.js +4 -4
  62. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
  63. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +2 -2
  64. package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
  65. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +11 -6
  66. package/src/commons/SubUnit/OneTap/index.js +19 -6
  67. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
  68. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  69. package/src/configs/API.js +6 -0
  70. package/src/configs/AccessibilityLabel.js +1 -0
  71. package/src/configs/Colors.js +1 -1
  72. package/src/configs/Constants.js +12 -18
  73. package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
  74. package/src/hooks/Common/index.js +0 -2
  75. package/src/hooks/Common/useKeyboardShow.js +4 -4
  76. package/src/hooks/Common/useStatusBar.js +2 -2
  77. package/src/hooks/Common/useTitleHeader.js +5 -7
  78. package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
  79. package/src/hooks/IoT/useBluetoothConnection.js +6 -3
  80. package/src/hooks/index.js +1 -2
  81. package/src/navigations/UnitStack.js +33 -9
  82. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +8 -31
  83. package/src/screens/AddNewAutoSmart/index.js +24 -60
  84. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
  85. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
  86. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +5 -13
  87. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +9 -11
  88. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
  89. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
  90. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
  91. package/src/screens/AddNewGateway/index.js +1 -1
  92. package/src/screens/AllCamera/index.js +2 -3
  93. package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
  94. package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
  95. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
  96. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
  97. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseAction.js +78 -119
  98. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseConfig.js +45 -73
  99. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
  100. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/SelectDevices.js +3 -3
  101. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
  102. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +3 -3
  103. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
  104. package/src/screens/{AddNewAction → Automate/AddNewAction}/NewActionWrapper.js +11 -10
  105. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectControlDevices.js +11 -49
  106. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectMonitorDevices.js +10 -42
  107. package/src/screens/{AddNewAction → Automate/AddNewAction}/SetupConfigCondition.js +52 -101
  108. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
  109. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
  110. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +4 -2
  111. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseAction.test.js +10 -11
  112. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseConfig.test.js +26 -27
  113. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectControlDevices.test.js +9 -9
  114. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectMonitorDevices.test.js +5 -5
  115. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SetupSensor.test.js +43 -13
  116. package/src/screens/Automate/Components/InputName.js +64 -0
  117. package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +2 -2
  118. package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
  119. package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +6 -6
  120. package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
  121. package/src/screens/Automate/MultiUnits.js +68 -66
  122. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
  123. package/src/screens/Automate/OneTap/index.js +16 -0
  124. package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
  125. package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
  126. package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
  127. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
  128. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
  129. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +69 -72
  130. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
  131. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
  132. package/src/screens/Automate/ScriptDetail/index.js +346 -0
  133. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/utils.js +32 -31
  134. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
  135. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
  136. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
  137. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
  138. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
  139. package/src/screens/Automate/SetSchedule/index.js +140 -0
  140. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
  141. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
  142. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
  143. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
  144. package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
  145. package/src/screens/Automate/__test__/MultiUnits.test.js +76 -120
  146. package/src/screens/Automate/__test__/index.test.js +2 -9
  147. package/src/screens/Automate/constants.js +0 -0
  148. package/src/screens/Automate/index.js +11 -22
  149. package/src/screens/ChangePosition/__test__/index.test.js +75 -0
  150. package/src/screens/ChangePosition/index.js +112 -0
  151. package/src/screens/ChangePosition/styles.js +87 -0
  152. package/src/screens/Device/__test__/detail.test.js +202 -257
  153. package/src/screens/Device/__test__/sensorDisplayItem.test.js +4 -0
  154. package/src/screens/Device/components/SensorDisplayItem.js +2 -1
  155. package/src/screens/Device/components/VisualChart.js +55 -8
  156. package/src/screens/Device/detail.js +14 -0
  157. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
  158. package/src/screens/Device/hooks/useEvaluateValue.js +20 -2
  159. package/src/screens/Device/styles.js +7 -0
  160. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
  161. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
  162. package/src/screens/Notification/__test__/Notification.test.js +1 -1
  163. package/src/screens/PlayBackCamera/index.js +2 -3
  164. package/src/screens/SharedUnit/index.js +5 -4
  165. package/src/screens/Sharing/SelectUser.js +2 -2
  166. package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
  167. package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
  168. package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
  169. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
  170. package/src/screens/SmartAccount/index.js +1 -0
  171. package/src/screens/SubUnit/ManageSubUnit.js +4 -4
  172. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
  173. package/src/screens/TDSGuide/index.js +1 -1
  174. package/src/screens/Template/GatewayList.js +4 -1
  175. package/src/screens/Template/__test__/detail.test.js +14 -20
  176. package/src/screens/Template/detail.js +1 -0
  177. package/src/screens/UVIndexGuide/index.js +2 -2
  178. package/src/screens/Unit/Detail.js +6 -5
  179. package/src/screens/Unit/SelectAddToFavorites.js +1 -1
  180. package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
  181. package/src/screens/Unit/__test__/Detail.test.js +3 -1
  182. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
  183. package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
  184. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
  185. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
  186. package/src/screens/WaterQualityGuide/index.js +10 -5
  187. package/src/utils/I18n/translations/en.json +23 -18
  188. package/src/utils/I18n/translations/vi.json +21 -18
  189. package/src/utils/Route/index.js +3 -0
  190. package/src/utils/Utils.js +29 -0
  191. package/src/utils/__test__/Utils.test.js +6 -0
  192. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
  193. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
  194. package/src/commons/Auth/SocialButton.js +0 -54
  195. package/src/commons/Auth/__test__/SocialButton.test.js +0 -46
  196. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
  197. package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
  198. package/src/hooks/useInitDeepLink.js +0 -25
  199. package/src/screens/AddNewOneTap/index.js +0 -156
  200. package/src/screens/ScriptDetail/hooks/index.js +0 -136
  201. package/src/screens/ScriptDetail/index.js +0 -446
  202. package/src/screens/SetSchedule/index.js +0 -200
  203. /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
  204. /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
@@ -1,11 +1,9 @@
1
- import React, { useEffect, useMemo, useRef, useState, memo } from 'react';
2
- import { View, Animated } from 'react-native';
3
- import { Constants, Colors } from '../../configs';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { Animated, View } from 'react-native';
3
+ import { Colors, Constants } from '../../configs';
4
4
  import Text from '../Text';
5
5
  import styles from './styles';
6
6
 
7
- let isCanChangeValue = false;
8
-
9
7
  const HorizontalPicker = ({
10
8
  width = Constants.width,
11
9
  onChangeValue,
@@ -24,14 +22,40 @@ const HorizontalPicker = ({
24
22
  }) => {
25
23
  const scrollViewRef = useRef();
26
24
  const [scrollX] = useState(new Animated.Value(0));
25
+ const [max, setMax] = useState(maximum);
26
+
27
+ const data = useMemo(() => {
28
+ const array = [];
29
+ const numberOfSteps = Math.floor((max - minimum) / step);
30
+ for (let i = 0; i <= numberOfSteps; i++) {
31
+ array.push(minimum + i * step);
32
+ }
33
+ return array;
34
+ }, [max, minimum, step]);
35
+
36
+ useEffect(() => {
37
+ if (minimum >= maximum) {
38
+ setMax(minimum + 10 * step);
39
+ } else {
40
+ setMax(maximum);
41
+ }
42
+ }, [minimum, maximum, step]);
43
+
44
+ useEffect(() => {
45
+ if (maximum) {
46
+ return;
47
+ }
48
+ setMax((prev) => {
49
+ if (value + 10 * step > prev) {
50
+ return value + 10 * step;
51
+ }
52
+ return prev;
53
+ });
54
+ }, [maximum, value, setMax, step]);
27
55
 
28
56
  const spacerWidth = (width - stepWidth) / 2;
29
- let time = useMemo(() => minimum, [minimum]);
30
57
 
31
58
  const renderTime = useMemo(() => {
32
- const data = [...Array(maximum - minimum + 1).keys()].map(
33
- (i) => i + minimum
34
- );
35
59
  return (
36
60
  <View style={[styles.wrap]}>
37
61
  <View
@@ -40,9 +64,9 @@ const HorizontalPicker = ({
40
64
  }}
41
65
  />
42
66
  {data.map((i, index) => {
43
- const isStep = i % step === 0;
67
+ const isStep = index % 10 === 0;
44
68
  return (
45
- <View key={index}>
69
+ <View key={index} accessibilityLabel={`x-${index}`}>
46
70
  <View
47
71
  key={i}
48
72
  // eslint-disable-next-line react-native/no-inline-styles
@@ -51,15 +75,12 @@ const HorizontalPicker = ({
51
75
  height: isStep ? stepHeight : normalHeight,
52
76
  width: isStep ? stepWidth : normalWidth,
53
77
  borderRadius: isStep ? stepWidth / 2 : normalWidth / 2,
54
- marginRight: i === maximum ? 0 : segmentSpacing,
78
+ marginRight: i === data.length - 1 ? 0 : segmentSpacing,
55
79
  }}
56
80
  />
57
81
  {isStep && (
58
- <Text
59
- color={Colors.Gray7}
60
- style={[styles.time, time < 10 && styles.time2]}
61
- >
62
- {time++}
82
+ <Text color={Colors.Gray7} style={[styles.time, styles.time2]}>
83
+ {i}
63
84
  </Text>
64
85
  )}
65
86
  </View>
@@ -72,34 +93,40 @@ const HorizontalPicker = ({
72
93
  />
73
94
  </View>
74
95
  );
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- }, [maximum, minimum, time]);
96
+ }, [
97
+ data,
98
+ normalColor,
99
+ normalHeight,
100
+ normalWidth,
101
+ segmentSpacing,
102
+ spacerWidth,
103
+ stepColor,
104
+ stepHeight,
105
+ stepWidth,
106
+ width,
107
+ ]);
77
108
 
78
109
  useEffect(() => {
79
110
  const scrollListener = scrollX.addListener(({ value: scrollValue }) => {
80
- isCanChangeValue && onChangeValue && onChangeValue(scrollValue);
111
+ if (!onChangeValue) {
112
+ return;
113
+ }
114
+ const newValue = Math.round(scrollValue / step / 12.8) * step;
115
+ onChangeValue(newValue + minimum);
81
116
  });
82
117
  return () => scrollX.removeListener(scrollListener);
83
- // eslint-disable-next-line react-hooks/exhaustive-deps
84
- }, []);
118
+ }, [minimum, onChangeValue, scrollX, step]);
85
119
 
86
120
  useEffect(() => {
87
- if (!isCanChangeValue && scrollViewRef && scrollViewRef.current) {
88
- const to1 = setTimeout(() => {
89
- scrollViewRef.current.scrollTo({ x: value * 128 });
90
- clearTimeout(to1);
91
- }, 300);
92
- const to2 = setTimeout(() => {
93
- isCanChangeValue = true;
94
- clearTimeout(to2);
95
- }, 1000);
96
- }
121
+ setTimeout(() => {
122
+ scrollViewRef.current &&
123
+ scrollViewRef.current.scrollTo({
124
+ x: value * step * 12.8,
125
+ animated: false,
126
+ });
127
+ }, 10);
97
128
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
- }, [value, isCanChangeValue, scrollViewRef]);
99
-
100
- useEffect(() => {
101
- return () => (isCanChangeValue = false);
102
- }, []);
129
+ }, [scrollViewRef.current]); // this is preload default data, run only once
103
130
 
104
131
  return (
105
132
  <View style={[styles.container, style]}>
@@ -131,4 +158,4 @@ const HorizontalPicker = ({
131
158
  );
132
159
  };
133
160
 
134
- export default memo(HorizontalPicker);
161
+ export default HorizontalPicker;
@@ -12,6 +12,7 @@ const IconComponent = memo(
12
12
  size = 30,
13
13
  iconSize = 30,
14
14
  style,
15
+ antIconStyle,
15
16
  color,
16
17
  colorInActive,
17
18
  active,
@@ -70,7 +71,7 @@ const IconComponent = memo(
70
71
  name={displayIcon}
71
72
  color={colorIcon}
72
73
  size={iconSize}
73
- style={[extraStyle, style]}
74
+ style={[extraStyle, antIconStyle || style]}
74
75
  />
75
76
  );
76
77
  } else {
@@ -84,7 +85,7 @@ const IconComponent = memo(
84
85
  name={iconCT}
85
86
  color={colorIcon}
86
87
  size={iconSize}
87
- style={[extraStyle, style]}
88
+ style={[extraStyle, antIconStyle || style]}
88
89
  />
89
90
  );
90
91
  }
@@ -4,6 +4,7 @@ import { SCProvider } from '../../../context';
4
4
  import { mockSCStore } from '../../../context/mockStore';
5
5
  import { TouchableOpacity } from 'react-native';
6
6
  import MediaPlay from '../index';
7
+ import VLCPlayer from 'react-native-vlc-media-player/VLCPlayer';
7
8
 
8
9
  const wrapComponent = (props) => (
9
10
  <SCProvider initState={mockSCStore({})}>
@@ -17,9 +18,9 @@ describe('Test MediaPlayer', () => {
17
18
  beforeAll(() => {
18
19
  jest.useFakeTimers();
19
20
  props = {
20
- uri: 'uri',
21
+ uri: 'http://uri',
21
22
  previewUri: 'previewUri',
22
- thumbnail: 'thumbnail',
23
+ thumbnail: { uri: 'thumbnail' },
23
24
  background: 'background',
24
25
  };
25
26
  });
@@ -28,11 +29,15 @@ describe('Test MediaPlayer', () => {
28
29
  await act(async () => {
29
30
  tree = await create(wrapComponent(props));
30
31
  });
32
+ await act(async () => {
33
+ jest.runOnlyPendingTimers();
34
+ });
31
35
  const instance = tree.root;
32
36
  const pauseButton = instance.findByType(TouchableOpacity);
33
37
  await act(async () => {
34
38
  await pauseButton.props.onPress();
35
39
  });
36
- jest.runAllTimers();
40
+ const player = instance.findByType(VLCPlayer);
41
+ expect(player.props.paused).toBeFalsy();
37
42
  });
38
43
  });
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useEffect, useState } from 'react';
1
+ import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
3
  import VLCPlayer from 'react-native-vlc-media-player/VLCPlayer';
4
4
 
@@ -117,12 +117,16 @@ const MediaPlayer = memo(
117
117
  setPaused((p) => !p);
118
118
  }, []);
119
119
 
120
- const imageSource =
121
- thumbnail || thumbnail?.uri
122
- ? thumbnail
123
- : background
124
- ? background
125
- : Images.BgDevice;
120
+ const imageSource = useMemo(() => {
121
+ if (thumbnail) {
122
+ return thumbnail;
123
+ }
124
+ if (background) {
125
+ return background;
126
+ }
127
+ return Images.BgDevice;
128
+ }, [background, thumbnail]);
129
+
126
130
  return (
127
131
  <View style={styles.wrap}>
128
132
  <View style={styles.loadingWrap}>
@@ -1,11 +1,12 @@
1
1
  import React, { memo, useCallback, useEffect, useState } from 'react';
2
2
  import { TouchableOpacity, ScrollView } from 'react-native';
3
- import Popover from '../Popover';
3
+ import { PopoverMode } from 'react-native-popover-view';
4
4
 
5
+ import Popover from '../Popover';
5
6
  import styles from './MenuActionMoreStyles';
6
7
  import Text from '../Text';
7
8
  import { AccessibilityLabel } from '../../configs/Constants';
8
- import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
9
+ import { setStatusBarPreview } from '../../hooks/Common/useStatusBar';
9
10
  import { Colors } from '../../configs';
10
11
 
11
12
  const MenuActionMore = memo(
@@ -20,6 +21,7 @@ const MenuActionMore = memo(
20
21
  idLabelPopover,
21
22
  idLabelScrollView,
22
23
  idLabelItem = AccessibilityLabel.SUB_UNIT_NAME,
24
+ mode = PopoverMode.RN_MODAL,
23
25
  }) => {
24
26
  const [isDisable, setIsDisable] = useState(false);
25
27
  const onPress = useCallback(
@@ -36,8 +38,7 @@ const MenuActionMore = memo(
36
38
  );
37
39
 
38
40
  useEffect(() => {
39
- // eslint-disable-next-line react-hooks/rules-of-hooks
40
- useStatusBarPreview(
41
+ setStatusBarPreview(
41
42
  isVisible ? Colors.BlackTransparent5 : Colors.TextTransparent
42
43
  );
43
44
  }, [isVisible]);
@@ -51,6 +52,7 @@ const MenuActionMore = memo(
51
52
  isVisible={isVisible}
52
53
  arrowStyle={styles.wrap}
53
54
  accessibilityLabel={idLabelPopover}
55
+ mode={mode}
54
56
  >
55
57
  <ScrollView
56
58
  scrollIndicatorInsets={{ right: 1 }}
@@ -5,7 +5,7 @@ import styles from './Styles/ModalBottomStyles';
5
5
  import Text from '../Text';
6
6
  import { useTranslations } from '../../hooks/Common/useTranslations';
7
7
  import { Colors } from '../../configs';
8
- import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
8
+ import { setStatusBarPreview } from '../../hooks/Common/useStatusBar';
9
9
 
10
10
  const ModalBottom = ({
11
11
  isVisible,
@@ -21,8 +21,7 @@ const ModalBottom = ({
21
21
  const t = useTranslations();
22
22
 
23
23
  useEffect(() => {
24
- // eslint-disable-next-line react-hooks/rules-of-hooks
25
- useStatusBarPreview(
24
+ setStatusBarPreview(
26
25
  isVisible ? Colors.BlackTransparent5 : Colors.TextTransparent
27
26
  );
28
27
  }, [isVisible]);
@@ -1,12 +1,11 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import Modal from 'react-native-modal';
3
3
  import { Colors } from '../../configs';
4
- import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
4
+ import { setStatusBarPreview } from '../../hooks/Common/useStatusBar';
5
5
 
6
6
  const ModalCustom = (props) => {
7
7
  useEffect(() => {
8
- // eslint-disable-next-line react-hooks/rules-of-hooks
9
- useStatusBarPreview(
8
+ setStatusBarPreview(
10
9
  props.isVisible ? Colors.BlackTransparent3_5 : Colors.TextTransparent
11
10
  );
12
11
  }, [props.isVisible]);
@@ -1,4 +1,4 @@
1
- import React, { memo, useRef } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import { Icon } from '@ant-design/react-native';
3
3
  import { View, TouchableOpacity } from 'react-native';
4
4
 
@@ -9,55 +9,53 @@ import { AccessibilityLabel } from '../../configs/Constants';
9
9
  import Station from '../../screens/Unit/Station';
10
10
  import MenuActionMore from '../MenuActionMore';
11
11
 
12
- const NavBar = memo(
13
- ({
14
- listMenuItem,
15
- listStation,
16
- onSnapToItem,
17
- indexStation,
18
- style,
19
- idLabelScrollView,
20
- idLabelItem,
21
- idLabelIconBars,
22
- }) => {
23
- const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
24
- usePopover();
25
- const refMenuAction = useRef();
26
- const handleShowMenuAction = () => showPopoverWithRef(refMenuAction);
12
+ const NavBar = ({
13
+ listMenuItem,
14
+ listStation,
15
+ onSnapToItem,
16
+ indexStation,
17
+ style,
18
+ idLabelScrollView,
19
+ idLabelItem,
20
+ idLabelIconBars,
21
+ }) => {
22
+ const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
23
+ usePopover();
24
+ const refMenuAction = useRef();
25
+ const handleShowMenuAction = () => showPopoverWithRef(refMenuAction);
27
26
 
28
- return (
29
- <>
30
- <View style={[styles.wrap, style]}>
31
- <View style={styles.wrapTitle}>
32
- <Station
33
- listStation={listStation}
34
- onSnapToItem={onSnapToItem}
35
- indexStation={indexStation}
36
- />
37
- </View>
38
- <TouchableOpacity
39
- style={styles.btnBack}
40
- onPress={handleShowMenuAction}
41
- ref={refMenuAction}
42
- accessibilityLabel={idLabelIconBars}
43
- >
44
- <Icon name={'bars'} size={19} color={Colors.Black} />
45
- </TouchableOpacity>
27
+ return (
28
+ <>
29
+ <View style={[styles.wrap, style]}>
30
+ <View style={styles.wrapTitle}>
31
+ <Station
32
+ listStation={listStation}
33
+ onSnapToItem={onSnapToItem}
34
+ indexStation={indexStation}
35
+ />
46
36
  </View>
47
- <MenuActionMore
48
- isVisible={showingPopover}
49
- hideMore={hidePopover}
50
- listMenuItem={listMenuItem}
51
- childRef={childRef}
52
- onItemClick={onSnapToItem}
53
- isTextCenter={false}
54
- idLabelPopover={AccessibilityLabel.NAVBAR_MENU_ACTION_MORE}
55
- wrapStyle={styles.wrapStyle}
56
- idLabelScrollView={idLabelScrollView}
57
- idLabelItem={idLabelItem}
58
- />
59
- </>
60
- );
61
- }
62
- );
37
+ <TouchableOpacity
38
+ style={styles.btnBack}
39
+ onPress={handleShowMenuAction}
40
+ ref={refMenuAction}
41
+ accessibilityLabel={idLabelIconBars}
42
+ >
43
+ <Icon name={'bars'} size={19} color={Colors.Black} />
44
+ </TouchableOpacity>
45
+ </View>
46
+ <MenuActionMore
47
+ isVisible={showingPopover}
48
+ hideMore={hidePopover}
49
+ listMenuItem={listMenuItem}
50
+ childRef={childRef}
51
+ onItemClick={onSnapToItem}
52
+ isTextCenter={false}
53
+ idLabelPopover={AccessibilityLabel.NAVBAR_MENU_ACTION_MORE}
54
+ wrapStyle={styles.wrapStyle}
55
+ idLabelScrollView={idLabelScrollView}
56
+ idLabelItem={idLabelItem}
57
+ />
58
+ </>
59
+ );
60
+ };
63
61
  export default NavBar;
@@ -106,7 +106,7 @@ const NumberUpDownActionTemplate = ({ device, item = {}, onSelectAction }) => {
106
106
  >
107
107
  <View style={styles.popoverStyle}>
108
108
  <View>
109
- <Text type="H4" bold style={styles.textwithline}>
109
+ <Text type="H4" bold style={styles.textWithLine}>
110
110
  {t('set_temperature')}
111
111
  </Text>
112
112
  <View style={styles.modalContent}>
@@ -7,7 +7,7 @@ export default StyleSheet.create({
7
7
  backgroundColor: Colors.White,
8
8
  borderRadius: 10,
9
9
  },
10
- textwithline: {
10
+ textWithLine: {
11
11
  paddingLeft: 16,
12
12
  paddingRight: 16,
13
13
  paddingBottom: 16,
@@ -77,7 +77,7 @@ const OptionsDropdownActionTemplate = ({ device, item, onSelectAction }) => {
77
77
  >
78
78
  <View style={styles.popoverStyle}>
79
79
  <View>
80
- <Text type="H4" bold style={styles.textwithline}>
80
+ <Text type="H4" bold style={styles.textWithLine}>
81
81
  {title ? title : t('options')}
82
82
  </Text>
83
83
  <View style={styles.wrapContent}>
@@ -7,7 +7,7 @@ export default StyleSheet.create({
7
7
  backgroundColor: Colors.White,
8
8
  borderRadius: 10,
9
9
  },
10
- textwithline: {
10
+ textWithLine: {
11
11
  paddingLeft: 16,
12
12
  paddingRight: 16,
13
13
  paddingBottom: 16,
@@ -37,7 +37,7 @@ const ActionItem = ({
37
37
  onPress={handleSelectAction}
38
38
  accessibilityLabel={AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM}
39
39
  >
40
- <Text type="H4" style={styles.textwithline}>
40
+ <Text type="H4" style={styles.textWithLine}>
41
41
  {item.text}
42
42
  </Text>
43
43
  </TouchableOpacity>
@@ -11,7 +11,7 @@ export default StyleSheet.create({
11
11
  paddingLeft: 16,
12
12
  paddingRight: 16,
13
13
  },
14
- textwithline: {
14
+ textWithLine: {
15
15
  paddingBottom: 16,
16
16
  paddingTop: 16,
17
17
  borderBottomWidth: 1,
@@ -15,7 +15,7 @@ const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
15
15
  const dataText = useMemo(() => {
16
16
  return {
17
17
  headerText: t('note'),
18
- bodyText: t('This {name} was removed!', {
18
+ bodyText: t('This_name_was_removed', {
19
19
  name: headerBodyText ? headerBodyText : '',
20
20
  }),
21
21
  endOfText: t('back'),
@@ -1,4 +1,4 @@
1
- import React, { memo, useState, useCallback } from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -13,7 +13,7 @@ import DoorInactive from '../../../assets/images/Device/door-inactive.svg';
13
13
 
14
14
  import DevicePermissionsCheckbox from './DevicePermissionsCheckbox';
15
15
 
16
- const StationDevicePermissions = memo(({ dataStation, onselectSensor }) => {
16
+ const StationDevicePermissions = ({ dataStation, onselectSensor }) => {
17
17
  const t = useTranslations();
18
18
  const [listChosen, setListChosen] = useState({}); // { sensorId : indexConfigChoosen , ...}
19
19
  const [expandedIndex, setExpandedIndex] = useState(-1);
@@ -122,12 +122,12 @@ const StationDevicePermissions = memo(({ dataStation, onselectSensor }) => {
122
122
  <Text style={styles.textEmpty}>{t('no_device')}</Text>
123
123
  )}
124
124
  {dataStation.sensors.map((device, index) => (
125
- <RowDevice sensor={device} index={index} />
125
+ <RowDevice sensor={device} index={index} key={device.id} />
126
126
  ))}
127
127
  </View>
128
128
  </>
129
129
  );
130
- });
130
+ };
131
131
 
132
132
  const styles = StyleSheet.create({
133
133
  box: {
@@ -1,11 +1,11 @@
1
- import React, { useRef, useCallback, useState, memo } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import {
3
- RefreshControl,
4
- StyleSheet,
5
3
  Animated,
6
- View,
7
4
  Platform,
5
+ RefreshControl,
8
6
  SafeAreaView,
7
+ StyleSheet,
8
+ View,
9
9
  } from 'react-native';
10
10
  import { ActivityIndicator } from '@ant-design/react-native';
11
11
  import { isIphoneX } from 'react-native-iphone-x-helper';
@@ -109,7 +109,7 @@ const WrapHeaderScrollable = ({
109
109
  );
110
110
  };
111
111
 
112
- export default memo(WrapHeaderScrollable);
112
+ export default WrapHeaderScrollable;
113
113
 
114
114
  const styles = StyleSheet.create({
115
115
  container: {
@@ -20,8 +20,8 @@ describe('Test DevicePermissionsCheckbox', () => {
20
20
  let sensor = {
21
21
  icon: 'caret-down',
22
22
  id: 10,
23
- read_configs: [1],
24
- actions: [13],
23
+ read_configs: [{ id: 1 }],
24
+ actions: [{ id: 13 }],
25
25
  };
26
26
  const mockFunction = jest.fn();
27
27
  it('test create DevicePermissionsCheckbox', async () => {
@@ -89,21 +89,17 @@ const ItemOneTap = memo(
89
89
  const iconKit = script?.icon_kit;
90
90
  if (iconKit) {
91
91
  return <FImage source={{ uri: iconKit }} style={styles.iconSensor} />;
92
- } else if (type === AUTOMATE_TYPE.ONE_TAP) {
92
+ }
93
+ if (type === AUTOMATE_TYPE.ONE_TAP) {
93
94
  return <OneTap />;
94
- } else if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
95
+ }
96
+ if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
95
97
  return <ValueChange />;
96
- } else if (
97
- [
98
- AUTOMATE_TYPE.EVENT,
99
- AUTOMATE_TYPE.EVENT_ACTION,
100
- AUTOMATE_TYPE.EVENT_SENSOR,
101
- ].includes(type)
102
- ) {
98
+ }
99
+ if ([AUTOMATE_TYPE.EVENT].includes(type)) {
103
100
  return <Event />;
104
- } else {
105
- return <Schedule />;
106
101
  }
102
+ return <Schedule />;
107
103
  };
108
104
  const activateAt = activate_at
109
105
  ? timeDifference(new Date(), moment(activate_at), true)
@@ -8,6 +8,7 @@ import SubUnitAutomate from '..';
8
8
  import {
9
9
  AUTOMATE_TYPE,
10
10
  AccessibilityLabel,
11
+ AUTOMATE_TABS,
11
12
  } from '../../../../configs/Constants';
12
13
  import { SCProvider } from '../../../../context';
13
14
  import { mockSCStore } from '../../../../context/mockStore';
@@ -50,7 +51,7 @@ let data = {
50
51
  },
51
52
  },
52
53
  ],
53
- type: AUTOMATE_TYPE.ONE_TAP,
54
+ type: AUTOMATE_TABS.SCENARIO,
54
55
  },
55
56
  ],
56
57
  };
@@ -78,7 +79,11 @@ describe('test Item', () => {
78
79
  await item[0].props.onPress();
79
80
  });
80
81
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddNewOneTap, {
81
- type: 'one_tap',
82
+ automate: {
83
+ type: 'one_tap',
84
+ unit: undefined,
85
+ },
86
+ closeScreen: undefined,
82
87
  });
83
88
  mockedNavigate.mockClear();
84
89
 
@@ -198,8 +203,8 @@ describe('test Item', () => {
198
203
  data.type = 'schedule';
199
204
  data.listAutomate = [
200
205
  {
201
- text: AUTOMATE_TYPE.AUTOMATION,
202
- type: AUTOMATE_TYPE.AUTOMATION,
206
+ text: AUTOMATE_TABS.AUTOMATION,
207
+ type: AUTOMATE_TABS.AUTOMATION,
203
208
  data: [
204
209
  {
205
210
  id: 1,
@@ -233,8 +238,8 @@ describe('test Item', () => {
233
238
  await item[0].props.onPress();
234
239
  });
235
240
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddNewAutoSmart, {
236
- type: AUTOMATE_TYPE.VALUE_CHANGE,
237
- unit: undefined,
241
+ automate: { type: AUTOMATE_TYPE.VALUE_CHANGE, unit: undefined },
242
+ closeScreen: undefined,
238
243
  });
239
244
  mockedNavigate.mockClear();
240
245