@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.2.95",
4
+ "version": "0.2.98",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -81,10 +81,11 @@
81
81
  "eslint-plugin-react": "^7.21.5",
82
82
  "eslint-plugin-react-native": "^3.10.0",
83
83
  "factory-girl": "^5.0.4",
84
+ "husky": "^8.0.1",
84
85
  "jest": "^26.6.3",
85
86
  "jest-circus": "^26.6.3",
86
87
  "jetifier": "^1.6.6",
87
- "lint-staged": "^8.2.1",
88
+ "lint-staged": "^12.4.1",
88
89
  "metro-react-native-babel-preset": "^0.66.2",
89
90
  "node-html-parser": "^2.0.2",
90
91
  "react": "17.0.2",
@@ -97,7 +98,8 @@
97
98
  "dependencies": {
98
99
  "@ant-design/icons-react-native": "^2.2.1",
99
100
  "@ant-design/react-native": "^4.0.5",
100
- "@eohjsc/highcharts": "^1.0.6",
101
+ "@babel/helper-environment-visitor": "^7.16.7",
102
+ "@eohjsc/highcharts": "^1.0.8",
101
103
  "@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
102
104
  "@formatjs/intl-getcanonicallocales": "^1.4.5",
103
105
  "@formatjs/intl-numberformat": "^5.6.2",
@@ -188,7 +190,7 @@
188
190
  "react-native-unimodules": "^0.11.0",
189
191
  "react-native-version-check": "^3.4.2",
190
192
  "react-native-vlc-media-player": "^1.0.39",
191
- "react-native-webview": "^10.9.3",
193
+ "react-native-webview": "11.17.2",
192
194
  "react-native-wheel-color-picker": "^1.2.0",
193
195
  "react-native-wheel-scrollview-picker": "^1.2.2",
194
196
  "react-native-wifi-reborn": "^4.5.0",
@@ -209,5 +211,15 @@
209
211
  "bugs": {
210
212
  "url": "https://github.com/github_account/react-native-smart-city/issues"
211
213
  },
212
- "homepage": "https://github.com/github_account/react-native-smart-city#readme"
214
+ "homepage": "https://github.com/github_account/react-native-smart-city#readme",
215
+ "husky": {
216
+ "hooks": {
217
+ "pre-commit": "lint-staged"
218
+ }
219
+ },
220
+ "lint-staged": {
221
+ "*.{js, ts}": [
222
+ "yarn lint"
223
+ ]
224
+ }
213
225
  }
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 6C13.1046 6 14 5.10457 14 4C14 2.89543 13.1046 2 12 2C10.8954 2 10 2.89543 10 4C10 5.10457 10.8954 6 12 6Z" fill="#262626"/>
3
+ <path d="M15.89 8.11C15.5 7.72 14.83 7 13.53 7C13.32 7 12.11 7 10.99 7C8.24 6.99 6 4.75 6 2H4C4 5.16 6.11 7.84 9 8.71V22H11V16H13V22H15V10.05L18.95 14L20.36 12.59L15.89 8.11Z" fill="#262626"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21.753 9.0184C21.753 9.66253 21.2308 10.1847 20.5867 10.1847C20.4682 10.1847 20.3559 10.1617 20.2483 10.1291L18.5961 15.808H5.15687L3.50472 10.1291C3.39711 10.1617 3.28483 10.1847 3.16633 10.1847C2.52221 10.1847 2 9.66253 2 9.0184C2 8.37428 2.52221 7.85207 3.16633 7.85207C3.81046 7.85207 4.33266 8.37428 4.33266 9.0184C4.33266 9.24732 4.26424 9.45912 4.15041 9.6392L7.88142 12.1939L8.36195 7.3196C7.78003 7.25367 7.32625 6.76567 7.32625 6.16633C7.32625 5.52221 7.84846 5 8.49258 5C9.13671 5 9.65892 5.52221 9.65892 6.16633C9.65892 6.59305 9.42752 6.96224 9.08539 7.16565L11.8765 11.7398L14.6863 7.13517C14.3743 6.92585 14.1687 6.57035 14.1687 6.16633C14.1687 5.52221 14.6909 5 15.3351 5C15.9792 5 16.5014 5.52221 16.5014 6.16633C16.5014 6.79118 16.0091 7.2969 15.392 7.32707L15.8716 12.1939L19.6026 9.6392C19.4888 9.45912 19.4203 9.24732 19.4203 9.0184C19.4203 8.37428 19.9425 7.85207 20.5867 7.85207C21.2308 7.85207 21.753 8.37428 21.753 9.0184ZM5.15782 16.6384H18.5962V18.712H5.15782V16.6384Z" fill="#262626"/>
3
+ </svg>
@@ -43,8 +43,9 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
43
43
  useEffect(() => {
44
44
  sensor.quick_action &&
45
45
  sensor.quick_action.config_id &&
46
+ sensor.device_type !== 'GOOGLE_HOME' &&
46
47
  watchMultiConfigs([sensor.quick_action.config_id]);
47
- }, [sensor.quick_action]);
48
+ }, [sensor.quick_action, sensor?.device_type]);
48
49
 
49
50
  useEffect(() => {
50
51
  if (!sensor.quick_action) {
@@ -59,7 +60,9 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
59
60
  const userId = useSCContextSelector((state) => state?.auth.account.user.id);
60
61
  const onActionPress = useCallback(() => {
61
62
  sendRemoteCommand(sensor, action, null, userId);
62
- sensor.quick_action && watchMultiConfigs([sensor.quick_action.config_id]);
63
+ sensor.quick_action &&
64
+ sensor.device_type !== 'GOOGLE_HOME' &&
65
+ watchMultiConfigs([sensor.quick_action.config_id]);
63
66
  setIsSendingCommand(true);
64
67
 
65
68
  if (!sensor.quick_action) {
@@ -35,7 +35,7 @@ const ColorPickerTemplate = memo(({ actionGroup, doAction, sensor }) => {
35
35
  }, [configuration.config, configValues, configuration]);
36
36
 
37
37
  useEffect(() => {
38
- if (sensor?.is_managed_by_backend) {
38
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
39
39
  watchMultiConfigs([configuration.config]);
40
40
  }
41
41
  }, [sensor, configuration.config]);
@@ -39,7 +39,11 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
39
39
 
40
40
  const doActionAndWatchConfig = useCallback(
41
41
  (actionData, actionValue, actionName) => {
42
- doAction(actionData, actionValue, actionName);
42
+ doAction(
43
+ actionData,
44
+ JSON.stringify({ temperature: actionValue }),
45
+ actionName
46
+ );
43
47
  if (!sensor?.is_managed_by_backend) {
44
48
  return;
45
49
  }
@@ -50,9 +54,17 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
50
54
  return;
51
55
  }
52
56
 
53
- config && watchMultiConfigs([config]);
57
+ config &&
58
+ sensor.device_type !== 'GOOGLE_HOME' &&
59
+ watchMultiConfigs([config]);
54
60
  },
55
- [config, doAction, keep_track_config, sensor.is_managed_by_backend]
61
+ [
62
+ config,
63
+ doAction,
64
+ keep_track_config,
65
+ sensor.is_managed_by_backend,
66
+ sensor.device_type,
67
+ ]
56
68
  );
57
69
 
58
70
  const doActionUp = useCallback(async () => {
@@ -35,7 +35,9 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
35
35
  doAction(action_off_data, JSON.stringify(dataUnlock), actionName);
36
36
  }
37
37
  if (sensor?.is_managed_by_backend) {
38
- configuration.config && watchMultiConfigs([configuration.config]);
38
+ configuration.config &&
39
+ sensor.device_type !== 'GOOGLE_HOME' &&
40
+ watchMultiConfigs([configuration.config]);
39
41
  }
40
42
  }
41
43
  }, [
@@ -47,6 +49,7 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
47
49
  sensor?.name,
48
50
  configuration,
49
51
  sensor?.is_managed_by_backend,
52
+ sensor?.device_type,
50
53
  ]);
51
54
 
52
55
  useEffect(() => {
@@ -180,6 +180,7 @@ const SetupGeneratePasscode = memo(() => {
180
180
  showsVerticalScrollIndicator={false}
181
181
  showsHorizontalScrollIndicator={false}
182
182
  style={styles.scrollview}
183
+ scrollIndicatorInsets={{ right: 1 }}
183
184
  >
184
185
  <View style={styles.wrap}>
185
186
  <ButtonWrapper
@@ -11,23 +11,25 @@ const OnOffSimpleTemplate = ({
11
11
  triggerAction,
12
12
  actionGroup,
13
13
  disabled,
14
+ valueOfSwitch,
15
+ checkValueOfSwitch,
14
16
  }) => {
15
- const isEnabled = !!isOn;
16
-
17
17
  return (
18
18
  <View style={styles.wrap}>
19
19
  <View style={styles.iconAndText}>
20
20
  <IconOutline name="poweroff" size={20} style={styles.marginRight} />
21
21
  <Text type="H4">{actionGroup.title}</Text>
22
22
  </View>
23
- <Switch
24
- trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
25
- thumbColor={isEnabled ? Colors.White : Colors.Gray6}
26
- ios_backgroundColor={Colors.Gray4}
27
- onValueChange={triggerAction}
28
- value={isEnabled}
29
- disabled={disabled}
30
- />
23
+ {isOn !== null && (
24
+ <Switch
25
+ trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
26
+ thumbColor={isOn ? Colors.White : Colors.Gray6}
27
+ ios_backgroundColor={Colors.Gray4}
28
+ onValueChange={triggerAction}
29
+ value={checkValueOfSwitch ? !!isOn : valueOfSwitch}
30
+ disabled={disabled}
31
+ />
32
+ )}
31
33
  </View>
32
34
  );
33
35
  };
@@ -1,10 +1,19 @@
1
- import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
1
+ import React, {
2
+ memo,
3
+ useCallback,
4
+ useContext,
5
+ useEffect,
6
+ useMemo,
7
+ useState,
8
+ } from 'react';
2
9
  import { DEVICE_TYPE } from '../../../configs/Constants';
3
10
 
4
11
  import { watchMultiConfigs } from '../../../iot/Monitor';
5
12
  import { useConfigGlobalState } from '../../../iot/states';
6
13
  import OnOffButtonTemplate from './OnOffButtonTemplate';
7
14
  import OnOffSimpleTemplate from './OnOffSimpleTemplate';
15
+ import { SCContext } from '../../../context';
16
+ import { Action } from '../../../context/actionType';
8
17
 
9
18
  const getComponent = (template) => {
10
19
  switch (template) {
@@ -20,9 +29,14 @@ const getComponent = (template) => {
20
29
  const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
21
30
  const { configuration } = actionGroup;
22
31
  const { action_data, action_on_data, action_off_data } = configuration;
23
- const [isOn, setIsOn] = useState(true);
32
+ const [isOn, setIsOn] = useState(null);
33
+ const [valueOfSwitch, setValueOfSwitch] = useState(false);
34
+ const [checkValueOfSwitch, setCheckValueOfSwitch] = useState(true);
35
+ //checkValueOfSwitch to check the value real-time of Switch when re-entering the screen
36
+
24
37
  // eslint-disable-next-line no-unused-vars
25
38
  const [configValues, _] = useConfigGlobalState('configValues');
39
+ const { setAction } = useContext(SCContext);
26
40
 
27
41
  const actionName = useCallback(
28
42
  (text) => {
@@ -34,6 +48,10 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
34
48
  [actionGroup?.title, sensor?.name]
35
49
  );
36
50
  const triggerAction = useCallback(() => {
51
+ if (actionGroup?.template === 'OnOffSimpleActionTemplate') {
52
+ setAction(Action.IS_FULL_LOADING, true);
53
+ }
54
+ setCheckValueOfSwitch(false);
37
55
  switch (sensor?.device_type) {
38
56
  case DEVICE_TYPE.ZIGBEE:
39
57
  if (action_on_data && action_off_data) {
@@ -61,6 +79,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
61
79
  }
62
80
  }
63
81
  if (action_on_data && action_off_data) {
82
+ setValueOfSwitch(!isOn);
64
83
  if (isOn) {
65
84
  doAction(action_off_data, null, actionName('off'));
66
85
  } else {
@@ -68,20 +87,32 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
68
87
  }
69
88
  }
70
89
  if (sensor?.is_managed_by_backend) {
71
- configuration.config && watchMultiConfigs([configuration.config]);
90
+ configuration?.config &&
91
+ sensor?.device_type !== 'GOOGLE_HOME' &&
92
+ watchMultiConfigs([configuration?.config]);
93
+ if (actionGroup?.template === 'OnOffSimpleActionTemplate') {
94
+ const cleanTimeout = setTimeout(() => {
95
+ setAction(Action.IS_FULL_LOADING, false);
96
+ clearTimeout(cleanTimeout);
97
+ }, 2000);
98
+ }
99
+ } else {
100
+ setValueOfSwitch(isOn);
72
101
  }
73
102
  return;
74
103
  }
75
104
  }, [
105
+ actionGroup.template,
76
106
  actionName,
77
107
  action_data,
78
108
  action_off_data,
79
109
  action_on_data,
80
- configuration.config,
110
+ configuration?.config,
81
111
  doAction,
82
112
  isOn,
83
113
  sensor?.device_type,
84
114
  sensor?.is_managed_by_backend,
115
+ setAction,
85
116
  ]);
86
117
 
87
118
  useEffect(() => {
@@ -103,7 +134,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
103
134
  if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
104
135
  return;
105
136
  }
106
- if (sensor?.is_managed_by_backend) {
137
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
107
138
  watchMultiConfigs([configuration.config]);
108
139
  }
109
140
  }, [sensor, configuration.config]);
@@ -119,6 +150,8 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
119
150
  triggerAction={triggerAction}
120
151
  actionGroup={actionGroup}
121
152
  disabled={!action_data && !action_on_data && !action_off_data}
153
+ valueOfSwitch={valueOfSwitch}
154
+ checkValueOfSwitch={checkValueOfSwitch}
122
155
  />
123
156
  </>
124
157
  );
@@ -61,9 +61,15 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
61
61
  const value = getOptionValue(newOption);
62
62
  let actionName = `${sensor?.name} ${title?.toLowerCase()} ${value}`;
63
63
  actionName = actionName.replace(/\s+/g, ' ').trim();
64
- doAction(action_data, value, actionName);
64
+ doAction(
65
+ action_data,
66
+ JSON.stringify({ level: value, key_code: newOption?.value_int }),
67
+ actionName
68
+ );
65
69
  if (sensor?.is_managed_by_backend) {
66
- configuration.config && watchMultiConfigs([configuration.config]);
70
+ configuration.config &&
71
+ sensor.device_type !== 'GOOGLE_HOME' &&
72
+ watchMultiConfigs([configuration.config]);
67
73
  }
68
74
  hideAlertAction();
69
75
  }, [
@@ -75,6 +81,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
75
81
  selectedIndex,
76
82
  sensor?.is_managed_by_backend,
77
83
  sensor?.name,
84
+ sensor?.device_type,
78
85
  title,
79
86
  ]);
80
87
 
@@ -141,7 +148,10 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
141
148
  rightButtonClick={onDone}
142
149
  >
143
150
  <View style={styles.wrapRename}>
144
- <ScrollView style={styles.scrollView}>
151
+ <ScrollView
152
+ style={styles.scrollView}
153
+ scrollIndicatorInsets={{ right: 1 }}
154
+ >
145
155
  {!action_data && (
146
156
  <Text
147
157
  color={Colors.Gray6}
@@ -37,7 +37,7 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
37
37
  }, [configuration.config, configValues, configuration]);
38
38
 
39
39
  useEffect(() => {
40
- if (sensor?.is_managed_by_backend) {
40
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
41
41
  watchMultiConfigs([configuration.config]);
42
42
  }
43
43
  }, [sensor, configuration.config]);
@@ -91,7 +91,10 @@ const SmartTiviActionTemplate = memo(
91
91
  }, []);
92
92
  return (
93
93
  <>
94
- <ScrollView scrollEnabled={scrollEnabled}>
94
+ <ScrollView
95
+ scrollEnabled={scrollEnabled}
96
+ scrollIndicatorInsets={{ right: 1 }}
97
+ >
95
98
  <View style={styles.wrap}>
96
99
  <View style={styles.rowOnOff}>
97
100
  <CircleButton
@@ -45,10 +45,20 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
45
45
  actionName = actionName.replace(/\s+/g, ' ').trim();
46
46
  doAction(actionData, null, actionName);
47
47
  if (sensor?.is_managed_by_backend) {
48
- config && watchMultiConfigs([config]);
48
+ config &&
49
+ sensor.device_type !== 'GOOGLE_HOME' &&
50
+ watchMultiConfigs([config]);
49
51
  }
50
52
  },
51
- [config, doAction, sensor?.is_managed_by_backend, sensor?.name, text, title]
53
+ [
54
+ config,
55
+ doAction,
56
+ sensor?.is_managed_by_backend,
57
+ sensor?.name,
58
+ sensor?.device_type,
59
+ text,
60
+ title,
61
+ ]
52
62
  );
53
63
 
54
64
  const iconKit = !!icon_kit_data && icon_kit_data.icon;
@@ -114,10 +124,10 @@ const StatesGridActionTemplate = ({ actionGroup, doAction, sensor }) => {
114
124
  }, [configuration, configValues]);
115
125
 
116
126
  useEffect(() => {
117
- if (sensor?.is_managed_by_backend) {
127
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
118
128
  watchMultiConfigs(configuration.options.map((option) => option.config));
119
129
  }
120
- }, [sensor.is_managed_by_backend, configuration.options]);
130
+ }, [sensor.is_managed_by_backend, sensor.device_type, configuration.options]);
121
131
 
122
132
  return (
123
133
  <View style={styles.wrap}>
@@ -94,6 +94,7 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
94
94
  if (sensor.is_managed_by_backend) {
95
95
  hour !== undefined &&
96
96
  minute !== undefined &&
97
+ sensor.device_type !== 'GOOGLE_HOME' &&
97
98
  watchMultiConfigs([
98
99
  configuration.config_hour,
99
100
  configuration.config_minute,
@@ -106,13 +107,17 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
106
107
  configuration.config_minute,
107
108
  doAction,
108
109
  sensor.is_managed_by_backend,
110
+ sensor.device_type,
109
111
  ]
110
112
  );
111
113
 
112
114
  const doActionHour = useCallback(
113
115
  (hour) => {
114
116
  doAction(configuration.action_data, hour);
115
- if (sensor.is_managed_by_backend) {
117
+ if (
118
+ sensor.is_managed_by_backend &&
119
+ sensor.device_type !== 'GOOGLE_HOME'
120
+ ) {
116
121
  hour && watchMultiConfigs([configuration.config_hour]);
117
122
  }
118
123
  },
@@ -121,6 +126,7 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
121
126
  configuration.config_hour,
122
127
  doAction,
123
128
  sensor.is_managed_by_backend,
129
+ sensor.device_type,
124
130
  ]
125
131
  );
126
132
 
@@ -201,6 +207,8 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
201
207
  onConfirm={onConfirmTime}
202
208
  onCancel={onHideTime}
203
209
  display="spinner"
210
+ cancelTextIOS={t('cancel')}
211
+ confirmTextIOS={t('confirm')}
204
212
  />
205
213
  <BottomScrollPicker
206
214
  min={configuration.min}
@@ -37,7 +37,9 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
37
37
  }
38
38
  }
39
39
  if (sensor?.is_managed_by_backend) {
40
- configuration.config && watchMultiConfigs([configuration.config]);
40
+ configuration.config &&
41
+ sensor.device_type !== 'GOOGLE_HOME' &&
42
+ watchMultiConfigs([configuration.config]);
41
43
  }
42
44
  }, [
43
45
  actionName,
@@ -46,6 +48,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
46
48
  doAction,
47
49
  isOn,
48
50
  sensor?.is_managed_by_backend,
51
+ sensor?.device_type,
49
52
  ]);
50
53
 
51
54
  const triggerAction2 = useCallback(() => {
@@ -56,7 +59,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
56
59
  doAction(button2?.action_on_data, null, actionName('start'));
57
60
  }
58
61
  }
59
- if (sensor?.is_managed_by_backend) {
62
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
60
63
  configuration.config && watchMultiConfigs([configuration.config]);
61
64
  }
62
65
  }, [
@@ -67,6 +70,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
67
70
  doAction,
68
71
  isStart,
69
72
  sensor?.is_managed_by_backend,
73
+ sensor?.device_type,
70
74
  ]);
71
75
 
72
76
  useEffect(() => {
@@ -98,7 +102,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
98
102
  if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
99
103
  return;
100
104
  }
101
- if (sensor?.is_managed_by_backend) {
105
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
102
106
  watchMultiConfigs([configuration.config]);
103
107
  }
104
108
  }, [sensor, configuration.config]);
@@ -1,6 +1,14 @@
1
1
  import React, { useState } from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import Index from '../OnOffTemplate';
3
+ import OnOffTemplate from '../OnOffTemplate';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import { SCProvider } from '../../../context';
6
+
7
+ const wrapComponent = (actionGroup, mockDoAction) => (
8
+ <SCProvider initState={mockSCStore({})}>
9
+ <OnOffTemplate actionGroup={actionGroup} doAction={mockDoAction} />
10
+ </SCProvider>
11
+ );
4
12
 
5
13
  jest.mock('react', () => ({
6
14
  ...jest.requireActual('react'),
@@ -49,21 +57,15 @@ describe('Test OneBigButtonTemplate', () => {
49
57
  const assertRender = (state, text) => {
50
58
  useState.mockImplementationOnce((init) => [state, setState]);
51
59
  const mockDoAction = jest.fn();
60
+
52
61
  act(() => {
53
- wrapper = create(
54
- <Index actionGroup={actionGroup} doAction={mockDoAction} />
55
- );
62
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
56
63
  });
57
64
 
58
65
  const renderJson = wrapper.toJSON();
59
66
 
60
- expect(renderJson?.children[0].children[0].children[1].children).toEqual(
61
- undefined
62
- );
63
-
64
- expect(
65
- renderJson?.children[0].children[0].children[1].children
66
- ).not.toEqual([text]);
67
+ expect(renderJson?.props?.visible).toEqual(false);
68
+ expect(renderJson?.type).toEqual('Modal');
67
69
  };
68
70
 
69
71
  test('render state on', () => {
@@ -78,9 +80,7 @@ describe('Test OneBigButtonTemplate', () => {
78
80
  useState.mockImplementationOnce((init) => [state, setState]);
79
81
  const mockDoAction = jest.fn();
80
82
  act(() => {
81
- wrapper = create(
82
- <Index actionGroup={actionGroup} doAction={mockDoAction} />
83
- );
83
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
84
84
  });
85
85
 
86
86
  expect(mockDoAction).not.toHaveBeenCalled();