@eohjsc/react-native-smart-city 0.2.82 → 0.2.85
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/assets/images/Event.svg +9 -0
- package/assets/images/brightness.svg +12 -0
- package/package.json +4 -2
- package/src/Images/Common/SuccessfullyConnected.svg +4 -0
- package/src/Images/Common/eye-closed.png +0 -0
- package/src/Images/Common/eye-closed@2x.png +0 -0
- package/src/Images/Common/eye-closed@3x.png +0 -0
- package/src/Images/Common/eye.png +0 -0
- package/src/Images/Common/eye@2x.png +0 -0
- package/src/Images/Common/eye@3x.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
- package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
- package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
- package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
- package/src/commons/ActionGroup/__test__/index.test.js +48 -14
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/Automate/ItemAutomate.js +1 -1
- package/src/commons/Automate/ItemAutomateStyles.js +5 -1
- package/src/commons/CardShadow/index.js +5 -2
- package/src/commons/CardShadow/styles.js +2 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
- package/src/commons/ConnectingProcess/index.js +202 -0
- package/src/commons/ConnectingProcess/styles.js +69 -0
- package/src/commons/Device/HorizontalBarChart.js +7 -1
- package/src/commons/Device/ItemDevice.js +8 -5
- package/src/commons/Device/LinearChart.js +1 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/EmergencyButton/AlertSent.js +2 -2
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +35 -0
- package/src/commons/SubUnit/Favorites/index.js +2 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -0
- package/src/commons/SubUnit/ShortDetail.js +7 -1
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +6 -4
- package/src/configs/Constants.js +25 -0
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useBlockBackAndroid.js +3 -1
- package/src/iot/RemoteControl/Internet.js +8 -1
- package/src/iot/RemoteControl/index.js +4 -2
- package/src/navigations/AddDeviceStack.js +10 -0
- package/src/screens/AddCommon/SelectSubUnit.js +29 -6
- package/src/screens/AddCommon/SelectUnit.js +24 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
- package/src/screens/AddNewAction/SelectAction.js +46 -28
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -3
- package/src/screens/AddNewAutoSmart/index.js +18 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +55 -16
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +52 -23
- package/src/screens/AddNewGateway/SelectGateway.js +132 -0
- package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -52
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +18 -11
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +64 -26
- package/src/screens/Device/styles.js +2 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +197 -15
- package/src/screens/Notification/components/NotificationItem.js +188 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +10 -7
- package/src/screens/ScanChipQR/hooks/index.js +48 -40
- package/src/screens/SubUnit/AddSubUnit.js +4 -1
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
- package/src/screens/Unit/Detail.js +33 -1
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/screens/Unit/ManageUnitStyles.js +0 -6
- package/src/screens/Unit/SmartAccount.js +5 -1
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
- package/src/screens/Unit/__test__/Detail.test.js +10 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
- package/src/screens/UnitSummary/__test__/index.test.js +3 -3
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/index.js +52 -9
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/I18n/translations/en.json +16 -0
- package/src/utils/I18n/translations/vi.json +16 -1
- package/src/utils/Route/index.js +2 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React, { useEffect, useCallback, useState } from 'react';
|
|
2
|
+
import { SafeAreaView, View, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
+
import Routes from '../../utils/Route';
|
|
5
|
+
import { useNavigation } from '@react-navigation/native';
|
|
6
|
+
import * as Progress from 'react-native-progress';
|
|
7
|
+
import ImageSuccessfully from '../../Images/Common/SuccessfullyConnected.svg';
|
|
8
|
+
|
|
9
|
+
import Text from '../Text';
|
|
10
|
+
import { axiosPost } from '../../utils/Apis/axios';
|
|
11
|
+
import { API, Colors, Constants } from '../../configs';
|
|
12
|
+
import styles from './styles';
|
|
13
|
+
import DeviceItem from './DeviceItem/DeviceItem';
|
|
14
|
+
import { useSCContextSelector } from '../../context';
|
|
15
|
+
|
|
16
|
+
const ConnectingProcess = ({ route }) => {
|
|
17
|
+
const { navigate, goBack } = useNavigation();
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
scan_sensor_data,
|
|
22
|
+
gateway,
|
|
23
|
+
station,
|
|
24
|
+
unit,
|
|
25
|
+
unit_id,
|
|
26
|
+
devicePrefixName,
|
|
27
|
+
wifi_ssid,
|
|
28
|
+
wifi_pass,
|
|
29
|
+
chip_id,
|
|
30
|
+
} = route.params;
|
|
31
|
+
const [percent, setPercent] = useState(0);
|
|
32
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
33
|
+
const [sensor, setSensor] = useState(null);
|
|
34
|
+
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
processLoading();
|
|
37
|
+
}, [processLoading]);
|
|
38
|
+
|
|
39
|
+
const processLoading = useCallback(() => {
|
|
40
|
+
let interval;
|
|
41
|
+
if (isLoading) {
|
|
42
|
+
interval = setInterval(() => {
|
|
43
|
+
setPercent((prev) => {
|
|
44
|
+
if (prev === 1) {
|
|
45
|
+
clearInterval(interval);
|
|
46
|
+
return 1;
|
|
47
|
+
} else {
|
|
48
|
+
return prev + 0.2;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}, 180);
|
|
52
|
+
} else {
|
|
53
|
+
clearInterval(interval);
|
|
54
|
+
}
|
|
55
|
+
}, [isLoading]);
|
|
56
|
+
|
|
57
|
+
const ConnectingDevice = useCallback(async () => {
|
|
58
|
+
setIsLoading(true);
|
|
59
|
+
switch (devicePrefixName) {
|
|
60
|
+
case 'SENSOR':
|
|
61
|
+
{
|
|
62
|
+
const body = { imei: scan_sensor_data?.imei, chip: gateway?.id };
|
|
63
|
+
const { success, data } = await axiosPost(
|
|
64
|
+
API.SUB_UNIT.SENSOR_SCAN(station.id),
|
|
65
|
+
body
|
|
66
|
+
);
|
|
67
|
+
if (success) {
|
|
68
|
+
setSensor(data);
|
|
69
|
+
} else {
|
|
70
|
+
goBack();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case 'ROBOT': {
|
|
75
|
+
const { success, data } = await axiosPost(API.UNIT.CHIP_SCAN(unit.id), {
|
|
76
|
+
imei: gateway?.imei,
|
|
77
|
+
qr_code: scan_sensor_data?.imei,
|
|
78
|
+
name: gateway?.model,
|
|
79
|
+
station: station?.id,
|
|
80
|
+
wifi_ssid: wifi_ssid,
|
|
81
|
+
wifi_pass: wifi_pass,
|
|
82
|
+
phone: user?.phone_number,
|
|
83
|
+
});
|
|
84
|
+
if (success) {
|
|
85
|
+
setSensor(data);
|
|
86
|
+
} else {
|
|
87
|
+
goBack();
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'LITE': {
|
|
92
|
+
const { success } = await axiosPost(API.UNIT.ADD_GATEWAY(unit_id), {
|
|
93
|
+
chip: chip_id,
|
|
94
|
+
imei: gateway?.imei,
|
|
95
|
+
chip_name: gateway?.model,
|
|
96
|
+
});
|
|
97
|
+
if (success) {
|
|
98
|
+
setSensor({ name: gateway?.model });
|
|
99
|
+
} else {
|
|
100
|
+
goBack();
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
setIsLoading(false);
|
|
106
|
+
}, [
|
|
107
|
+
devicePrefixName,
|
|
108
|
+
scan_sensor_data?.imei,
|
|
109
|
+
gateway?.id,
|
|
110
|
+
gateway?.imei,
|
|
111
|
+
gateway?.model,
|
|
112
|
+
station,
|
|
113
|
+
goBack,
|
|
114
|
+
unit,
|
|
115
|
+
wifi_ssid,
|
|
116
|
+
wifi_pass,
|
|
117
|
+
user?.phone_number,
|
|
118
|
+
unit_id,
|
|
119
|
+
chip_id,
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
const Connecting = useCallback(() => {
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
<View style={styles.progressBar}>
|
|
126
|
+
<View style={styles.connecting}>
|
|
127
|
+
<Text type="H4" bold>
|
|
128
|
+
{t('connecting')}
|
|
129
|
+
</Text>
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
<View style={styles.percentLoad}>
|
|
133
|
+
<Progress.Bar
|
|
134
|
+
progress={percent}
|
|
135
|
+
animated={true}
|
|
136
|
+
color={Colors.Primary}
|
|
137
|
+
indeterminateAnimationDuration={1000}
|
|
138
|
+
height={7}
|
|
139
|
+
width={Constants.width - 80}
|
|
140
|
+
useNativeDriver={true}
|
|
141
|
+
/>
|
|
142
|
+
<Text style={styles.textPercentLoad}>{`${parseInt(
|
|
143
|
+
percent * 100,
|
|
144
|
+
10
|
|
145
|
+
)}%`}</Text>
|
|
146
|
+
</View>
|
|
147
|
+
</>
|
|
148
|
+
);
|
|
149
|
+
}, [percent, t]);
|
|
150
|
+
|
|
151
|
+
const ConnectingSuccess = useCallback(() => {
|
|
152
|
+
return (
|
|
153
|
+
<View style={styles.ConnectingSuccess}>
|
|
154
|
+
<ImageSuccessfully />
|
|
155
|
+
<Text bold style={styles.connectingText}>
|
|
156
|
+
{t('successfully_connected')}
|
|
157
|
+
</Text>
|
|
158
|
+
<Text size={14} style={styles.textHome}>
|
|
159
|
+
Home - {station?.name}
|
|
160
|
+
</Text>
|
|
161
|
+
<DeviceItem icon={sensor?.icon_kit} name={sensor?.name} />
|
|
162
|
+
</View>
|
|
163
|
+
);
|
|
164
|
+
}, [sensor?.icon_kit, sensor?.name, station?.name, t]);
|
|
165
|
+
|
|
166
|
+
const handleDone = useCallback(() => {
|
|
167
|
+
navigate(Routes.UnitStack, {
|
|
168
|
+
screen: Routes.UnitDetail,
|
|
169
|
+
params: {
|
|
170
|
+
unitId: unit?.id || unit_id,
|
|
171
|
+
unitData: unit,
|
|
172
|
+
routeName: 'DashboardStack',
|
|
173
|
+
stationId: station?.id,
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}, [navigate, station?.id, unit, unit_id]);
|
|
177
|
+
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
ConnectingDevice();
|
|
180
|
+
}, [ConnectingDevice]);
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<SafeAreaView style={styles.wrap}>
|
|
184
|
+
<View style={styles.boxText}>
|
|
185
|
+
<Text bold style={styles.connectingText}>
|
|
186
|
+
{t('connect_device')}
|
|
187
|
+
</Text>
|
|
188
|
+
{!!isLoading && <Connecting />}
|
|
189
|
+
{!isLoading && <ConnectingSuccess />}
|
|
190
|
+
</View>
|
|
191
|
+
{!isLoading && (
|
|
192
|
+
<TouchableOpacity style={styles.buttonDone} onPress={handleDone}>
|
|
193
|
+
<Text color={Colors.Primary} type={'H4'}>
|
|
194
|
+
{t('done')}
|
|
195
|
+
</Text>
|
|
196
|
+
</TouchableOpacity>
|
|
197
|
+
)}
|
|
198
|
+
</SafeAreaView>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export default ConnectingProcess;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../configs';
|
|
3
|
+
import {
|
|
4
|
+
getStatusBarHeight,
|
|
5
|
+
getBottomSpace,
|
|
6
|
+
} from 'react-native-iphone-x-helper';
|
|
7
|
+
|
|
8
|
+
export default StyleSheet.create({
|
|
9
|
+
wrap: {
|
|
10
|
+
paddingTop: getStatusBarHeight(true),
|
|
11
|
+
backgroundColor: Colors.White,
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
},
|
|
16
|
+
connectingText: {
|
|
17
|
+
marginLeft: 30,
|
|
18
|
+
marginTop: 16,
|
|
19
|
+
fontSize: 20,
|
|
20
|
+
color: Colors.Gray9,
|
|
21
|
+
},
|
|
22
|
+
animatedEllipsis: {
|
|
23
|
+
fontSize: 25,
|
|
24
|
+
color: Colors.Gray9,
|
|
25
|
+
marginTop: 14,
|
|
26
|
+
},
|
|
27
|
+
warningText: {
|
|
28
|
+
marginHorizontal: 30,
|
|
29
|
+
marginTop: 16,
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
color: Colors.Gray8,
|
|
32
|
+
},
|
|
33
|
+
boxText: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
},
|
|
36
|
+
progressBar: {
|
|
37
|
+
flexDirection: 'column',
|
|
38
|
+
marginTop: 180,
|
|
39
|
+
marginHorizontal: 30,
|
|
40
|
+
},
|
|
41
|
+
connecting: {
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
marginBottom: 10,
|
|
45
|
+
},
|
|
46
|
+
percentLoad: {
|
|
47
|
+
flexDirection: 'row',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
},
|
|
51
|
+
textPercentLoad: {
|
|
52
|
+
marginLeft: 10,
|
|
53
|
+
},
|
|
54
|
+
ConnectingSuccess: {
|
|
55
|
+
marginTop: 180,
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
},
|
|
59
|
+
textHome: {
|
|
60
|
+
paddingTop: 16,
|
|
61
|
+
paddingBottom: 8,
|
|
62
|
+
},
|
|
63
|
+
buttonDone: {
|
|
64
|
+
width: '100%',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
paddingBottom: getBottomSpace() + 24,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
@@ -33,6 +33,7 @@ const HorizontalBarChart = memo(({ datas, config }) => {
|
|
|
33
33
|
},
|
|
34
34
|
yAxis: {
|
|
35
35
|
min: 0,
|
|
36
|
+
minRange: 0.5,
|
|
36
37
|
title: {
|
|
37
38
|
text: null,
|
|
38
39
|
},
|
|
@@ -55,7 +56,12 @@ const HorizontalBarChart = memo(({ datas, config }) => {
|
|
|
55
56
|
useHTML: true,
|
|
56
57
|
formatter: function () {
|
|
57
58
|
const { unit, price } = JSON.parse(this.series.name);
|
|
58
|
-
const textColor =
|
|
59
|
+
const textColor =
|
|
60
|
+
this.color === '#00979D'
|
|
61
|
+
? this.y === 0
|
|
62
|
+
? '#262626'
|
|
63
|
+
: '#FFFFFF'
|
|
64
|
+
: '#262626';
|
|
59
65
|
const valueStyle = `color:${textColor};font-weight:normal;font-size:12px;`;
|
|
60
66
|
const costStyle = valueStyle + 'font-weight:bold;';
|
|
61
67
|
|
|
@@ -30,6 +30,7 @@ const ItemDevice = memo(
|
|
|
30
30
|
sensor,
|
|
31
31
|
unit,
|
|
32
32
|
station,
|
|
33
|
+
isNetworkConnected,
|
|
33
34
|
isGGHomeConnected,
|
|
34
35
|
status,
|
|
35
36
|
wrapStyle,
|
|
@@ -39,9 +40,9 @@ const ItemDevice = memo(
|
|
|
39
40
|
|
|
40
41
|
const goToSensorDisplay = useCallback(() => {
|
|
41
42
|
navigation.navigate(Routes.DeviceDetail, {
|
|
42
|
-
unit,
|
|
43
|
+
unitData: unit,
|
|
43
44
|
station,
|
|
44
|
-
sensor,
|
|
45
|
+
sensorData: sensor,
|
|
45
46
|
title,
|
|
46
47
|
isGGHomeConnected,
|
|
47
48
|
});
|
|
@@ -56,13 +57,15 @@ const ItemDevice = memo(
|
|
|
56
57
|
);
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
const
|
|
60
|
-
status === undefined
|
|
60
|
+
const isConnectedViaInternet =
|
|
61
|
+
status === undefined
|
|
62
|
+
? isNetworkConnected && sensor.is_connected
|
|
63
|
+
: isNetworkConnected && status.is_connected;
|
|
61
64
|
const isBLEConnected = isDeviceConnected(
|
|
62
65
|
sensor?.remote_control_options?.bluetooth?.address
|
|
63
66
|
);
|
|
64
67
|
const isConnected =
|
|
65
|
-
|
|
68
|
+
isConnectedViaInternet || isGGHomeConnected || isBLEConnected;
|
|
66
69
|
const borderColor = isConnected ? Colors.Gray4 : Colors.Red6;
|
|
67
70
|
const textConnected = isConnected ? t('connected') : t('disconnected');
|
|
68
71
|
|
|
@@ -44,9 +44,9 @@ const AlertSendConfirm = ({
|
|
|
44
44
|
<Text
|
|
45
45
|
type="Body"
|
|
46
46
|
style={styles.textLocation}
|
|
47
|
-
>{`${unit
|
|
47
|
+
>{`${unit?.name} - ${station?.name}`}</Text>
|
|
48
48
|
<Text type="Body" style={styles.textAddress}>
|
|
49
|
-
{unit
|
|
49
|
+
{unit?.address}
|
|
50
50
|
</Text>
|
|
51
51
|
</View>
|
|
52
52
|
</ButtonPopup>
|
|
@@ -58,7 +58,7 @@ const AlertSent = ({
|
|
|
58
58
|
<Text
|
|
59
59
|
type="H5"
|
|
60
60
|
style={styles.location}
|
|
61
|
-
>{`${unit
|
|
61
|
+
>{`${unit?.name} - ${station?.name}`}</Text>
|
|
62
62
|
<IconFill name="alert" size={42} style={styles.alert} />
|
|
63
63
|
<Text semibold style={styles.textAlertSent}>
|
|
64
64
|
{data.title}
|
|
@@ -67,7 +67,7 @@ const AlertSent = ({
|
|
|
67
67
|
{data.message}
|
|
68
68
|
{isDashboard && (
|
|
69
69
|
<Text type="H4" semibold>
|
|
70
|
-
{` ${unit
|
|
70
|
+
{` ${unit?.name}: ${station?.name}.`}
|
|
71
71
|
</Text>
|
|
72
72
|
)}
|
|
73
73
|
</Text>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { colorOpacity } from '../../utils/Converter/color';
|
|
5
|
+
import { Colors } from '../../configs';
|
|
6
|
+
|
|
7
|
+
const FullLoading = ({ wrapStyle, color = Colors.Primary, size = 'small' }) => (
|
|
8
|
+
<View style={[styles.wrap, wrapStyle]}>
|
|
9
|
+
<View style={styles.background}>
|
|
10
|
+
<ActivityIndicator color={color} size={size} />
|
|
11
|
+
</View>
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
wrap: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
backgroundColor: colorOpacity(Colors.Black, 0.1),
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
bottom: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
zIndex: 10,
|
|
26
|
+
},
|
|
27
|
+
background: {
|
|
28
|
+
backgroundColor: colorOpacity(Colors.White, 0.8),
|
|
29
|
+
borderRadius: 5,
|
|
30
|
+
paddingHorizontal: 32,
|
|
31
|
+
paddingVertical: 24,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default FullLoading;
|
|
@@ -15,6 +15,7 @@ const SubUnitFavorites = ({
|
|
|
15
15
|
unit,
|
|
16
16
|
isOwner,
|
|
17
17
|
favorites,
|
|
18
|
+
isNetworkConnected,
|
|
18
19
|
isGGHomeConnected,
|
|
19
20
|
wrapItemStyle,
|
|
20
21
|
}) => {
|
|
@@ -71,6 +72,7 @@ const SubUnitFavorites = ({
|
|
|
71
72
|
sensor={sensor}
|
|
72
73
|
unit={unit}
|
|
73
74
|
station={sensor.station}
|
|
75
|
+
isNetworkConnected={isNetworkConnected}
|
|
74
76
|
isGGHomeConnected={isGGHomeConnected}
|
|
75
77
|
status={sensorsStatus.find((s) => s.id === sensor.id)}
|
|
76
78
|
wrapStyle={wrapItemStyle}
|
|
@@ -7,6 +7,7 @@ import { API, Colors } from '../../../configs';
|
|
|
7
7
|
import OneTap from '../../../../assets/images/OneTap.svg';
|
|
8
8
|
import ValueChange from '../../../../assets/images/ValueChange.svg';
|
|
9
9
|
import Schedule from '../../../../assets/images/Schedule.svg';
|
|
10
|
+
import Event from '../../../../assets/images/Event.svg';
|
|
10
11
|
import CheckCircle from '../../../../assets/images/CheckCircle.svg';
|
|
11
12
|
import FImage from '../../FImage';
|
|
12
13
|
import { timeDifference } from '../../../utils/Converter/time';
|
|
@@ -92,6 +93,8 @@ const ItemOneTap = memo(
|
|
|
92
93
|
return <OneTap />;
|
|
93
94
|
} else if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
94
95
|
return <ValueChange />;
|
|
96
|
+
} else if (type === AUTOMATE_TYPE.EVENT) {
|
|
97
|
+
return <Event />;
|
|
95
98
|
} else {
|
|
96
99
|
return <Schedule />;
|
|
97
100
|
}
|
|
@@ -19,7 +19,12 @@ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
|
|
|
19
19
|
Device.screenWidth - 32
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
const ShortDetailSubUnit = ({
|
|
22
|
+
const ShortDetailSubUnit = ({
|
|
23
|
+
unit,
|
|
24
|
+
station,
|
|
25
|
+
isNetworkConnected,
|
|
26
|
+
isGGHomeConnected,
|
|
27
|
+
}) => {
|
|
23
28
|
const t = useTranslations();
|
|
24
29
|
const isFocused = useIsFocused();
|
|
25
30
|
const { navigate } = useNavigation();
|
|
@@ -146,6 +151,7 @@ const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
|
|
|
146
151
|
sensor={sensor}
|
|
147
152
|
unit={unit}
|
|
148
153
|
station={station}
|
|
154
|
+
isNetworkConnected={isNetworkConnected}
|
|
149
155
|
isGGHomeConnected={isGGHomeConnected}
|
|
150
156
|
status={sensorsStatus.find((s) => s.id === sensor.id)}
|
|
151
157
|
/>
|
package/src/commons/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import MenuActionList from './MenuActionList';
|
|
|
15
15
|
import RadioCircle from './RadioCircle';
|
|
16
16
|
import { CircleButton } from './CircleButton';
|
|
17
17
|
import HorizontalPicker from './HorizontalPicker';
|
|
18
|
+
import FullLoading from './FullLoading';
|
|
18
19
|
|
|
19
20
|
export {
|
|
20
21
|
ButtonPopup,
|
|
@@ -34,4 +35,5 @@ export {
|
|
|
34
35
|
RadioCircle,
|
|
35
36
|
CircleButton,
|
|
36
37
|
HorizontalPicker,
|
|
38
|
+
FullLoading,
|
|
37
39
|
};
|
package/src/configs/API.js
CHANGED
|
@@ -25,6 +25,8 @@ const API = {
|
|
|
25
25
|
MANAGE_UNIT: (id) => SCConfig.apiRoot + `/property_manager/units/${id}/`,
|
|
26
26
|
CHIP_SCAN: (id) =>
|
|
27
27
|
SCConfig.apiRoot + `/property_manager/units/${id}/chip_scan/`,
|
|
28
|
+
CHIP_SCAN_GET_WIFI_INFO: () =>
|
|
29
|
+
SCConfig.apiRoot + '/property_manager/units/chip_scan_get_wifi_info/',
|
|
28
30
|
MANAGE_ACCESS: (id) =>
|
|
29
31
|
SCConfig.apiRoot + `/property_manager/manage_access/${id}/`,
|
|
30
32
|
AUTOMATE: (id) =>
|
|
@@ -51,8 +53,12 @@ const API = {
|
|
|
51
53
|
CHIP: {
|
|
52
54
|
CHECK_FINALIZED: () =>
|
|
53
55
|
SCConfig.apiRoot + '/property_manager/stations/check_chip_finalized/',
|
|
56
|
+
GET_CHIPS_FROM_UNIT: (id) =>
|
|
57
|
+
SCConfig.apiRoot + `/property_manager/get_chips/?unit_id=${id}`,
|
|
54
58
|
},
|
|
55
59
|
SENSOR: {
|
|
60
|
+
SENSOR_DETAIL: (id) =>
|
|
61
|
+
SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
|
|
56
62
|
DISPLAY: (id) =>
|
|
57
63
|
SCConfig.apiRoot + `/property_manager/sensors/${id}/display/`,
|
|
58
64
|
DISPLAY_VALUES: (id) =>
|
|
@@ -82,10 +88,6 @@ const API = {
|
|
|
82
88
|
`/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/remove_from_favourites/`,
|
|
83
89
|
DISPLAY_ACTIONS: (id) =>
|
|
84
90
|
SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
|
|
85
|
-
RENAME_SENSOR: (id) =>
|
|
86
|
-
SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
|
|
87
|
-
REMOVE_SENSOR: (id) =>
|
|
88
|
-
SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
|
|
89
91
|
CHANGE_SUB_UNIT: (unit_id, station_id, id) =>
|
|
90
92
|
SCConfig.apiRoot +
|
|
91
93
|
`/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/change_sub_unit/`,
|
package/src/configs/Constants.js
CHANGED
|
@@ -3,6 +3,7 @@ import { RFValue } from 'react-native-responsive-fontsize';
|
|
|
3
3
|
import OneTap from '../../assets/images/OneTap.svg';
|
|
4
4
|
import ValueChange from '../../assets/images/ValueChange.svg';
|
|
5
5
|
import Schedule from '../../assets/images/Schedule.svg';
|
|
6
|
+
import Event from '../../assets/images/Event.svg';
|
|
6
7
|
|
|
7
8
|
const X_WIDTH = 375;
|
|
8
9
|
const X_HEIGHT = 812;
|
|
@@ -91,6 +92,7 @@ export const AUTOMATE_TYPE = {
|
|
|
91
92
|
ONE_TAP: 'one_tap',
|
|
92
93
|
VALUE_CHANGE: 'value_change',
|
|
93
94
|
SCHEDULE: 'schedule',
|
|
95
|
+
EVENT: 'event',
|
|
94
96
|
ONE_TAP_ONLY: 'one_tap_only',
|
|
95
97
|
AUTOMATE: 'automate',
|
|
96
98
|
AUTOMATION: 'automation',
|
|
@@ -128,6 +130,12 @@ export const AUTOMATES = {
|
|
|
128
130
|
explanation: 'setup_the_schedule',
|
|
129
131
|
icon: Schedule,
|
|
130
132
|
},
|
|
133
|
+
event: {
|
|
134
|
+
value: AUTOMATE_TYPE.EVENT,
|
|
135
|
+
title: 'event',
|
|
136
|
+
explanation: 'setup_the_conditions',
|
|
137
|
+
icon: Event,
|
|
138
|
+
},
|
|
131
139
|
};
|
|
132
140
|
|
|
133
141
|
export const UNIT_TYPES = {
|
|
@@ -340,6 +348,7 @@ export const TESTID = {
|
|
|
340
348
|
|
|
341
349
|
// ADD SUB UNIT
|
|
342
350
|
ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO: 'ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO',
|
|
351
|
+
ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION: 'ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION',
|
|
343
352
|
|
|
344
353
|
SCANNING_RESPONSE_TITLE: 'SCANNING_RESPONSE_TITLE',
|
|
345
354
|
SCANNING_RESPONSE_DESCRIPTION: 'SCANNING_RESPONSE_DESCRIPTION',
|
|
@@ -478,6 +487,12 @@ export const TESTID = {
|
|
|
478
487
|
TOUCH_SHARED_UNIT: 'TOUCH_SHARED_UNIT',
|
|
479
488
|
SHARED_UNIT_OWN_BY: 'SHARED_UNIT_OWN_BY',
|
|
480
489
|
|
|
490
|
+
// Select subunit
|
|
491
|
+
|
|
492
|
+
SELECT_SUBUNIT_NAME: 'SELECT_SUBUNIT_NAME',
|
|
493
|
+
SELECT_SUBUNIT_RADIO_BUTTON: 'SELECT_SUBUNIT_RADIO_BUTTON',
|
|
494
|
+
SELECT_SUBUNIT_SELECT: 'SELECT_SUBUNIT_SELECT',
|
|
495
|
+
|
|
481
496
|
// Select unit
|
|
482
497
|
SELECT_UNIT_NAME: 'SELECT_UNIT_NAME',
|
|
483
498
|
SELECT_UNIT_RADIO_BUTTON: 'SELECT_UNIT_RADIO_BUTTON',
|
|
@@ -552,6 +567,12 @@ export const TESTID = {
|
|
|
552
567
|
ADD_NEW_GATEWAY_THEN_SELECT: 'ADD_NEW_GATEWAY_THEN_SELECT',
|
|
553
568
|
ADD_NEW_GATEWAY_TEXT_IMEI: 'ADD_NEW_GATEWAY_TEXT_IMEI',
|
|
554
569
|
|
|
570
|
+
// Select Gateway
|
|
571
|
+
|
|
572
|
+
SELECT_GATEWAY_NAME: 'SELECT_GATEWAY_NAME',
|
|
573
|
+
SELECT_GATEWAY_RADIO_BUTTON: 'SELECT_GATEWAY_RADIO_BUTTON',
|
|
574
|
+
SELECT_GATEWAY_SELECT: 'SELECT_GATEWAY_SELECT',
|
|
575
|
+
|
|
555
576
|
// Header
|
|
556
577
|
HEADER_ANI_TITLE: 'HEADER_ANI_TITLE',
|
|
557
578
|
|
|
@@ -634,10 +655,14 @@ export const NOTIFICATION_TYPES = {
|
|
|
634
655
|
PARKING_COMPLETED_DUE_TO_CAR_LEAVE: 'PARKING_COMPLETED_DUE_TO_CAR_LEAVE',
|
|
635
656
|
NOTIFY_INVITE_MEMBER: 'NOTIFY_INVITE_MEMBER',
|
|
636
657
|
REMINDER: 'REMINDER',
|
|
658
|
+
NOTIFY_INDICATOR: 'NOTIFY_INDICATOR',
|
|
637
659
|
NOTIFY_REMOVE_UNIT: 'NOTIFY_REMOVE_UNIT',
|
|
638
660
|
NOTIFY_REMOVE_MEMBER: 'NOTIFY_REMOVE_MEMBER',
|
|
639
661
|
NOTIFY_MEMBER_LEAVE_UNIT: 'NOTIFY_MEMBER_LEAVE_UNIT',
|
|
640
662
|
NOTIFY_RENAME_UNIT: 'NOTIFY_RENAME_UNIT',
|
|
663
|
+
NOTIFY_DEVICE_DISCONNECT: 'NOTIFY_DEVICE_DISCONNECT',
|
|
664
|
+
NOTIFY_RENAME_SUB_UNIT: 'NOTIFY_RENAME_SUB_UNIT',
|
|
665
|
+
NOTIFY_UPDATE_ADDRESS: 'NOTIFY_UPDATE_ADDRESS',
|
|
641
666
|
};
|
|
642
667
|
|
|
643
668
|
export const ACTIVITY_LOG_TYPES = {
|
package/src/configs/Images.js
CHANGED
|
@@ -11,4 +11,6 @@ export default {
|
|
|
11
11
|
buttonLeftCurtain: require('../Images/Common/buttonLeftCurtain.png'),
|
|
12
12
|
buttonRightCurtain: require('../Images/Common/buttonRightCurtain.png'),
|
|
13
13
|
shadowButton: require('../Images/Common/shadowButton.png'),
|
|
14
|
+
eye: require('../Images/Common/eye.png'),
|
|
15
|
+
eyeClosed: require('../Images/Common/eye-closed.png'),
|
|
14
16
|
};
|
|
@@ -6,6 +6,7 @@ export const Action = {
|
|
|
6
6
|
LIST_ACTION: 'LIST_ACTION',
|
|
7
7
|
IS_FIRST_OPEN_CAMERA: 'IS_FIRST_OPEN_CAMERA',
|
|
8
8
|
IS_LAVIDA_SOURCE: 'IS_LAVIDA_SOURCE',
|
|
9
|
+
IS_CONNECT_WIFI_GATEWAY: 'IS_CONNECT_WIFI_GATEWAY',
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export type AuthData = {
|
|
@@ -50,4 +51,5 @@ export type ActionDataMap = {
|
|
|
50
51
|
export type AppType = {
|
|
51
52
|
isFirstOpenCamera: boolean;
|
|
52
53
|
isLavidaSource: boolean;
|
|
54
|
+
isConnectWifiGateway: boolean;
|
|
53
55
|
};
|
package/src/context/reducer.ts
CHANGED
|
@@ -40,6 +40,7 @@ export const initialState = {
|
|
|
40
40
|
app: {
|
|
41
41
|
isFirstOpenCamera: true,
|
|
42
42
|
isLavidaSource: false,
|
|
43
|
+
isConnectWifiGateway: false,
|
|
43
44
|
},
|
|
44
45
|
};
|
|
45
46
|
|
|
@@ -107,6 +108,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
107
108
|
},
|
|
108
109
|
};
|
|
109
110
|
}
|
|
111
|
+
case Action.IS_CONNECT_WIFI_GATEWAY: {
|
|
112
|
+
return {
|
|
113
|
+
...currentState,
|
|
114
|
+
app: {
|
|
115
|
+
...currentState.app,
|
|
116
|
+
isConnectWifiGateway: payload,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
110
120
|
default:
|
|
111
121
|
return currentState;
|
|
112
122
|
}
|
|
@@ -2,10 +2,12 @@ import { useIsFocused } from '@react-navigation/native';
|
|
|
2
2
|
import { useCallback, useEffect } from 'react';
|
|
3
3
|
import { BackHandler } from 'react-native';
|
|
4
4
|
|
|
5
|
-
export const useBlockBackAndroid = () => {
|
|
5
|
+
export const useBlockBackAndroid = (actionBack) => {
|
|
6
6
|
const focused = useIsFocused();
|
|
7
7
|
const blockBack = useCallback(() => {
|
|
8
|
+
actionBack && actionBack();
|
|
8
9
|
return true;
|
|
10
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9
11
|
}, []);
|
|
10
12
|
useEffect(() => {
|
|
11
13
|
if (focused) {
|