@eohjsc/react-native-smart-city 0.3.70 → 0.3.72
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.
- package/index.js +0 -2
- package/package.json +4 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +0 -1
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
- package/src/commons/ActionGroup/OnOffTemplate/index.js +22 -11
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +19 -13
- package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -4
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +9 -4
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +40 -39
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
- package/src/commons/ActionGroup/__test__/index.test.js +24 -16
- package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
- package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
- package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
- package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
- package/src/commons/CameraDevice/index.js +37 -22
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
- package/src/commons/Dashboard/MyUnit/index.js +1 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -1
- package/src/commons/Device/DeviceAlertStatus.js +1 -1
- package/src/commons/Device/DisconnectedView.js +10 -14
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +1 -1
- package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
- package/src/commons/Device/LinearChart.js +5 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +7 -16
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
- package/src/commons/Device/WindDirection/Compass/index.js +15 -23
- package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
- package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
- package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
- package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
- package/src/commons/DisplayChecking/index.js +4 -3
- package/src/commons/DisplayChecking/styles.js +2 -2
- package/src/commons/MediaPlayer/index.js +2 -1
- package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
- package/src/commons/MediaPlayerDetail/index.js +2 -3
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
- package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
- package/src/commons/MenuActionList/index.js +8 -70
- package/src/commons/MenuActionList/styles.js +68 -0
- package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
- package/src/commons/PreventAccess/index.js +3 -3
- package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
- package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
- package/src/commons/SubUnit/OneTap/index.js +6 -1
- package/src/commons/Today/__test__/Today.test.js +3 -3
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
- package/src/configs/IOPinConstants.js +285 -0
- package/src/configs/SCConfig.js +1 -0
- package/src/iot/RemoteControl/HomeAssistant.js +2 -11
- package/src/iot/RemoteControl/__test__/HomeAssistant.test.js +1 -33
- package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
- package/src/navigations/AllGatewayStack.js +3 -3
- package/src/navigations/UnitStack.js +0 -6
- package/src/screens/ActivityLog/__test__/index.test.js +16 -22
- package/src/screens/ActivityLog/index.js +2 -3
- package/src/screens/AddNewAction/SelectAction.js +3 -0
- package/src/screens/AddNewAction/SetupSensor.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
- package/src/screens/AllCamera/__test__/index.test.js +1 -1
- package/src/screens/AllCamera/index.js +1 -1
- package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
- package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
- package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
- package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
- package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
- package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
- package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
- package/src/screens/AllGateway/hooks/useGateway.js +1 -0
- package/src/screens/AllGateway/test-utils.js +20 -0
- package/src/screens/Device/__test__/detail.test.js +8 -3
- package/src/screens/Device/components/SensorDisplayItem.js +1 -5
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
- package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
- package/src/screens/GuestInfo/__test__/index.test.js +26 -14
- package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
- package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
- package/src/screens/PlayBackCamera/Timer.js +2 -3
- package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
- package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
- package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
- package/src/screens/SharedUnit/index.js +19 -17
- package/src/screens/SmartAccount/Connecting/index.js +2 -2
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
- package/src/screens/SmartAccount/ListDevice/index.js +1 -1
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
- package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
- package/src/screens/SubUnit/EditSubUnit.js +6 -6
- package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
- package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
- package/src/screens/Template/EditTemplate.js +13 -3
- package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
- package/src/screens/Unit/Detail.js +157 -121
- package/src/screens/Unit/ManageUnit.js +3 -3
- package/src/screens/Unit/ManageUnitStyles.js +1 -1
- package/src/screens/Unit/__test__/Detail.test.js +40 -20
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
- package/src/screens/Unit/components/AutomateScript/index.js +9 -8
- package/src/screens/Unit/components/Header/index.js +1 -14
- package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
- package/src/screens/Unit/components/__test__/Header.test.js +14 -9
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
- package/src/utils/I18n/translations/en.json +2 -1
- package/src/utils/I18n/translations/vi.json +2 -1
- package/src/utils/Route/index.js +1 -2
- package/src/utils/Utils.js +62 -2
- package/src/commons/Explore/ActivityIndicator/index.js +0 -49
- package/src/commons/Explore/CityItem/index.js +0 -116
- package/src/commons/Explore/HeaderExplore/index.js +0 -44
- package/src/commons/Explore/HeaderLabel/index.js +0 -46
- package/src/commons/Explore/LocationItem/index.js +0 -71
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
- package/src/commons/Explore/SearchBox/index.js +0 -59
- package/src/commons/Explore/__test__/CityItem.test.js +0 -156
- package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
- package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
- package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
- package/src/screens/Explore/__test__/Explore.test.js +0 -43
- package/src/screens/Explore/index.js +0 -201
- package/src/screens/Unit/MyAllUnit/index.js +0 -44
- package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
- package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
- package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
package/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { UnitStack } from './src/navigations/UnitStack';
|
|
|
9
9
|
import { EmergencyContactsStack } from './src/navigations/EmergencyContactsStack';
|
|
10
10
|
import { AddUnitStack } from './src/navigations/AddUnitStack';
|
|
11
11
|
import SharedStack from './src/navigations/SharedStack';
|
|
12
|
-
import Explore from './src/screens/Explore';
|
|
13
12
|
import { AddLGDeviceStack } from './src/navigations/AddLGDeviceStack';
|
|
14
13
|
import { initSCConfig } from './src/configs';
|
|
15
14
|
import AutomateStack from './src/navigations/AutomateStack';
|
|
@@ -34,7 +33,6 @@ export {
|
|
|
34
33
|
UnitStack,
|
|
35
34
|
AddUnitStack,
|
|
36
35
|
SharedStack,
|
|
37
|
-
Explore,
|
|
38
36
|
SCProvider,
|
|
39
37
|
SCContext,
|
|
40
38
|
AddLGDeviceStack,
|
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.3.
|
|
4
|
+
"version": "0.3.72",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -119,7 +119,6 @@
|
|
|
119
119
|
"@react-native-community/segmented-control": "^2.1.1",
|
|
120
120
|
"@react-native-community/slider": "^3.0.3",
|
|
121
121
|
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
|
|
122
|
-
"@react-native-community/viewpager": "^4.1.4",
|
|
123
122
|
"@react-native-picker/picker": "^1.16.7",
|
|
124
123
|
"@react-navigation/bottom-tabs": "^5.8.0",
|
|
125
124
|
"@react-navigation/drawer": "^5.9.0",
|
|
@@ -129,6 +128,7 @@
|
|
|
129
128
|
"@testing-library/react-hooks": "^6.0.0",
|
|
130
129
|
"apisauce": "^2.1.5",
|
|
131
130
|
"axios": "^0.19.2",
|
|
131
|
+
"deprecated-react-native-prop-types": "^2.3.0",
|
|
132
132
|
"dotenv": "^8.2.0",
|
|
133
133
|
"google-libphonenumber": "^3.2.10",
|
|
134
134
|
"home-assistant-js-websocket": "^5.7.0",
|
|
@@ -153,7 +153,6 @@
|
|
|
153
153
|
"react-native-android-keyboard-adjust": "^1.2.0",
|
|
154
154
|
"react-native-android-location-enabler": "^1.2.2",
|
|
155
155
|
"react-native-android-wifi": "^0.0.41",
|
|
156
|
-
"react-native-animated-ellipsis": "^2.0.0",
|
|
157
156
|
"react-native-appearance": "^0.3.4",
|
|
158
157
|
"react-native-base64": "^0.1.0",
|
|
159
158
|
"react-native-ble-plx": "^2.0.3",
|
|
@@ -174,11 +173,13 @@
|
|
|
174
173
|
"react-native-input-credit-card": "^0.5.5",
|
|
175
174
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
176
175
|
"react-native-linear-gradient": "^2.5.6",
|
|
176
|
+
"react-native-loading-dots": "^1.3.2",
|
|
177
177
|
"react-native-localize": "^1.4.1",
|
|
178
178
|
"react-native-maps": "0.27.1",
|
|
179
179
|
"react-native-maps-directions": "^1.8.0",
|
|
180
180
|
"react-native-modal": "^11.5.6",
|
|
181
181
|
"react-native-modal-datetime-picker": "^8.9.3",
|
|
182
|
+
"react-native-new-snap-carousel": "^3.9.3",
|
|
182
183
|
"react-native-onesignal": "^4.3.1",
|
|
183
184
|
"react-native-pager-view": "^5.4.1",
|
|
184
185
|
"react-native-parallax-scroll-view": "^0.21.3",
|
|
@@ -190,8 +191,6 @@
|
|
|
190
191
|
"react-native-responsive-fontsize": "^0.5.1",
|
|
191
192
|
"react-native-safe-area-context": "^3.1.1",
|
|
192
193
|
"react-native-screens": "^2.9.0",
|
|
193
|
-
"react-native-slider": "^0.11.0",
|
|
194
|
-
"react-native-snap-carousel": "4.0.0-beta.5",
|
|
195
194
|
"react-native-super-grid": "^4.0.3",
|
|
196
195
|
"react-native-svg": "^12.1.0",
|
|
197
196
|
"react-native-toast-message": "^2.1.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import Slider from 'react-native-slider';
|
|
3
|
+
import Slider from '@react-native-community/slider';
|
|
4
4
|
import Text from '../../../Text';
|
|
5
5
|
import { HeaderCustom } from '../../../Header';
|
|
6
6
|
import ButtonWrapper from './ButtonWrapper';
|
|
@@ -56,7 +56,7 @@ const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
|
56
56
|
}, [config, configValues, configuration, is_on_value]);
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
|
|
59
|
+
<View style={styles.wrap}>
|
|
60
60
|
<View>
|
|
61
61
|
<TouchableOpacity
|
|
62
62
|
onPress={handleActionSmartLock}
|
|
@@ -78,7 +78,7 @@ const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
|
78
78
|
{t(isUnlock ? 'door_is_open' : 'door_is_close')}
|
|
79
79
|
</Text>
|
|
80
80
|
</View>
|
|
81
|
-
|
|
81
|
+
</View>
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -5,6 +5,7 @@ import SetupGeneratePasscode from '../index';
|
|
|
5
5
|
import { mockSCStore } from '../../../../../context/mockStore';
|
|
6
6
|
import { AccessibilityLabel } from '../../../../../configs/Constants';
|
|
7
7
|
import { SCProvider } from '../../../../../context';
|
|
8
|
+
import WheelDateTimePicker from '../../../../WheelDateTimePicker';
|
|
8
9
|
|
|
9
10
|
const mockNavigate = jest.fn();
|
|
10
11
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -66,17 +67,17 @@ describe('Test SetupGeneratePasscode', () => {
|
|
|
66
67
|
expect(changeTime[0]).toBeDefined();
|
|
67
68
|
expect(changeDuration[0]).toBeDefined();
|
|
68
69
|
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
await act(async () => {
|
|
71
|
+
await changeDuration[0].props.onPressSetMinute();
|
|
72
|
+
});
|
|
73
|
+
await act(async () => {
|
|
74
|
+
await changeDuration[0].props.onPressSelectCircle();
|
|
75
|
+
});
|
|
76
|
+
await act(async () => {
|
|
77
|
+
await changeTime[0].props.onPressSetTime();
|
|
78
|
+
});
|
|
72
79
|
|
|
73
|
-
const wheelDateTimePicker = instance.
|
|
74
|
-
|
|
75
|
-
item.props.accessibilityLabel ===
|
|
76
|
-
`${AccessibilityLabel.WHEEL_DATE_TIME_PICKER_BUTTON}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
77
|
-
);
|
|
78
|
-
await wheelDateTimePicker[5].props.onClick();
|
|
79
|
-
await wheelDateTimePicker[11].props.onClick();
|
|
80
|
-
await wheelDateTimePicker[17].props.onClick();
|
|
80
|
+
const wheelDateTimePicker = instance.findAllByType(WheelDateTimePicker);
|
|
81
|
+
expect(wheelDateTimePicker).toHaveLength(3);
|
|
81
82
|
});
|
|
82
83
|
});
|
|
@@ -56,7 +56,7 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
56
56
|
const updateStatusFromPusher = useCallback(() => {
|
|
57
57
|
setTimeout(() => {
|
|
58
58
|
setTempIsOn(temp);
|
|
59
|
-
},
|
|
59
|
+
}, 3000);
|
|
60
60
|
}, []);
|
|
61
61
|
|
|
62
62
|
const triggerAction = useCallback(async () => {
|
|
@@ -64,28 +64,39 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
64
64
|
if (!action_data) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
let data
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
let data;
|
|
68
|
+
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
69
|
+
data = null;
|
|
70
|
+
} else {
|
|
71
|
+
data = {
|
|
72
|
+
value: isOn ? 0 : 1,
|
|
73
|
+
state: isOn ? 0 : 1, // todo Bang remove this for Zigbee
|
|
74
|
+
};
|
|
75
|
+
if (allow_config_store_value && config) {
|
|
76
|
+
data.config_id = config;
|
|
77
|
+
data.config_value = data.value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
81
|
+
setTempIsOn((prev) => !prev);
|
|
74
82
|
}
|
|
75
|
-
setTempIsOn((prev) => !prev);
|
|
76
83
|
await doAction(action_data, data);
|
|
77
84
|
updateStatusFromPusher(); // todo Bang read about this magic
|
|
78
85
|
|
|
79
|
-
sensor?.is_managed_by_backend &&
|
|
86
|
+
sensor?.is_managed_by_backend &&
|
|
87
|
+
config &&
|
|
88
|
+
sensor.device_type === DEVICE_TYPE.LG_THINQ &&
|
|
89
|
+
watchMultiConfigs([config]);
|
|
80
90
|
}, [
|
|
81
91
|
isOn,
|
|
82
92
|
action_off_data,
|
|
83
93
|
action_on_data,
|
|
94
|
+
sensor?.device_type,
|
|
95
|
+
sensor?.is_managed_by_backend,
|
|
84
96
|
allow_config_store_value,
|
|
85
97
|
config,
|
|
86
98
|
doAction,
|
|
87
99
|
updateStatusFromPusher,
|
|
88
|
-
sensor?.is_managed_by_backend,
|
|
89
100
|
]);
|
|
90
101
|
|
|
91
102
|
useUnwatchLGDeviceConfigControl(sensor, [config]);
|
|
@@ -9,7 +9,7 @@ import { useDropdownAction } from './hooks/useDropdownAction';
|
|
|
9
9
|
import { useConfigGlobalState } from '../../iot/states';
|
|
10
10
|
import { useUnwatchLGDeviceConfigControl } from '../../hooks/IoT';
|
|
11
11
|
import styles from './OptionsDropdownActionTemplateStyle';
|
|
12
|
-
import { AccessibilityLabel } from '../../configs/Constants';
|
|
12
|
+
import { AccessibilityLabel, DEVICE_TYPE } from '../../configs/Constants';
|
|
13
13
|
import IconComponent from '../../commons/IconComponent';
|
|
14
14
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
15
15
|
import SvgDoorState from '../../../assets/images/Device/door-state.svg';
|
|
@@ -70,25 +70,31 @@ const OptionsDropdownActionTemplate = ({
|
|
|
70
70
|
const newOption = options[selectedIndex];
|
|
71
71
|
const value = getOptionValue(newOption, allow_config_store_value);
|
|
72
72
|
|
|
73
|
-
let data
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
let data;
|
|
74
|
+
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
75
|
+
data = value;
|
|
76
|
+
} else {
|
|
77
|
+
data = {
|
|
78
|
+
value: newOption?.value_int, // todo Bang keep only this
|
|
79
|
+
level: value,
|
|
80
|
+
key_code: newOption?.value_int,
|
|
81
|
+
};
|
|
82
|
+
if (allow_config_store_value && config) {
|
|
83
|
+
data.config_id = config;
|
|
84
|
+
data.config_value = newOption?.value_int;
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
doAction(action_data, data);
|
|
83
88
|
hideAlertAction();
|
|
84
89
|
}, [
|
|
85
|
-
|
|
90
|
+
options,
|
|
91
|
+
selectedIndex,
|
|
86
92
|
allow_config_store_value,
|
|
87
|
-
|
|
93
|
+
sensor.device_type,
|
|
94
|
+
config,
|
|
88
95
|
doAction,
|
|
96
|
+
action_data,
|
|
89
97
|
hideAlertAction,
|
|
90
|
-
options,
|
|
91
|
-
selectedIndex,
|
|
92
98
|
]);
|
|
93
99
|
|
|
94
100
|
useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
|
|
@@ -5,7 +5,7 @@ import styles from './SliderRangeTemplateStyles';
|
|
|
5
5
|
import Text from '../Text';
|
|
6
6
|
import { Colors } from '../../configs';
|
|
7
7
|
import SvgBrightness from '../../../assets/images/brightness.svg';
|
|
8
|
-
import
|
|
8
|
+
import Slider from '@react-native-community/slider';
|
|
9
9
|
import { useConfigGlobalState } from '../../iot/states';
|
|
10
10
|
import { DEVICE_TYPE } from '../../configs/Constants';
|
|
11
11
|
|
|
@@ -35,7 +35,7 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
35
35
|
async (value) => {
|
|
36
36
|
await doAction(
|
|
37
37
|
configuration?.action_brightness_data || configuration?.action_data,
|
|
38
|
-
JSON.stringify({ value_brness: value })
|
|
38
|
+
JSON.stringify({ value_brness: value, value: value })
|
|
39
39
|
);
|
|
40
40
|
},
|
|
41
41
|
[
|
|
@@ -75,7 +75,7 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
75
75
|
</Text>
|
|
76
76
|
</View>
|
|
77
77
|
<View style={styles.RightBrightness}>
|
|
78
|
-
<
|
|
78
|
+
<Slider
|
|
79
79
|
style={styles.slider}
|
|
80
80
|
value={valueBrightness}
|
|
81
81
|
onSlidingComplete={onChangeBrightness}
|
|
@@ -89,7 +89,6 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
89
89
|
trackStyle={styles.trackSlider}
|
|
90
90
|
thumbStyle={styles.thumbSlider}
|
|
91
91
|
/>
|
|
92
|
-
|
|
93
92
|
<View style={styles.valuePercent}>
|
|
94
93
|
<Text type="Label" style={styles.textValuePercent}>
|
|
95
94
|
{`${valueBrightness}%`}
|
|
@@ -20,6 +20,9 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
20
20
|
icon1,
|
|
21
21
|
icon2,
|
|
22
22
|
icon3,
|
|
23
|
+
icon_kit1_data,
|
|
24
|
+
icon_kit2_data,
|
|
25
|
+
icon_kit3_data,
|
|
23
26
|
text_door_lock,
|
|
24
27
|
is_display_lock,
|
|
25
28
|
} = configuration || {};
|
|
@@ -28,7 +31,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
28
31
|
return icon === 'stop' ? (
|
|
29
32
|
<View style={styles.squareStop} />
|
|
30
33
|
) : (
|
|
31
|
-
<IconComponent icon={
|
|
34
|
+
<IconComponent icon={icon} iconSize={30} />
|
|
32
35
|
);
|
|
33
36
|
};
|
|
34
37
|
const onButton1Press = useCallback(() => {
|
|
@@ -91,7 +94,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
91
94
|
underlayColor={Colors.Gray2}
|
|
92
95
|
>
|
|
93
96
|
<View style={styles.imageButton}>
|
|
94
|
-
<IconComponent icon={icon1} iconSize={30} />
|
|
97
|
+
<IconComponent icon={icon_kit1_data?.icon || icon1} iconSize={30} />
|
|
95
98
|
</View>
|
|
96
99
|
<Text style={styles.text}>{text1}</Text>
|
|
97
100
|
</TouchableOpacity>
|
|
@@ -102,7 +105,9 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
102
105
|
onPress={onButton2Press}
|
|
103
106
|
underlayColor={Colors.Gray2}
|
|
104
107
|
>
|
|
105
|
-
<View style={styles.imageButton}>
|
|
108
|
+
<View style={styles.imageButton}>
|
|
109
|
+
{iconCustom(icon_kit2_data?.icon || icon2)}
|
|
110
|
+
</View>
|
|
106
111
|
<Text style={styles.text}>{text2}</Text>
|
|
107
112
|
</TouchableOpacity>
|
|
108
113
|
|
|
@@ -113,7 +118,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
113
118
|
underlayColor={Colors.Gray2}
|
|
114
119
|
>
|
|
115
120
|
<View style={styles.imageButton}>
|
|
116
|
-
<IconComponent icon={icon3} iconSize={30} />
|
|
121
|
+
<IconComponent icon={icon_kit3_data?.icon || icon3} iconSize={30} />
|
|
117
122
|
</View>
|
|
118
123
|
<Text style={styles.text}>{text3}</Text>
|
|
119
124
|
</TouchableOpacity>
|
|
@@ -85,6 +85,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
85
85
|
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
86
86
|
});
|
|
87
87
|
const instance = wrapper.root;
|
|
88
|
+
await act(async () => {
|
|
89
|
+
instance.findAllByType(TouchableOpacity)[0].props.onPress();
|
|
90
|
+
});
|
|
88
91
|
|
|
89
92
|
const texts = instance.findAllByType(Text);
|
|
90
93
|
const radioCircles = instance.findAllByType(RadioCircle);
|
|
@@ -104,6 +107,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
104
107
|
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
105
108
|
});
|
|
106
109
|
const instance = wrapper.root;
|
|
110
|
+
await act(async () => {
|
|
111
|
+
instance.findAllByType(TouchableOpacity)[0].props.onPress();
|
|
112
|
+
});
|
|
107
113
|
|
|
108
114
|
const text = instance.findAllByType(Text);
|
|
109
115
|
expect(text[0].props.children).toEqual('Fan Speed'); // title
|
|
@@ -118,12 +124,20 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
118
124
|
const instance = wrapper.root;
|
|
119
125
|
|
|
120
126
|
const touchs = instance.findAllByType(TouchableOpacity);
|
|
121
|
-
expect(touchs).toHaveLength(5); // 1 show popup + 2 alert bottom button + 2 option
|
|
122
127
|
const showListOption = touchs[0];
|
|
123
128
|
|
|
124
129
|
const texts = instance.findAllByType(Text);
|
|
125
130
|
expect(texts[1].props.children).toEqual('Level2'); // selectedOption
|
|
126
131
|
|
|
132
|
+
const alertAction = instance.findByType(AlertAction);
|
|
133
|
+
expect(alertAction.props.visible).toBeFalsy();
|
|
134
|
+
|
|
135
|
+
// show option
|
|
136
|
+
await act(async () => {
|
|
137
|
+
await showListOption.props.onPress();
|
|
138
|
+
});
|
|
139
|
+
expect(alertAction.props.visible).toBeTruthy();
|
|
140
|
+
|
|
127
141
|
const radioCircles = instance.findAllByType(RadioCircle);
|
|
128
142
|
expect(radioCircles[0].props.active).toBeFalsy();
|
|
129
143
|
expect(radioCircles[1].props.active).toBeTruthy(); // choosing 2nd radioCircle in list
|
|
@@ -136,15 +150,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
136
150
|
);
|
|
137
151
|
expect(listChoosingOption).toHaveLength(2); // 2 option
|
|
138
152
|
|
|
139
|
-
const alertAction = instance.findByType(AlertAction);
|
|
140
|
-
expect(alertAction.props.visible).toBeFalsy();
|
|
141
|
-
|
|
142
|
-
// show option
|
|
143
|
-
await act(async () => {
|
|
144
|
-
await showListOption.props.onPress();
|
|
145
|
-
});
|
|
146
|
-
expect(alertAction.props.visible).toBeTruthy();
|
|
147
|
-
|
|
148
153
|
// Choosed Level1 option
|
|
149
154
|
await act(async () => {
|
|
150
155
|
await listChoosingOption[0].props.onPress();
|
|
@@ -188,12 +193,20 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
188
193
|
const instance = wrapper.root;
|
|
189
194
|
|
|
190
195
|
const touchs = instance.findAllByType(TouchableOpacity);
|
|
191
|
-
expect(touchs).toHaveLength(5);
|
|
192
196
|
const showListOption = touchs[0];
|
|
193
197
|
|
|
194
198
|
const texts = instance.findAllByType(Text);
|
|
195
199
|
expect(texts[1].props.children).toEqual('Level2');
|
|
196
200
|
|
|
201
|
+
const alertAction = instance.findByType(AlertAction);
|
|
202
|
+
expect(alertAction.props.visible).toBeFalsy();
|
|
203
|
+
|
|
204
|
+
// show option
|
|
205
|
+
await act(async () => {
|
|
206
|
+
await showListOption.props.onPress();
|
|
207
|
+
});
|
|
208
|
+
expect(alertAction.props.visible).toBeTruthy();
|
|
209
|
+
|
|
197
210
|
const radioCircles = instance.findAllByType(RadioCircle);
|
|
198
211
|
expect(radioCircles[0].props.active).toBeFalsy();
|
|
199
212
|
expect(radioCircles[1].props.active).toBeTruthy();
|
|
@@ -206,15 +219,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
206
219
|
);
|
|
207
220
|
expect(listChoosingOption).toHaveLength(2);
|
|
208
221
|
|
|
209
|
-
const alertAction = instance.findByType(AlertAction);
|
|
210
|
-
expect(alertAction.props.visible).toBeFalsy();
|
|
211
|
-
|
|
212
|
-
// show option
|
|
213
|
-
await act(async () => {
|
|
214
|
-
await showListOption.props.onPress();
|
|
215
|
-
});
|
|
216
|
-
expect(alertAction.props.visible).toBeTruthy();
|
|
217
|
-
|
|
218
222
|
// Choosed Level1 option
|
|
219
223
|
await act(async () => {
|
|
220
224
|
await listChoosingOption[0].props.onPress();
|
|
@@ -247,6 +251,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
247
251
|
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
248
252
|
});
|
|
249
253
|
const instance = wrapper.root;
|
|
254
|
+
await act(async () => {
|
|
255
|
+
instance.findAllByType(TouchableOpacity)[0].props.onPress();
|
|
256
|
+
});
|
|
250
257
|
const textDisplaySelected = instance.find(
|
|
251
258
|
(el) =>
|
|
252
259
|
el.props.accessibilityLabel ===
|
|
@@ -257,6 +264,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
257
264
|
getTranslate('en', 'not_available')
|
|
258
265
|
);
|
|
259
266
|
});
|
|
267
|
+
|
|
260
268
|
it('doAction sensor device type is GOOGLE_HOME', async () => {
|
|
261
269
|
actionGroup.configuration.options[0].value_text = 'level-1';
|
|
262
270
|
sensor.device_type = DEVICE_TYPE.GOOGLE_HOME;
|
|
@@ -265,26 +273,12 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
265
273
|
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
266
274
|
});
|
|
267
275
|
const instance = wrapper.root;
|
|
268
|
-
|
|
269
276
|
const touchs = instance.findAllByType(TouchableOpacity);
|
|
270
|
-
expect(touchs).toHaveLength(5);
|
|
271
277
|
const showListOption = touchs[0];
|
|
272
278
|
|
|
273
279
|
const texts = instance.findAllByType(Text);
|
|
274
280
|
expect(texts[1].props.children).toEqual('Level2');
|
|
275
281
|
|
|
276
|
-
const radioCircles = instance.findAllByType(RadioCircle);
|
|
277
|
-
expect(radioCircles[0].props.active).toBeFalsy();
|
|
278
|
-
expect(radioCircles[1].props.active).toBeTruthy();
|
|
279
|
-
|
|
280
|
-
const listChoosingOption = instance.findAll(
|
|
281
|
-
(el) =>
|
|
282
|
-
el.props.accessibilityLabel ===
|
|
283
|
-
AccessibilityLabel.OPTIONS_DROPDOWN_ACTION_CHOOSING_ITEM &&
|
|
284
|
-
el.type === TouchableOpacity
|
|
285
|
-
);
|
|
286
|
-
expect(listChoosingOption).toHaveLength(2);
|
|
287
|
-
|
|
288
282
|
const alertAction = instance.findByType(AlertAction);
|
|
289
283
|
expect(alertAction.props.visible).toBeFalsy();
|
|
290
284
|
|
|
@@ -294,6 +288,17 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
294
288
|
});
|
|
295
289
|
expect(alertAction.props.visible).toBeTruthy();
|
|
296
290
|
|
|
291
|
+
const listChoosingOption = instance.findAll(
|
|
292
|
+
(el) =>
|
|
293
|
+
el.props.accessibilityLabel ===
|
|
294
|
+
AccessibilityLabel.OPTIONS_DROPDOWN_ACTION_CHOOSING_ITEM &&
|
|
295
|
+
el.type === TouchableOpacity
|
|
296
|
+
);
|
|
297
|
+
expect(listChoosingOption).toHaveLength(2);
|
|
298
|
+
const radioCircles = instance.findAllByType(RadioCircle);
|
|
299
|
+
expect(radioCircles[0].props.active).toBeFalsy();
|
|
300
|
+
expect(radioCircles[1].props.active).toBeTruthy();
|
|
301
|
+
|
|
297
302
|
// Choose Level1 option
|
|
298
303
|
await act(async () => {
|
|
299
304
|
await listChoosingOption[0].props.onPress();
|
|
@@ -308,10 +313,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
308
313
|
});
|
|
309
314
|
expect(alertAction.props.visible).toBeFalsy();
|
|
310
315
|
|
|
311
|
-
expect(mockDoAction).toHaveBeenCalledWith(action_data,
|
|
312
|
-
value: 1,
|
|
313
|
-
level: 'level-1',
|
|
314
|
-
key_code: 1,
|
|
315
|
-
});
|
|
316
|
+
expect(mockDoAction).toHaveBeenCalledWith(action_data, 'level-1');
|
|
316
317
|
});
|
|
317
318
|
});
|
|
@@ -5,7 +5,7 @@ import SliderRangeTemplate from '../SliderRangeTemplate';
|
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
7
|
import { useConfigGlobalState } from '../../../iot/states';
|
|
8
|
-
import SliderRange from 'react-native-slider';
|
|
8
|
+
import SliderRange from '@react-native-community/slider';
|
|
9
9
|
|
|
10
10
|
jest.mock('../../../iot/Monitor');
|
|
11
11
|
const mockDoAction = jest.fn();
|
|
@@ -62,7 +62,7 @@ describe('Test SliderRangeTemplate', () => {
|
|
|
62
62
|
});
|
|
63
63
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
64
64
|
action_data,
|
|
65
|
-
JSON.stringify({ value_brness: 50 })
|
|
65
|
+
JSON.stringify({ value_brness: 50, value: 50 })
|
|
66
66
|
);
|
|
67
67
|
});
|
|
68
68
|
|
|
@@ -82,7 +82,7 @@ describe('Test SliderRangeTemplate', () => {
|
|
|
82
82
|
});
|
|
83
83
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
84
84
|
action_data,
|
|
85
|
-
JSON.stringify({ value_brness: 50 })
|
|
85
|
+
JSON.stringify({ value_brness: 50, value: 50 })
|
|
86
86
|
);
|
|
87
87
|
});
|
|
88
88
|
|
|
@@ -74,7 +74,7 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
74
74
|
});
|
|
75
75
|
const instance = wrapper.root;
|
|
76
76
|
const texts = instance.findAllByType(Text);
|
|
77
|
-
expect(texts).
|
|
77
|
+
expect(texts[0].props.children).toEqual(undefined);
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it('render template', async () => {
|
|
@@ -84,19 +84,20 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
84
84
|
const instance = wrapper.root;
|
|
85
85
|
|
|
86
86
|
const texts = instance.findAllByType(Text);
|
|
87
|
-
expect(texts).toHaveLength(7);
|
|
88
87
|
expect(texts[0].props.children).toEqual('Timer');
|
|
89
88
|
expect(texts[1].props.children).toEqual('Setting at 18:30');
|
|
90
89
|
|
|
91
90
|
const switchButton = instance.findByType(Switch);
|
|
92
91
|
expect(switchButton.props.value).toBeTruthy();
|
|
93
|
-
await
|
|
92
|
+
await act(async () => {
|
|
93
|
+
await switchButton.props.onValueChange();
|
|
94
|
+
});
|
|
94
95
|
expect(mockDoAction).toBeCalled();
|
|
95
96
|
|
|
96
|
-
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
97
|
-
expect(bottomScrollPicker).toBeDefined();
|
|
98
97
|
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
99
|
-
await
|
|
98
|
+
await act(async () => {
|
|
99
|
+
await TouchableOpacities[0].props.onPress();
|
|
100
|
+
});
|
|
100
101
|
|
|
101
102
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
102
103
|
expect(dateTimePicker.props.isVisible).toBeTruthy();
|
|
@@ -119,17 +120,25 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
119
120
|
});
|
|
120
121
|
const instance = wrapper.root;
|
|
121
122
|
|
|
123
|
+
await act(async () => {
|
|
124
|
+
instance.findAllByType(TouchableOpacity)[0].props.onPress();
|
|
125
|
+
});
|
|
122
126
|
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
123
127
|
expect(bottomScrollPicker).toBeDefined();
|
|
124
128
|
|
|
125
129
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
126
130
|
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
127
|
-
await
|
|
128
|
-
|
|
131
|
+
await act(async () => {
|
|
132
|
+
await dateTimePicker.props.onConfirm();
|
|
133
|
+
});
|
|
129
134
|
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
130
135
|
expect(TouchableOpacities).toHaveLength(3);
|
|
131
|
-
await
|
|
132
|
-
|
|
136
|
+
await act(async () => {
|
|
137
|
+
await TouchableOpacities[0].props.onPress();
|
|
138
|
+
});
|
|
139
|
+
await act(async () => {
|
|
140
|
+
await TouchableOpacities[2].props.onPress(3);
|
|
141
|
+
});
|
|
133
142
|
expect(mockDoAction).toBeCalled();
|
|
134
143
|
});
|
|
135
144
|
});
|
|
@@ -69,7 +69,6 @@ describe('Test TimerActionTemplate without config value', () => {
|
|
|
69
69
|
const instance = wrapper.root;
|
|
70
70
|
|
|
71
71
|
const texts = instance.findAllByType(Text);
|
|
72
|
-
expect(texts).toHaveLength(7);
|
|
73
72
|
expect(texts[0].props.children).toEqual('Timer');
|
|
74
73
|
|
|
75
74
|
const switchButton = instance.findByType(Switch);
|