@eohjsc/react-native-smart-city 0.3.30 → 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/ActionGroup/ColorPickerTemplate.js +36 -17
- 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 +5 -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 +2 -2
- 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/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/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/MenuActionMore/index.js +3 -1
- package/src/commons/Sharing/WrapHeaderScrollable.js +4 -2
- package/src/configs/API.js +6 -0
- package/src/configs/Colors.js +4 -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/navigations/Main.js +26 -2
- 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/SensorDisplayItem.js +49 -24
- package/src/screens/Device/detail.js +3 -1
- package/src/screens/Drawer/index.js +9 -4
- 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/SmartAccount.js +1 -1
- package/src/screens/Unit/Station/__test__/index.test.js +18 -2
- package/src/screens/Unit/__test__/Detail.test.js +73 -43
- package/src/screens/Unit/__test__/SmartAccount.test.js +42 -25
- package/src/utils/I18n/translations/en.json +11 -1
- package/src/utils/I18n/translations/vi.json +9 -1
- 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
|
|
@@ -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
|
);
|
|
@@ -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
|
<>
|
|
@@ -22,7 +23,7 @@ const OnOffButtonTemplate = memo(
|
|
|
22
23
|
>
|
|
23
24
|
<View style={styles.smallCircle}>
|
|
24
25
|
<Icon
|
|
25
|
-
name={isOn ?
|
|
26
|
+
name={isOn ? icon_on : icon_off}
|
|
26
27
|
size={44}
|
|
27
28
|
color={isOn ? Colors.Green7 : Colors.Gray6}
|
|
28
29
|
/>
|
|
@@ -34,7 +35,7 @@ const OnOffButtonTemplate = memo(
|
|
|
34
35
|
testID={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
35
36
|
accessibilityLabel={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
36
37
|
>
|
|
37
|
-
{isOn ?
|
|
38
|
+
{isOn ? text_on : text_off}
|
|
38
39
|
</Text>
|
|
39
40
|
</View>
|
|
40
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) {
|
|
@@ -8,9 +8,9 @@ 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
16
|
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, View, Switch } from 'react-native';
|
|
3
3
|
import { Icon } from '@ant-design/react-native';
|
|
4
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
4
|
import styles from './ThreeButtonTemplateStyle';
|
|
6
5
|
import Text from '../Text';
|
|
7
6
|
import { TESTID } from '../../configs/Constants';
|
|
8
7
|
import { Colors } from '../../configs';
|
|
9
|
-
import { Card } from '../../commons/CardShadow';
|
|
10
8
|
|
|
11
|
-
const ThreeButtonTemplate = memo(({ actionGroup, doAction
|
|
12
|
-
const t = useTranslations();
|
|
9
|
+
const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
13
10
|
const { configuration } = actionGroup;
|
|
14
11
|
const {
|
|
15
12
|
text1,
|
|
@@ -20,7 +17,12 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
20
17
|
action3_data,
|
|
21
18
|
action_off_data,
|
|
22
19
|
action_on_data,
|
|
23
|
-
|
|
20
|
+
icon1,
|
|
21
|
+
icon2,
|
|
22
|
+
icon3,
|
|
23
|
+
text_door_lock,
|
|
24
|
+
is_display_lock,
|
|
25
|
+
} = configuration || {};
|
|
24
26
|
const [lock, setLock] = useState(false);
|
|
25
27
|
const iconCustom = (icon) => {
|
|
26
28
|
return icon === 'stop' ? (
|
|
@@ -60,7 +62,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
60
62
|
style={styles.textLockDoor}
|
|
61
63
|
testID={TESTID.TEXT_DOOR_LOOK_ON_OFF}
|
|
62
64
|
>
|
|
63
|
-
{
|
|
65
|
+
{`${text_door_lock} `}
|
|
64
66
|
</Text>
|
|
65
67
|
</View>
|
|
66
68
|
<Switch
|
|
@@ -75,60 +77,48 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
75
77
|
};
|
|
76
78
|
return (
|
|
77
79
|
<>
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
color={Colors.Primary}
|
|
91
|
-
/>
|
|
92
|
-
</View>
|
|
93
|
-
<Text style={styles.text}>{text1}</Text>
|
|
94
|
-
</TouchableOpacity>
|
|
80
|
+
<View style={styles.wrap}>
|
|
81
|
+
<TouchableOpacity
|
|
82
|
+
testID={TESTID.BUTTON_TEMPLATE_1}
|
|
83
|
+
style={styles.buttonActionDoor}
|
|
84
|
+
onPress={onButton1Press}
|
|
85
|
+
underlayColor={Colors.Gray2}
|
|
86
|
+
>
|
|
87
|
+
<View style={styles.imageButton}>
|
|
88
|
+
<Icon name={icon1} size={30} color={Colors.Primary} />
|
|
89
|
+
</View>
|
|
90
|
+
<Text style={styles.text}>{text1}</Text>
|
|
91
|
+
</TouchableOpacity>
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<Text style={styles.text}>{text2}</Text>
|
|
106
|
-
</TouchableOpacity>
|
|
93
|
+
<TouchableOpacity
|
|
94
|
+
testID={TESTID.BUTTON_TEMPLATE_2}
|
|
95
|
+
style={styles.buttonActionDoor}
|
|
96
|
+
onPress={onButton2Press}
|
|
97
|
+
underlayColor={Colors.Gray2}
|
|
98
|
+
>
|
|
99
|
+
<View style={styles.imageButton}>{iconCustom(icon2)}</View>
|
|
100
|
+
<Text style={styles.text}>{text2}</Text>
|
|
101
|
+
</TouchableOpacity>
|
|
107
102
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
lock ? 'lock' : 'unlock',
|
|
128
|
-
lock ? Colors.Primary : Colors.Gray6
|
|
129
|
-
)}
|
|
130
|
-
</View>
|
|
131
|
-
</Card>
|
|
103
|
+
<TouchableOpacity
|
|
104
|
+
testID={TESTID.BUTTON_TEMPLATE_3}
|
|
105
|
+
style={styles.buttonActionDoor}
|
|
106
|
+
onPress={onButton3Press}
|
|
107
|
+
underlayColor={Colors.Gray2}
|
|
108
|
+
>
|
|
109
|
+
<View style={styles.imageButton}>
|
|
110
|
+
<Icon name={icon3} size={30} color={Colors.Primary} />
|
|
111
|
+
</View>
|
|
112
|
+
<Text style={styles.text}>{text3}</Text>
|
|
113
|
+
</TouchableOpacity>
|
|
114
|
+
</View>
|
|
115
|
+
<View style={styles.lockSwitch}>
|
|
116
|
+
{is_display_lock &&
|
|
117
|
+
itemLock(
|
|
118
|
+
lock ? 'lock' : 'unlock',
|
|
119
|
+
lock ? Colors.Primary : Colors.Gray6
|
|
120
|
+
)}
|
|
121
|
+
</View>
|
|
132
122
|
</>
|
|
133
123
|
);
|
|
134
124
|
});
|