@eohjsc/react-native-smart-city 0.3.27 → 0.3.30
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 +2 -0
- package/package.json +1 -1
- package/src/Images/Common/device_icon.png +0 -0
- package/src/Images/DevMode/gateway.png +0 -0
- package/src/Images/DevMode/gateway@2x.png +0 -0
- package/src/Images/DevMode/gateway@3x.png +0 -0
- package/src/Images/DevMode/menu.png +0 -0
- package/src/Images/DevMode/menu@2x.png +0 -0
- package/src/Images/DevMode/menu@3x.png +0 -0
- package/src/Images/DevMode/search.png +0 -0
- package/src/Images/DevMode/search@2x.png +0 -0
- package/src/Images/DevMode/search@3x.png +0 -0
- package/src/Images/DevMode/smart.png +0 -0
- package/src/Images/DevMode/smart@2x.png +0 -0
- package/src/Images/DevMode/smart@3x.png +0 -0
- package/src/Images/DevMode/template.png +0 -0
- package/src/Images/DevMode/template@2x.png +0 -0
- package/src/Images/DevMode/template@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -0
- package/src/commons/ActionGroup/SliderRangeTemplate.js +22 -14
- 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/CameraDevice/index.js +1 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +20 -12
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +2 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +1 -1
- package/src/commons/ConnectingProcess/index.js +11 -0
- package/src/commons/Dashboard/MyUnit/index.js +1 -1
- package/src/commons/DevMode/Label.js +10 -0
- package/src/commons/DevMode/Search.js +20 -0
- package/src/commons/DevMode/Styles/LabelStyles.js +8 -0
- package/src/commons/DevMode/Styles/SearchStyles.js +21 -0
- package/src/commons/DevMode/index.js +3 -0
- package/src/commons/Device/ItemAddNew/index.js +5 -1
- package/src/commons/Device/ItemDevice.js +12 -9
- package/src/commons/Form/TextInput.js +4 -0
- package/src/commons/HeaderAni/index.js +1 -0
- package/src/commons/MediaPlayerDetail/index.js +0 -20
- package/src/commons/MenuActionMore/index.js +11 -1
- package/src/commons/Modal/index.js +1 -2
- package/src/commons/NavBar/index.js +13 -1
- package/src/commons/Popover/index.js +7 -6
- 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/Tabbar/Styles/indexStyles.js +51 -0
- package/src/commons/Tabbar/index.js +110 -0
- 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/Colors.js +4 -0
- package/src/configs/Constants.js +16 -0
- package/src/configs/Images.js +6 -0
- 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/GatewayStack.js +23 -0
- package/src/navigations/Main.js +144 -0
- package/src/navigations/SmartStack.js +23 -0
- package/src/navigations/TemplateStack.js +23 -0
- 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/AllCamera/__test__/index.test.js +1 -8
- package/src/screens/AllCamera/index.js +0 -13
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +10 -11
- package/src/screens/Device/detail.js +35 -16
- package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +37 -0
- package/src/screens/Device/hooks/useFavoriteDevice.js +4 -2
- package/src/screens/Drawer/Drawer.test.js +24 -0
- package/src/screens/Drawer/index.js +198 -0
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +4 -7
- package/src/screens/Gateway/__test__/index.test.js +16 -0
- package/src/screens/Gateway/index.js +8 -0
- 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/Smart/__test__/index.test.js +16 -0
- package/src/screens/Smart/index.js +8 -0
- package/src/screens/SubUnit/AddSubUnit.js +1 -1
- package/src/screens/SubUnit/EditSubUnit.js +4 -1
- package/src/screens/Template/Styles/indexStyles.js +51 -0
- package/src/screens/Template/__test__/index.test.js +16 -0
- package/src/screens/Template/index.js +84 -0
- package/src/screens/Unit/Detail.js +16 -28
- package/src/screens/Unit/MoreMenu.js +16 -1
- package/src/screens/Unit/SelectAddToFavorites.js +11 -1
- package/src/screens/Unit/Station/__test__/index.test.js +41 -0
- 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 +1 -5
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/utils/Converter/__test__/timer.test.js +99 -0
- package/src/utils/Functions/Search.js +17 -0
- package/src/utils/Functions/ShortEmail.js +4 -0
- package/src/utils/Functions/__test__/Search.test.js +6 -0
- package/src/utils/Functions/__test__/ShortEmail.test.js +6 -0
- package/src/utils/I18n/translations/en.json +37 -42
- package/src/utils/I18n/translations/vi.json +37 -44
- package/src/utils/Route/index.js +6 -0
- package/src/commons/Modal/ModalFullVideo.js +0 -48
- package/src/commons/Modal/Styles/ModalFullVideoStyles.js +0 -26
package/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import MyUnit from './src/commons/Dashboard/MyUnit';
|
|
|
19
19
|
import SharedUnit from './src/commons/Unit/SharedUnit';
|
|
20
20
|
import { Action } from './src/context/actionType';
|
|
21
21
|
import { withRemoteControl } from './src/hoc';
|
|
22
|
+
import DevModeStack from './src/navigations/Main';
|
|
22
23
|
|
|
23
24
|
export {
|
|
24
25
|
AddSubUnitStack,
|
|
@@ -44,4 +45,5 @@ export {
|
|
|
44
45
|
SCWrapper,
|
|
45
46
|
Action,
|
|
46
47
|
withRemoteControl,
|
|
48
|
+
DevModeStack,
|
|
47
49
|
};
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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}>
|
|
@@ -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
|
},
|
|
@@ -18,6 +18,7 @@ const OnOffButtonTemplate = memo(
|
|
|
18
18
|
style={styles.bigCircle}
|
|
19
19
|
onPress={triggerAction}
|
|
20
20
|
testID={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
21
|
+
accessibilityLabel={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
21
22
|
>
|
|
22
23
|
<View style={styles.smallCircle}>
|
|
23
24
|
<Icon
|
|
@@ -31,6 +32,7 @@ const OnOffButtonTemplate = memo(
|
|
|
31
32
|
{ color: isOn ? Colors.Gray8 : Colors.Gray6 },
|
|
32
33
|
]}
|
|
33
34
|
testID={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
35
|
+
accessibilityLabel={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
34
36
|
>
|
|
35
37
|
{isOn ? configuration.text_on : configuration.text_off}
|
|
36
38
|
</Text>
|
|
@@ -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';
|
|
@@ -13,30 +13,38 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
13
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>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import styles from './CurtainActionStyles';
|
|
5
|
+
|
|
6
|
+
const CurtainAction = ({ configuration, onPress, template }) => {
|
|
7
|
+
const { open_action, close_action, stop_action, text1, text2, text3 } =
|
|
8
|
+
configuration || {};
|
|
9
|
+
|
|
10
|
+
const onPressActionClose = useCallback(() => {
|
|
11
|
+
onPress &&
|
|
12
|
+
onPress({
|
|
13
|
+
name: text1,
|
|
14
|
+
action: close_action,
|
|
15
|
+
template,
|
|
16
|
+
});
|
|
17
|
+
}, [onPress, text1, close_action, template]);
|
|
18
|
+
|
|
19
|
+
const onPressActionStop = useCallback(() => {
|
|
20
|
+
onPress &&
|
|
21
|
+
onPress({
|
|
22
|
+
name: text2,
|
|
23
|
+
action: stop_action,
|
|
24
|
+
template,
|
|
25
|
+
});
|
|
26
|
+
}, [onPress, text2, stop_action, template]);
|
|
27
|
+
|
|
28
|
+
const onPressActionOpen = useCallback(() => {
|
|
29
|
+
onPress &&
|
|
30
|
+
onPress({
|
|
31
|
+
name: text3,
|
|
32
|
+
action: open_action,
|
|
33
|
+
template,
|
|
34
|
+
});
|
|
35
|
+
}, [onPress, text3, open_action, template]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<TouchableOpacity onPress={onPressActionClose}>
|
|
40
|
+
<Text type="H4" style={styles.textwithline}>
|
|
41
|
+
{text1}
|
|
42
|
+
</Text>
|
|
43
|
+
</TouchableOpacity>
|
|
44
|
+
|
|
45
|
+
<TouchableOpacity onPress={onPressActionStop}>
|
|
46
|
+
<Text type="H4" style={styles.textwithline}>
|
|
47
|
+
{text2}
|
|
48
|
+
</Text>
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
|
|
51
|
+
<TouchableOpacity onPress={onPressActionOpen}>
|
|
52
|
+
<Text type="H4" style={styles.textwithline}>
|
|
53
|
+
{text3}
|
|
54
|
+
</Text>
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default memo(CurtainAction);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import styles from './OnOffSmartLockActionStyles';
|
|
5
|
+
|
|
6
|
+
const OnOffSmartLockAction = ({ configuration, onPress, template }) => {
|
|
7
|
+
const { action_off, action_on, text_off, text_on } = configuration || {};
|
|
8
|
+
|
|
9
|
+
const onPressActionClose = useCallback(() => {
|
|
10
|
+
onPress &&
|
|
11
|
+
onPress({
|
|
12
|
+
name: text_off,
|
|
13
|
+
action: action_off,
|
|
14
|
+
template,
|
|
15
|
+
});
|
|
16
|
+
}, [onPress, text_off, action_off, template]);
|
|
17
|
+
|
|
18
|
+
const onPressActionOpen = useCallback(() => {
|
|
19
|
+
onPress &&
|
|
20
|
+
onPress({
|
|
21
|
+
name: text_on,
|
|
22
|
+
action: action_on,
|
|
23
|
+
template,
|
|
24
|
+
});
|
|
25
|
+
}, [onPress, text_on, action_on, template]);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<TouchableOpacity onPress={onPressActionClose}>
|
|
30
|
+
<Text type="H4" style={styles.textwithline}>
|
|
31
|
+
{text_off}
|
|
32
|
+
</Text>
|
|
33
|
+
</TouchableOpacity>
|
|
34
|
+
|
|
35
|
+
<TouchableOpacity onPress={onPressActionOpen}>
|
|
36
|
+
<Text type="H4" style={styles.textwithline}>
|
|
37
|
+
{text_on}
|
|
38
|
+
</Text>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default memo(OnOffSmartLockAction);
|
|
@@ -9,6 +9,8 @@ import ThreeButtonAction from './ThreeButtonAction';
|
|
|
9
9
|
import OnOffSimpleAction from './OnOffSimpleAction';
|
|
10
10
|
import SelectActionCard from '../SelectActionCard';
|
|
11
11
|
import { ModalCustom } from '../Modal';
|
|
12
|
+
import CurtainAction from './CurtainAction';
|
|
13
|
+
import OnOffSmartLockAction from './OnOffSmartLockAction';
|
|
12
14
|
|
|
13
15
|
const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
14
16
|
const t = useTranslations();
|
|
@@ -66,6 +68,22 @@ const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
66
68
|
key={index}
|
|
67
69
|
/>
|
|
68
70
|
);
|
|
71
|
+
case 'curtain_action_template':
|
|
72
|
+
return (
|
|
73
|
+
<CurtainAction
|
|
74
|
+
{...item}
|
|
75
|
+
onPress={onPressSelectAction}
|
|
76
|
+
key={index}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
case 'OnOffSmartLockActionTemplate':
|
|
80
|
+
return (
|
|
81
|
+
<OnOffSmartLockAction
|
|
82
|
+
{...item}
|
|
83
|
+
onPress={onPressSelectAction}
|
|
84
|
+
key={index}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
69
87
|
}
|
|
70
88
|
});
|
|
71
89
|
}, [data, onPressSelectAction]);
|
|
@@ -133,6 +133,7 @@ export default ({
|
|
|
133
133
|
textSemiBold = true,
|
|
134
134
|
style,
|
|
135
135
|
testID,
|
|
136
|
+
accessibilityLabel,
|
|
136
137
|
}) => {
|
|
137
138
|
const styleButton = ButtonStyle[type];
|
|
138
139
|
const textColor = TextColor[type];
|
|
@@ -158,6 +159,7 @@ export default ({
|
|
|
158
159
|
onPress={onPress}
|
|
159
160
|
disabled={isDisabled}
|
|
160
161
|
activeOpacity={activeOpacity}
|
|
162
|
+
accessibilityLabel={accessibilityLabel}
|
|
161
163
|
>
|
|
162
164
|
<View style={styles.wrap}>
|
|
163
165
|
{icon}
|
|
@@ -17,7 +17,7 @@ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
|
|
|
17
17
|
Device.screenWidth - 32
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
const CameraDevice = ({ station,
|
|
20
|
+
const CameraDevice = ({ station, goToPlayBack }) => {
|
|
21
21
|
const t = useTranslations();
|
|
22
22
|
const { navigate } = useNavigation();
|
|
23
23
|
const { setAction } = useContext(SCContext);
|
|
@@ -62,7 +62,6 @@ const CameraDevice = ({ station, handleFullScreen, goToPlayBack }) => {
|
|
|
62
62
|
}}
|
|
63
63
|
key={`camera-device-${device.id}`}
|
|
64
64
|
cameraName={device.configuration.name}
|
|
65
|
-
handleFullScreen={handleFullScreen}
|
|
66
65
|
goToPlayBack={goToPlayBack(device, { uri: station?.background })}
|
|
67
66
|
width={standardizeWidth}
|
|
68
67
|
height={standardizeHeight}
|
|
@@ -3,18 +3,26 @@ import { View } from 'react-native';
|
|
|
3
3
|
import styles from './DeviceItemStyles';
|
|
4
4
|
import FImage from '../../FImage';
|
|
5
5
|
import _TextInput from '../../Form/TextInput';
|
|
6
|
+
import Images from '../../../configs/Images';
|
|
6
7
|
|
|
7
|
-
const DeviceItem = memo(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
8
|
+
const DeviceItem = memo(
|
|
9
|
+
({ icon, name, setNewName, handleSelectionChange, isSelection }) => {
|
|
10
|
+
return (
|
|
11
|
+
<View style={styles.container}>
|
|
12
|
+
<FImage
|
|
13
|
+
source={icon ? { uri: icon } : Images.deviceIcon}
|
|
14
|
+
style={styles.iconSensor}
|
|
15
|
+
/>
|
|
16
|
+
<_TextInput
|
|
17
|
+
value={name}
|
|
18
|
+
textInputStyle={styles.textItem}
|
|
19
|
+
onChange={setNewName}
|
|
20
|
+
selection={isSelection && { start: 0, end: 0 }}
|
|
21
|
+
onSelectionChange={handleSelectionChange}
|
|
22
|
+
/>
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
19
27
|
|
|
20
28
|
export default DeviceItem;
|
|
@@ -13,7 +13,7 @@ describe('Test DeviceItem button', () => {
|
|
|
13
13
|
const instance = tree.root;
|
|
14
14
|
const image = instance.findAllByType(FImage);
|
|
15
15
|
const text = instance.findAllByType(_TextInput);
|
|
16
|
-
expect(image).toHaveLength(
|
|
16
|
+
expect(image).toHaveLength(1);
|
|
17
17
|
expect(text).toHaveLength(1);
|
|
18
18
|
});
|
|
19
19
|
});
|
|
@@ -20,6 +20,8 @@ const ConnectingSuccess = ({
|
|
|
20
20
|
unit_name,
|
|
21
21
|
newName,
|
|
22
22
|
setNewName,
|
|
23
|
+
isSelection,
|
|
24
|
+
handleSelectionChange,
|
|
23
25
|
}) => {
|
|
24
26
|
const t = useTranslations();
|
|
25
27
|
return (
|
|
@@ -37,6 +39,8 @@ const ConnectingSuccess = ({
|
|
|
37
39
|
icon={sensor?.icon_kit}
|
|
38
40
|
name={newName}
|
|
39
41
|
setNewName={setNewName}
|
|
42
|
+
handleSelectionChange={handleSelectionChange}
|
|
43
|
+
isSelection={isSelection}
|
|
40
44
|
/>
|
|
41
45
|
</View>
|
|
42
46
|
);
|
|
@@ -61,6 +65,7 @@ const ConnectingProcess = ({ route }) => {
|
|
|
61
65
|
const [sensor, setSensor] = useState(null);
|
|
62
66
|
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
63
67
|
const [newName, setNewName] = useState('');
|
|
68
|
+
const [isSelection, setIsSelection] = useState(true);
|
|
64
69
|
|
|
65
70
|
const connectingDevice = useCallback(async () => {
|
|
66
71
|
setIsLoading(true);
|
|
@@ -166,6 +171,10 @@ const ConnectingProcess = ({ route }) => {
|
|
|
166
171
|
unit_id,
|
|
167
172
|
]);
|
|
168
173
|
|
|
174
|
+
const handleSelectionChange = useCallback(() => {
|
|
175
|
+
setIsSelection(false);
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
169
178
|
useEffect(() => {
|
|
170
179
|
connectingDevice();
|
|
171
180
|
}, [connectingDevice]);
|
|
@@ -185,6 +194,8 @@ const ConnectingProcess = ({ route }) => {
|
|
|
185
194
|
unit_name={unit_name}
|
|
186
195
|
newName={newName}
|
|
187
196
|
setNewName={setNewName}
|
|
197
|
+
isSelection={isSelection}
|
|
198
|
+
handleSelectionChange={handleSelectionChange}
|
|
188
199
|
/>
|
|
189
200
|
)}
|
|
190
201
|
</View>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import styles from './Styles/LabelStyles';
|
|
5
|
+
|
|
6
|
+
const Label = ({ name = '', style }) => {
|
|
7
|
+
return <Text style={[styles.label, style]}>{name}</Text>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default memo(Label);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { View, Image, TextInput } from 'react-native';
|
|
3
|
+
import { Images } from '../../configs';
|
|
4
|
+
import t from '../../hooks/Common/useTranslations';
|
|
5
|
+
import styles from './Styles/SearchStyles';
|
|
6
|
+
|
|
7
|
+
const Search = ({ onSearch }) => {
|
|
8
|
+
return (
|
|
9
|
+
<View style={styles.wrap}>
|
|
10
|
+
<Image source={Images.search} style={styles.icon} />
|
|
11
|
+
<TextInput
|
|
12
|
+
style={styles.textInput}
|
|
13
|
+
placeholder={t('what_are_you_looking_for')}
|
|
14
|
+
onChangeText={onSearch}
|
|
15
|
+
/>
|
|
16
|
+
</View>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default memo(Search);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrap: {
|
|
6
|
+
borderRadius: 6,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
borderColor: Colors.Neutral.Neutral3,
|
|
9
|
+
width: '100%',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
paddingHorizontal: 10,
|
|
13
|
+
marginVertical: 16,
|
|
14
|
+
},
|
|
15
|
+
icon: {},
|
|
16
|
+
textInput: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
height: 36,
|
|
19
|
+
marginLeft: 5,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -9,7 +9,11 @@ import { TESTID } from '../../../configs/Constants';
|
|
|
9
9
|
|
|
10
10
|
const ItemAddNew = memo(({ title, onAddNew, wrapStyle }) => {
|
|
11
11
|
return (
|
|
12
|
-
<TouchableWithoutFeedback
|
|
12
|
+
<TouchableWithoutFeedback
|
|
13
|
+
onPress={onAddNew}
|
|
14
|
+
testID={TESTID.TOUCH_ADD_NEW_FAVORITES}
|
|
15
|
+
accessibilityLabel={TESTID.TOUCH_ADD_NEW_FAVORITES}
|
|
16
|
+
>
|
|
13
17
|
<View style={[styles.container, wrapStyle]}>
|
|
14
18
|
<View style={styles.boxIcon}>
|
|
15
19
|
<TouchableOpacity
|
|
@@ -61,17 +61,18 @@ const ItemDevice = memo(
|
|
|
61
61
|
|
|
62
62
|
const borderColor = (() => {
|
|
63
63
|
if (!!sensor && sensor?.is_managed_by_backend) {
|
|
64
|
+
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
65
|
+
return Colors.Gray4;
|
|
66
|
+
}
|
|
64
67
|
if (isConnectedViaBLE) {
|
|
65
68
|
return Colors.Gray4;
|
|
66
69
|
}
|
|
67
70
|
if (isFetchingStatus || isConnectedViaInternet) {
|
|
68
71
|
return Colors.Gray4;
|
|
69
72
|
}
|
|
73
|
+
return Colors.Red6;
|
|
70
74
|
}
|
|
71
75
|
// not managed by backend
|
|
72
|
-
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
73
|
-
return Colors.Gray4;
|
|
74
|
-
}
|
|
75
76
|
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
76
77
|
if (isGGHomeConnecting || isGGHomeConnected) {
|
|
77
78
|
return Colors.Gray4;
|
|
@@ -82,6 +83,9 @@ const ItemDevice = memo(
|
|
|
82
83
|
|
|
83
84
|
const textConnected = (() => {
|
|
84
85
|
if (!!sensor && sensor?.is_managed_by_backend) {
|
|
86
|
+
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
87
|
+
return t('connected');
|
|
88
|
+
}
|
|
85
89
|
if (isConnectedViaBLE) {
|
|
86
90
|
return t('connected');
|
|
87
91
|
}
|
|
@@ -91,11 +95,9 @@ const ItemDevice = memo(
|
|
|
91
95
|
if (isConnectedViaInternet) {
|
|
92
96
|
return t('connected');
|
|
93
97
|
}
|
|
98
|
+
return t('disconnected');
|
|
94
99
|
}
|
|
95
100
|
// not managed by backend
|
|
96
|
-
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
97
|
-
return t('connected');
|
|
98
|
-
}
|
|
99
101
|
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
100
102
|
if (isGGHomeConnecting) {
|
|
101
103
|
return t('connecting');
|
|
@@ -109,6 +111,9 @@ const ItemDevice = memo(
|
|
|
109
111
|
|
|
110
112
|
const canRenderQuickAction = (() => {
|
|
111
113
|
if (!!sensor && sensor?.is_managed_by_backend) {
|
|
114
|
+
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
112
117
|
if (isConnectedViaBLE) {
|
|
113
118
|
return true;
|
|
114
119
|
}
|
|
@@ -118,9 +123,6 @@ const ItemDevice = memo(
|
|
|
118
123
|
return true;
|
|
119
124
|
}
|
|
120
125
|
// not managed by backend
|
|
121
|
-
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
126
|
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
125
127
|
return !isGGHomeConnecting;
|
|
126
128
|
}
|
|
@@ -131,6 +133,7 @@ const ItemDevice = memo(
|
|
|
131
133
|
<TouchableWithoutFeedback
|
|
132
134
|
onPress={goToSensorDisplay}
|
|
133
135
|
testID={`${TESTID.SENSOR_NAME}-${sensor?.id}`}
|
|
136
|
+
accessibilityLabel={`${TESTID.SENSOR_NAME}-${sensor?.id}`}
|
|
134
137
|
>
|
|
135
138
|
<View
|
|
136
139
|
style={[styles.container, wrapStyle, { borderColor }]}
|