@eohjsc/react-native-smart-city 0.3.28 → 0.3.31
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/package.json +1 -1
- package/src/Images/DevMode/close.png +0 -0
- package/src/Images/DevMode/close@2x.png +0 -0
- package/src/Images/DevMode/close@3x.png +0 -0
- package/src/Images/DevMode/plus.png +0 -0
- package/src/Images/DevMode/plus@2x.png +0 -0
- package/src/Images/DevMode/plus@3x.png +0 -0
- package/src/Images/DevMode/remove_circle.png +0 -0
- package/src/Images/DevMode/remove_circle@2x.png +0 -0
- package/src/Images/DevMode/remove_circle@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +36 -17
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +13 -8
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +37 -44
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +7 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -2
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +28 -18
- package/src/commons/ActionGroup/SliderRangeTemplate.js +24 -16
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +48 -58
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +134 -132
- package/src/commons/ActionGroup/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/index.js +35 -10
- package/src/commons/ActionTemplate/CurtainAction.js +60 -0
- package/src/commons/ActionTemplate/CurtainActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +44 -0
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +11 -0
- package/src/commons/ActionTemplate/index.js +18 -0
- package/src/commons/BottomButtonView/index.js +1 -0
- package/src/commons/Button/index.js +2 -0
- package/src/commons/DevMode/CardDevMode.js +42 -0
- package/src/commons/DevMode/EmptyComponent.js +18 -0
- package/src/commons/DevMode/Item.js +21 -0
- package/src/commons/DevMode/Styles/CardStyles.js +40 -0
- package/src/commons/DevMode/Styles/EmptyComponentStyles.js +15 -0
- package/src/commons/DevMode/Styles/ItemStyles.js +27 -0
- package/src/commons/DevMode/Styles/TextWithLabelStyles.js +36 -0
- package/src/commons/DevMode/TextWithLabel.js +30 -0
- package/src/commons/DevMode/index.js +5 -1
- package/src/commons/Device/DeviceAlertStatus.js +1 -1
- package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
- package/src/commons/Device/ItemAddNew/index.js +5 -1
- package/src/commons/Device/ItemDevice.js +12 -9
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -1
- package/src/commons/Device/WindDirection/Compass/index.js +1 -1
- package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
- package/src/commons/Header/HeaderCustom.js +8 -2
- package/src/commons/HeaderAni/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +14 -2
- package/src/commons/NavBar/index.js +13 -1
- package/src/commons/Popover/index.js +7 -6
- package/src/commons/Sharing/WrapHeaderScrollable.js +4 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -1
- package/src/commons/SubUnit/ShortDetail.js +1 -0
- package/src/commons/SummaryItem/index.js +2 -1
- package/src/commons/Unit/HeaderUnit/index.js +2 -0
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/WrapParallaxScrollView/index.js +16 -2
- package/src/configs/API.js +6 -0
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +16 -0
- package/src/configs/Images.js +3 -0
- package/src/context/actionType.ts +12 -0
- package/src/context/mockStore.ts +12 -0
- package/src/context/reducer.ts +43 -1
- package/src/hooks/Common/useDevicesStatus.js +1 -1
- package/src/hooks/IoT/useValueEvaluation.js +10 -19
- package/src/iot/RemoteControl/GoogleHome.js +6 -6
- package/src/navigations/Main.js +26 -2
- package/src/navigations/UnitStack.js +5 -8
- package/src/screens/AddNewAction/Device/index.js +5 -1
- package/src/screens/AddNewAction/SelectAction.js +36 -15
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +1 -0
- package/src/screens/AddNewAutoSmart/index.js +2 -0
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +13 -1
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +27 -0
- package/src/screens/Device/components/DetailHistoryChart.js +7 -5
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +10 -11
- package/src/screens/Device/components/SensorDisplayItem.js +49 -24
- package/src/screens/Device/detail.js +38 -17
- package/src/screens/Device/hooks/useFavoriteDevice.js +4 -2
- package/src/screens/Drawer/index.js +9 -4
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +4 -7
- package/src/screens/Notification/__test__/NotificationItem.test.js +74 -104
- package/src/screens/Notification/components/NotificationItem.js +40 -239
- package/src/screens/ScriptDetail/__test__/index.test.js +40 -1
- package/src/screens/ScriptDetail/index.js +2 -1
- package/src/screens/Sharing/Components/SensorItem.js +4 -1
- package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
- package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +4 -0
- package/src/screens/Sharing/Components/TitleCheckBox.js +17 -8
- package/src/screens/Template/EditTemplate.js +151 -0
- package/src/screens/Template/GatewayList.js +51 -0
- package/src/screens/Template/Information.js +41 -0
- package/src/screens/Template/Styles/EditTemplateStyle.js +109 -0
- package/src/screens/Template/Styles/GatewayStyles.js +46 -0
- package/src/screens/Template/Styles/InformationStyles.js +16 -0
- package/src/screens/Template/Styles/detailStyles.js +35 -0
- package/src/screens/Template/Styles/indexStyles.js +2 -33
- package/src/screens/Template/__test__/EditTemplate.test.js +89 -0
- package/src/screens/Template/__test__/GatewayList.test.js +26 -0
- package/src/screens/Template/__test__/Information.test.js +16 -0
- package/src/screens/Template/__test__/detail.test.js +60 -0
- package/src/screens/Template/__test__/index.test.js +26 -1
- package/src/screens/Template/detail.js +154 -0
- package/src/screens/Template/index.js +39 -32
- package/src/screens/Unit/Detail.js +11 -1
- package/src/screens/Unit/MoreMenu.js +16 -1
- package/src/screens/Unit/SelectAddToFavorites.js +11 -1
- package/src/screens/Unit/SmartAccount.js +1 -1
- package/src/screens/Unit/Station/__test__/index.test.js +18 -2
- package/src/screens/Unit/Station/index.js +0 -1
- package/src/screens/Unit/Summaries.js +6 -1
- package/src/screens/Unit/__test__/Detail.test.js +73 -43
- package/src/screens/Unit/__test__/SmartAccount.test.js +42 -25
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/utils/I18n/translations/en.json +37 -42
- package/src/utils/I18n/translations/vi.json +35 -44
- package/src/utils/Route/index.js +6 -0
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -88,6 +88,7 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus }) => {
|
|
|
88
88
|
return (
|
|
89
89
|
<TouchableOpacity
|
|
90
90
|
testID={TESTID.ITEM_QUICK_ACTION_PRESS}
|
|
91
|
+
accessibilityLabel={`${TESTID.ITEM_QUICK_ACTION_PRESS}-${sensor?.id}`}
|
|
91
92
|
onPress={onActionPress}
|
|
92
93
|
>
|
|
93
94
|
<View style={wrapperStyle}>
|
|
@@ -1,41 +1,55 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
memo,
|
|
3
|
+
useState,
|
|
4
|
+
useEffect,
|
|
5
|
+
useContext,
|
|
6
|
+
useCallback,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { View } from 'react-native';
|
|
3
9
|
import styles from './ColorPickerTemplateStyles';
|
|
4
10
|
import ColorPicker from 'react-native-wheel-color-picker';
|
|
5
11
|
import { useConfigGlobalState } from '../../iot/states';
|
|
12
|
+
import { SCContext } from '../../context';
|
|
13
|
+
import { Action } from '../../context/actionType';
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const WheelColorPicker = ({ valueColor, onChangeColor }) => {
|
|
15
|
+
const WheelColorPicker = ({ valueColor, onChangeColor, onStart }) => {
|
|
10
16
|
return (
|
|
11
17
|
<ColorPicker
|
|
12
18
|
style={styles.colorPicker}
|
|
13
19
|
sliderHidden={true}
|
|
14
20
|
swatches={false}
|
|
15
21
|
color={valueColor}
|
|
22
|
+
onInteractionStart={onStart}
|
|
16
23
|
onColorChangeComplete={onChangeColor}
|
|
17
24
|
thumbSize={16}
|
|
18
25
|
/>
|
|
19
26
|
);
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
let isFirstTime = true;
|
|
30
|
+
const ColorPickerTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
31
|
+
const { configuration = {} } = actionGroup;
|
|
24
32
|
const [valueColorComplete, setValueColorComplete] = useState('');
|
|
25
33
|
const [configValues] = useConfigGlobalState('configValues');
|
|
34
|
+
const { setAction } = useContext(SCContext);
|
|
26
35
|
|
|
27
|
-
const onChangeColor = (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const onChangeColor = useCallback(
|
|
37
|
+
(color) => {
|
|
38
|
+
setAction(Action.SET_LOCK_VIEW_PICK_COLOR, false);
|
|
39
|
+
const to = setTimeout(() => {
|
|
40
|
+
isFirstTime = false;
|
|
41
|
+
clearTimeout(to);
|
|
42
|
+
}, 1000);
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
!isFirstTime &&
|
|
45
|
+
doAction(
|
|
46
|
+
configuration?.action_color_data,
|
|
47
|
+
JSON.stringify({ value: color })
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
[configuration?.action_color_data, doAction]
|
|
52
|
+
);
|
|
39
53
|
|
|
40
54
|
useEffect(() => {
|
|
41
55
|
const { config } = configuration;
|
|
@@ -50,11 +64,16 @@ const ColorPickerTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
50
64
|
return () => (isFirstTime = true);
|
|
51
65
|
}, []);
|
|
52
66
|
|
|
67
|
+
const onStartPickColor = useCallback(() => {
|
|
68
|
+
setAction(Action.SET_LOCK_VIEW_PICK_COLOR, true);
|
|
69
|
+
}, [setAction]);
|
|
70
|
+
|
|
53
71
|
return (
|
|
54
72
|
<View style={styles.viewPickColor}>
|
|
55
73
|
<WheelColorPicker
|
|
56
74
|
valueColor={valueColorComplete}
|
|
57
75
|
onChangeColor={onChangeColor}
|
|
76
|
+
onStart={onStartPickColor}
|
|
58
77
|
/>
|
|
59
78
|
</View>
|
|
60
79
|
);
|
|
@@ -16,7 +16,6 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
16
16
|
action_on_data,
|
|
17
17
|
is_display_lock,
|
|
18
18
|
text1,
|
|
19
|
-
text2,
|
|
20
19
|
text3,
|
|
21
20
|
text_door_lock,
|
|
22
21
|
} = configuration || {};
|
|
@@ -56,7 +55,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
56
55
|
{
|
|
57
56
|
style: styles.buttonActionCurtainCenter,
|
|
58
57
|
icon: Images.buttonPauseCurtain,
|
|
59
|
-
text:
|
|
58
|
+
text: '',
|
|
60
59
|
onPress: onButtonStopPress,
|
|
61
60
|
testID: TESTID.BUTTON_TEMPLATE_2,
|
|
62
61
|
},
|
|
@@ -10,16 +10,21 @@ import styles from './NumberUpDownActionTemplateStyle';
|
|
|
10
10
|
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
11
11
|
import { DEVICE_TYPE, TESTID } from '../../configs/Constants';
|
|
12
12
|
|
|
13
|
-
const NumberUpDownActionTemplate = ({
|
|
14
|
-
|
|
13
|
+
const NumberUpDownActionTemplate = ({
|
|
14
|
+
actionGroup = {},
|
|
15
|
+
doAction,
|
|
16
|
+
sensor = {},
|
|
17
|
+
}) => {
|
|
18
|
+
const { configuration = {}, title } = actionGroup;
|
|
15
19
|
const {
|
|
16
20
|
action_data,
|
|
17
21
|
max_value,
|
|
18
22
|
min_value,
|
|
19
|
-
text_format,
|
|
23
|
+
text_format = '',
|
|
20
24
|
config,
|
|
21
25
|
allow_config_store_value,
|
|
22
26
|
} = configuration;
|
|
27
|
+
const { device_type, is_managed_by_backend } = sensor;
|
|
23
28
|
|
|
24
29
|
// eslint-disable-next-line no-unused-vars
|
|
25
30
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
@@ -41,7 +46,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
41
46
|
const doActionAndWatchConfig = useCallback(
|
|
42
47
|
async (actionData, actionValue) => {
|
|
43
48
|
let data = actionValue;
|
|
44
|
-
if (
|
|
49
|
+
if (device_type !== DEVICE_TYPE.GOOGLE_HOME) {
|
|
45
50
|
data = { temperature: actionValue };
|
|
46
51
|
if (allow_config_store_value && config) {
|
|
47
52
|
data.config_id = config;
|
|
@@ -50,7 +55,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
50
55
|
data = JSON.stringify(data);
|
|
51
56
|
}
|
|
52
57
|
await doAction(actionData, data);
|
|
53
|
-
if (!
|
|
58
|
+
if (!is_managed_by_backend) {
|
|
54
59
|
return;
|
|
55
60
|
}
|
|
56
61
|
if (!config) {
|
|
@@ -58,13 +63,13 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
config &&
|
|
61
|
-
|
|
66
|
+
device_type === DEVICE_TYPE.LG_THINQ &&
|
|
62
67
|
watchMultiConfigs([config]);
|
|
63
68
|
},
|
|
64
69
|
[
|
|
65
70
|
doAction,
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
is_managed_by_backend,
|
|
72
|
+
device_type,
|
|
68
73
|
allow_config_store_value,
|
|
69
74
|
config,
|
|
70
75
|
]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
4
|
-
import { Section } from '../../Section';
|
|
5
4
|
import Text from '../../Text';
|
|
6
5
|
import styles from './OnOffSmartLockStyle';
|
|
7
6
|
import ButtonLock from '../../../../assets/images/Device/button-lock.svg';
|
|
@@ -11,10 +10,12 @@ import { useUnwatchLGDeviceConfigControl } from '../../../hooks/IoT';
|
|
|
11
10
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
12
11
|
import { DEVICE_TYPE, TESTID } from '../../../configs/Constants';
|
|
13
12
|
|
|
14
|
-
const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
|
|
13
|
+
const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
15
14
|
const t = useTranslations();
|
|
16
|
-
const { configuration } = actionGroup;
|
|
17
|
-
const { action_on_data, action_off_data } =
|
|
15
|
+
const { configuration = {} } = actionGroup;
|
|
16
|
+
const { action_on_data, action_off_data, config, is_on_value } =
|
|
17
|
+
configuration;
|
|
18
|
+
const { is_managed_by_backend, device_type } = sensor;
|
|
18
19
|
const [isUnlock, setisUnlock] = useState(true);
|
|
19
20
|
const [configValues] = useConfigGlobalState('configValues');
|
|
20
21
|
|
|
@@ -27,10 +28,10 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
27
28
|
const dataUnlock = { door_lock: 1 };
|
|
28
29
|
await doAction(action_off_data, JSON.stringify(dataUnlock));
|
|
29
30
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
watchMultiConfigs([
|
|
31
|
+
if (is_managed_by_backend) {
|
|
32
|
+
config &&
|
|
33
|
+
device_type === DEVICE_TYPE.LG_THINQ &&
|
|
34
|
+
watchMultiConfigs([config]);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
}, [
|
|
@@ -38,54 +39,46 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
38
39
|
action_on_data,
|
|
39
40
|
doAction,
|
|
40
41
|
isUnlock,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
config,
|
|
43
|
+
is_managed_by_backend,
|
|
44
|
+
device_type,
|
|
44
45
|
]);
|
|
45
46
|
|
|
46
|
-
useUnwatchLGDeviceConfigControl(sensor, [
|
|
47
|
+
useUnwatchLGDeviceConfigControl(sensor, [config]);
|
|
47
48
|
|
|
48
49
|
useEffect(() => {
|
|
49
|
-
const { is_on_value, config } = configuration;
|
|
50
50
|
const configValue = configValues[config];
|
|
51
51
|
if (is_on_value && is_on_value.length) {
|
|
52
52
|
setisUnlock(is_on_value.includes(configValue?.value));
|
|
53
53
|
} else {
|
|
54
54
|
setisUnlock(configValue?.value);
|
|
55
55
|
}
|
|
56
|
-
}, [configValues, configuration]);
|
|
56
|
+
}, [config, configValues, configuration, is_on_value]);
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
|
|
60
|
-
<View
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)}
|
|
76
|
-
<Text style={styles.textSmartLock}>
|
|
77
|
-
{t(isUnlock ? 'lock' : 'unlock')}
|
|
78
|
-
</Text>
|
|
79
|
-
</TouchableOpacity>
|
|
80
|
-
</View>
|
|
81
|
-
<View style={styles.wrapStatus}>
|
|
82
|
-
<Text style={styles.textStatus}>
|
|
83
|
-
{t(isUnlock ? 'door_is_open' : 'door_is_close')}
|
|
84
|
-
</Text>
|
|
85
|
-
</View>
|
|
86
|
-
</Section>
|
|
59
|
+
<>
|
|
60
|
+
<View>
|
|
61
|
+
<TouchableOpacity
|
|
62
|
+
onPress={handleActionSmartLock}
|
|
63
|
+
testID={TESTID.BUTTON_ON_OFF}
|
|
64
|
+
style={styles.wrapButtonSmartLock}
|
|
65
|
+
>
|
|
66
|
+
{isUnlock ? (
|
|
67
|
+
<ButtonLock style={styles.buttonSmartLock} />
|
|
68
|
+
) : (
|
|
69
|
+
<ButtonUnLock style={styles.buttonSmartLock} />
|
|
70
|
+
)}
|
|
71
|
+
<Text style={styles.textSmartLock}>
|
|
72
|
+
{t(isUnlock ? 'lock' : 'unlock')}
|
|
73
|
+
</Text>
|
|
74
|
+
</TouchableOpacity>
|
|
87
75
|
</View>
|
|
88
|
-
|
|
76
|
+
<View style={styles.wrapStatus}>
|
|
77
|
+
<Text style={styles.textStatus}>
|
|
78
|
+
{t(isUnlock ? 'door_is_open' : 'door_is_close')}
|
|
79
|
+
</Text>
|
|
80
|
+
</View>
|
|
81
|
+
</>
|
|
89
82
|
);
|
|
90
83
|
});
|
|
91
84
|
|
|
@@ -8,8 +8,9 @@ import styles from './OnOffButtonTemplateStyle';
|
|
|
8
8
|
import { TESTID } from '../../../configs/Constants';
|
|
9
9
|
|
|
10
10
|
const OnOffButtonTemplate = memo(
|
|
11
|
-
({ isOn, triggerAction, actionGroup, isLight = false }) => {
|
|
12
|
-
const { configuration, id } = actionGroup;
|
|
11
|
+
({ isOn, triggerAction, actionGroup = {}, isLight = false }) => {
|
|
12
|
+
const { configuration = {}, id } = actionGroup;
|
|
13
|
+
const { icon_on, icon_off, text_on, text_off } = configuration;
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<>
|
|
@@ -18,10 +19,11 @@ const OnOffButtonTemplate = memo(
|
|
|
18
19
|
style={styles.bigCircle}
|
|
19
20
|
onPress={triggerAction}
|
|
20
21
|
testID={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
22
|
+
accessibilityLabel={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
21
23
|
>
|
|
22
24
|
<View style={styles.smallCircle}>
|
|
23
25
|
<Icon
|
|
24
|
-
name={isOn ?
|
|
26
|
+
name={isOn ? icon_on : icon_off}
|
|
25
27
|
size={44}
|
|
26
28
|
color={isOn ? Colors.Green7 : Colors.Gray6}
|
|
27
29
|
/>
|
|
@@ -31,8 +33,9 @@ const OnOffButtonTemplate = memo(
|
|
|
31
33
|
{ color: isOn ? Colors.Gray8 : Colors.Gray6 },
|
|
32
34
|
]}
|
|
33
35
|
testID={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
36
|
+
accessibilityLabel={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
34
37
|
>
|
|
35
|
-
{isOn ?
|
|
38
|
+
{isOn ? text_on : text_off}
|
|
36
39
|
</Text>
|
|
37
40
|
</View>
|
|
38
41
|
</TouchableOpacity>
|
|
@@ -20,8 +20,8 @@ const getComponent = (template) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
24
|
-
const { configuration } = actionGroup;
|
|
23
|
+
const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
24
|
+
const { configuration = {} } = actionGroup;
|
|
25
25
|
const { action_data, action_on_data, action_off_data } = configuration;
|
|
26
26
|
|
|
27
27
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -6,9 +6,9 @@ import Text from '../Text';
|
|
|
6
6
|
import { Colors } from '../../configs';
|
|
7
7
|
import styles from './OneBigButtonTemplateStyle';
|
|
8
8
|
|
|
9
|
-
const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
10
|
-
const { configuration } = actionGroup;
|
|
11
|
-
const { text, action_data } = configuration
|
|
9
|
+
const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
10
|
+
const { configuration = {} } = actionGroup;
|
|
11
|
+
const { text, action_data, icon } = configuration;
|
|
12
12
|
|
|
13
13
|
const onPressDoAction = useCallback(() => {
|
|
14
14
|
doAction(action_data, null);
|
|
@@ -19,7 +19,7 @@ const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
19
19
|
<View style={styles.barrierControlContainer}>
|
|
20
20
|
<TouchableOpacity style={styles.bigCircle} onPress={onPressDoAction}>
|
|
21
21
|
<View style={styles.smallCircle}>
|
|
22
|
-
<Icon name={
|
|
22
|
+
<Icon name={icon} size={44} color={Colors.Green7} />
|
|
23
23
|
<Text style={styles.textBig}>{text}</Text>
|
|
24
24
|
</View>
|
|
25
25
|
</TouchableOpacity>
|
|
@@ -24,38 +24,48 @@ function getOptionValue(option) {
|
|
|
24
24
|
return option.value_int;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const OptionsDropdownActionTemplate = ({
|
|
27
|
+
const OptionsDropdownActionTemplate = ({
|
|
28
|
+
actionGroup = {},
|
|
29
|
+
doAction,
|
|
30
|
+
sensor = {},
|
|
31
|
+
}) => {
|
|
28
32
|
const t = useTranslations();
|
|
29
|
-
const { configuration, title } = actionGroup;
|
|
30
|
-
const {
|
|
31
|
-
|
|
33
|
+
const { configuration = {}, title } = actionGroup;
|
|
34
|
+
const {
|
|
35
|
+
action_data,
|
|
36
|
+
options = [],
|
|
37
|
+
icon_kit_data,
|
|
38
|
+
icon,
|
|
39
|
+
icon_outlined,
|
|
40
|
+
config,
|
|
41
|
+
} = configuration;
|
|
32
42
|
// eslint-disable-next-line no-unused-vars
|
|
33
43
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
34
44
|
const checkIcon = /\d/.test(icon); // to do check icon svg and icon antDesign
|
|
35
45
|
const selectedOption = useMemo(() => {
|
|
36
|
-
const currentValue = configValues[
|
|
46
|
+
const currentValue = configValues[config]?.value;
|
|
37
47
|
if (currentValue === null || currentValue === undefined) {
|
|
38
|
-
return
|
|
48
|
+
return options[0];
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
for (let i = 0; i <
|
|
42
|
-
const option =
|
|
51
|
+
for (let i = 0; i < options.length; i++) {
|
|
52
|
+
const option = options[i];
|
|
43
53
|
const value = getOptionValue(option);
|
|
44
54
|
if (value === currentValue) {
|
|
45
55
|
return option;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
|
-
return
|
|
49
|
-
}, [configValues,
|
|
58
|
+
return options[0];
|
|
59
|
+
}, [configValues, config, options]);
|
|
50
60
|
|
|
51
61
|
const { stateAlert, hideAlertAction, onShowAlert } = useDropdownAction();
|
|
52
62
|
const [selectedIndex, setSelectedIndex] = useState(
|
|
53
|
-
|
|
63
|
+
options.indexOf(selectedOption)
|
|
54
64
|
);
|
|
55
65
|
|
|
56
66
|
useEffect(() => {
|
|
57
|
-
setSelectedIndex(
|
|
58
|
-
}, [
|
|
67
|
+
setSelectedIndex(options.indexOf(selectedOption));
|
|
68
|
+
}, [options, selectedOption]);
|
|
59
69
|
|
|
60
70
|
const onDone = useCallback(() => {
|
|
61
71
|
const newOption = options[selectedIndex];
|
|
@@ -68,14 +78,14 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
68
78
|
|
|
69
79
|
doAction(action_data, data);
|
|
70
80
|
if (sensor?.is_managed_by_backend) {
|
|
71
|
-
|
|
81
|
+
config &&
|
|
72
82
|
sensor.device_type === DEVICE_TYPE.LG_THINQ &&
|
|
73
|
-
watchMultiConfigs([
|
|
83
|
+
watchMultiConfigs([config]);
|
|
74
84
|
}
|
|
75
85
|
hideAlertAction();
|
|
76
86
|
}, [
|
|
77
87
|
action_data,
|
|
78
|
-
|
|
88
|
+
config,
|
|
79
89
|
doAction,
|
|
80
90
|
hideAlertAction,
|
|
81
91
|
options,
|
|
@@ -89,11 +99,11 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
89
99
|
const iconKit = !!icon_kit_data && icon_kit_data.icon;
|
|
90
100
|
|
|
91
101
|
const displaySelected = useMemo(() => {
|
|
92
|
-
if (!
|
|
102
|
+
if (!config) {
|
|
93
103
|
return t('not_available');
|
|
94
104
|
}
|
|
95
105
|
return selectedOption.text;
|
|
96
|
-
}, [
|
|
106
|
+
}, [config, selectedOption?.text, t]);
|
|
97
107
|
|
|
98
108
|
const iconSvg = useMemo(() => {
|
|
99
109
|
switch (icon) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useCallback, useState,
|
|
1
|
+
import React, { memo, useCallback, useState, useEffect } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
4
|
import styles from './SliderRangeTemplateStyles';
|
|
@@ -8,35 +8,43 @@ import SvgBrightness from '../../../assets/images/brightness.svg';
|
|
|
8
8
|
import SliderRange from 'react-native-slider';
|
|
9
9
|
import { useConfigGlobalState } from '../../iot/states';
|
|
10
10
|
|
|
11
|
-
const SliderRangeTemplate = memo(({ actionGroup, doAction
|
|
11
|
+
const SliderRangeTemplate = memo(({ actionGroup = {}, doAction }) => {
|
|
12
12
|
const t = useTranslations();
|
|
13
|
-
const { configuration } = actionGroup;
|
|
13
|
+
const { configuration = {} } = actionGroup;
|
|
14
14
|
const [valueBrightness, setValueBrightness] = useState(0);
|
|
15
15
|
const [valueBrightnessTemp, setValueBrightnessTemp] = useState(0);
|
|
16
|
+
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
17
|
+
|
|
16
18
|
const [configValues] = useConfigGlobalState('configValues');
|
|
17
19
|
|
|
18
20
|
const onChangeBrightness = useCallback(
|
|
19
|
-
(value) => {
|
|
20
|
-
doAction(
|
|
21
|
+
async (value) => {
|
|
22
|
+
await doAction(
|
|
21
23
|
configuration?.action_brightness_data,
|
|
22
24
|
JSON.stringify({ value_brness: value })
|
|
23
25
|
);
|
|
26
|
+
await setValueBrightness(value);
|
|
27
|
+
await setValueBrightnessTemp(value);
|
|
24
28
|
},
|
|
25
29
|
[configuration?.action_brightness_data, doAction]
|
|
26
30
|
);
|
|
27
31
|
|
|
28
|
-
const percentBrightness = useMemo(() => {
|
|
29
|
-
return valueBrightnessTemp || valueBrightness || 0;
|
|
30
|
-
}, [valueBrightness, valueBrightnessTemp]);
|
|
31
|
-
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
const { config } = configuration;
|
|
34
34
|
const configValue = configValues[config];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (configValue?.value >= 0 && isFirstTime) {
|
|
36
|
+
setValueBrightness(configValue?.value);
|
|
37
|
+
setIsFirstTime(false);
|
|
38
|
+
} else if (configValue?.value === valueBrightnessTemp) {
|
|
39
|
+
setValueBrightness(valueBrightnessTemp);
|
|
38
40
|
}
|
|
39
|
-
}, [
|
|
41
|
+
}, [
|
|
42
|
+
configuration.config,
|
|
43
|
+
configValues,
|
|
44
|
+
configuration,
|
|
45
|
+
isFirstTime,
|
|
46
|
+
valueBrightnessTemp,
|
|
47
|
+
]);
|
|
40
48
|
|
|
41
49
|
return (
|
|
42
50
|
<View style={styles.viewBrightness}>
|
|
@@ -49,9 +57,9 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
49
57
|
<View style={styles.RightBrightness}>
|
|
50
58
|
<View style={styles.slider}>
|
|
51
59
|
<SliderRange
|
|
52
|
-
value={
|
|
60
|
+
value={valueBrightness}
|
|
53
61
|
onSlidingComplete={onChangeBrightness}
|
|
54
|
-
onValueChange={
|
|
62
|
+
onValueChange={setValueBrightness}
|
|
55
63
|
step={1}
|
|
56
64
|
minimumValue={0}
|
|
57
65
|
maximumValue={100}
|
|
@@ -64,7 +72,7 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
64
72
|
</View>
|
|
65
73
|
<View style={styles.valuePercent}>
|
|
66
74
|
<Text type="Label" style={styles.textValuePercent}>
|
|
67
|
-
{`${
|
|
75
|
+
{`${valueBrightness}%`}
|
|
68
76
|
</Text>
|
|
69
77
|
</View>
|
|
70
78
|
</View>
|