@eohjsc/react-native-smart-city 0.2.86 → 0.2.87
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/brightnessBlack.svg +12 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/src/Images/SmartIr/AC.svg +14 -0
- package/src/Images/SmartIr/DIY.svg +3 -0
- package/src/Images/SmartIr/Fan.svg +10 -0
- package/src/Images/SmartIr/Fridge.svg +5 -0
- package/src/Images/SmartIr/TV.svg +10 -0
- package/src/Images/SmartIr/WM.svg +11 -0
- package/src/Images/SmartIr/index.js +7 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +40 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +65 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapperStyles.js +43 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +57 -0
- package/src/commons/ActionGroup/{OnOffSmartLock.js → OnOffSmartLock/OnOffSmartLock.js} +5 -5
- package/src/commons/ActionGroup/{OnOffSmartLockStyle.js → OnOffSmartLock/OnOffSmartLockStyle.js} +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscodeStyles.js +42 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/PasscodeListStyles.js +49 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +66 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +96 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +98 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +62 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +249 -0
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +188 -186
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -1
- package/src/commons/ActionGroup/index.js +1 -1
- package/src/commons/Device/DisconnectedView.js +7 -1
- package/src/commons/Device/LinearChart.js +3 -40
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -2
- package/src/commons/RowItem/index.js +12 -7
- package/src/commons/WheelDateTimePicker/index.js +18 -4
- package/src/configs/API.js +1 -1
- package/src/configs/Colors.js +1 -0
- package/src/configs/Constants.js +11 -0
- package/src/context/mockStore.ts +1 -0
- package/src/iot/RemoteControl/Bluetooth.js +3 -3
- package/src/navigations/SmartIrStack.js +31 -0
- package/src/navigations/SmartLockStack.js +51 -0
- package/src/navigations/UnitStack.js +12 -3
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +77 -55
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +141 -27
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +58 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +26 -2
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +13 -2
- package/src/screens/Device/detail.js +49 -10
- package/src/screens/Device/hooks/useDisconnectedDevice.js +21 -5
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +9 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +3 -2
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -2
- package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +3 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +1 -0
- package/src/screens/Notification/components/NotificationItem.js +16 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +54 -0
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +74 -0
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +64 -0
- package/src/screens/SmartIr/__test__/SmartIr.test.js +1 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +86 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByTypeStyles.js +76 -0
- package/src/screens/SmartIr/components/SelectBrand.js +61 -0
- package/src/screens/SmartIr/components/SelectBrandStyles.js +14 -0
- package/src/screens/SmartIr/components/SelectDeviceType.js +96 -0
- package/src/screens/SmartIr/components/SelectDeviceTypeStyles.js +30 -0
- package/src/screens/SmartIr/index.js +8 -3
- package/src/screens/Unit/Detail.js +7 -3
- package/src/screens/Unit/components/MyUnitDevice/index.js +2 -4
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +38 -9
- package/src/utils/I18n/translations/en.json +24 -1
- package/src/utils/I18n/translations/vi.json +24 -1
- package/src/utils/Route/index.js +9 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
2
|
+
import React, { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
import SelectDeviceType from '../screens/SmartIr/components/SelectDeviceType';
|
|
5
|
+
import SelectBrand from '../screens/SmartIr/components/SelectBrand';
|
|
6
|
+
import GroupButtonByType from '../screens/SmartIr/components/GroupButtonByType/GroupButtonByType';
|
|
7
|
+
import Route from '../utils/Route';
|
|
8
|
+
import { screenOptions } from './utils';
|
|
9
|
+
|
|
10
|
+
const Stack = createStackNavigator();
|
|
11
|
+
|
|
12
|
+
export const SmartIrStack = memo(() => {
|
|
13
|
+
return (
|
|
14
|
+
<Stack.Navigator
|
|
15
|
+
screenOptions={{
|
|
16
|
+
...screenOptions,
|
|
17
|
+
headerShown: false,
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
<Stack.Screen
|
|
21
|
+
name={Route.SelectDeviceType}
|
|
22
|
+
component={SelectDeviceType}
|
|
23
|
+
/>
|
|
24
|
+
<Stack.Screen name={Route.SelectBrand} component={SelectBrand} />
|
|
25
|
+
<Stack.Screen
|
|
26
|
+
name={Route.GroupButtonByType}
|
|
27
|
+
component={GroupButtonByType}
|
|
28
|
+
/>
|
|
29
|
+
</Stack.Navigator>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
2
|
+
import React, { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
import Route from '../utils/Route';
|
|
5
|
+
import { screenOptions } from './utils';
|
|
6
|
+
import SetupGeneratePasscode from '../commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index';
|
|
7
|
+
import AutoLock from '../commons/ActionGroup/OnOffSmartLock/AutoLock/index';
|
|
8
|
+
import PasscodeList from '../commons/ActionGroup/OnOffSmartLock/PasscodeList/index';
|
|
9
|
+
import ItemPasscode from '../commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode';
|
|
10
|
+
|
|
11
|
+
const Stack = createStackNavigator();
|
|
12
|
+
|
|
13
|
+
export const SmartLockStack = memo(() => {
|
|
14
|
+
return (
|
|
15
|
+
<Stack.Navigator
|
|
16
|
+
screenOptions={{
|
|
17
|
+
...screenOptions,
|
|
18
|
+
headerShown: false,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<Stack.Screen
|
|
22
|
+
name={Route.SetupGeneratePasscode}
|
|
23
|
+
component={SetupGeneratePasscode}
|
|
24
|
+
options={{
|
|
25
|
+
headerShown: false,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
<Stack.Screen
|
|
29
|
+
name={Route.AutoLock}
|
|
30
|
+
component={AutoLock}
|
|
31
|
+
options={{
|
|
32
|
+
headerShown: false,
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
<Stack.Screen
|
|
36
|
+
name={Route.PasscodeList}
|
|
37
|
+
component={PasscodeList}
|
|
38
|
+
options={{
|
|
39
|
+
headerShown: false,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
<Stack.Screen
|
|
43
|
+
name={Route.ItemPasscode}
|
|
44
|
+
component={ItemPasscode}
|
|
45
|
+
options={{
|
|
46
|
+
headerShown: false,
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</Stack.Navigator>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -117,12 +117,16 @@ export const UnitStack = memo((props) => {
|
|
|
117
117
|
component={ChooseLocation}
|
|
118
118
|
options={{
|
|
119
119
|
headerShown: true,
|
|
120
|
+
headerTitleStyle: {
|
|
121
|
+
...styles.headerLocation,
|
|
122
|
+
},
|
|
120
123
|
headerTitle: () => (
|
|
121
|
-
<View style={styles.
|
|
124
|
+
<View style={styles.headerLocation}>
|
|
122
125
|
<Text type="H3" color={Colors.Gray9} bold>
|
|
123
126
|
{t('choose_on_map')}
|
|
124
127
|
</Text>
|
|
125
|
-
|
|
128
|
+
|
|
129
|
+
<Text type="H4" color={Colors.Gray8} style={styles.headerContent}>
|
|
126
130
|
{t('plan_and_zoom_to_adjust')}
|
|
127
131
|
</Text>
|
|
128
132
|
</View>
|
|
@@ -323,7 +327,12 @@ const styles = StyleSheet.create({
|
|
|
323
327
|
icLeft: {
|
|
324
328
|
marginLeft: Device.isIOS ? 8 : 0,
|
|
325
329
|
},
|
|
326
|
-
|
|
330
|
+
headerLocation: {
|
|
327
331
|
alignItems: 'center',
|
|
332
|
+
justifyContent: 'center',
|
|
333
|
+
},
|
|
334
|
+
headerContent: {
|
|
335
|
+
textAlign: 'center',
|
|
336
|
+
paddingBottom: 8,
|
|
328
337
|
},
|
|
329
338
|
});
|
|
@@ -152,7 +152,7 @@ describe('Test SelectSubUnit container', () => {
|
|
|
152
152
|
case 'AddVconnexDevice':
|
|
153
153
|
expect(mockedNavigate).toBeCalledWith('Browser', {
|
|
154
154
|
// eslint-disable-next-line max-len
|
|
155
|
-
link: 'https://partner-api
|
|
155
|
+
link: 'https://partner-api.vconnex.vn/oauth/authorize?client_id=&redirect_uri=&response_type=code&scope=SYNCH&scope=CONTROL&scope=QUERY&state=undefined@undefined@undefined',
|
|
156
156
|
});
|
|
157
157
|
break;
|
|
158
158
|
case 'AddDeviceNewFlow':
|
|
@@ -27,6 +27,9 @@ import Routes from '../../../utils/Route';
|
|
|
27
27
|
import { SCContext } from '../../../context';
|
|
28
28
|
import { Action } from '../../../context/actionType';
|
|
29
29
|
|
|
30
|
+
const isIos = Platform.OS === 'ios';
|
|
31
|
+
const isAndroid = Platform.OS === 'android';
|
|
32
|
+
|
|
30
33
|
const ConnectWifiWarning = memo(({ route }) => {
|
|
31
34
|
const {
|
|
32
35
|
wifi_ssid,
|
|
@@ -60,74 +63,93 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
60
63
|
}, [t]);
|
|
61
64
|
|
|
62
65
|
useEffect(() => {
|
|
63
|
-
|
|
66
|
+
isAndroid && getPermissionWifiAndroid();
|
|
64
67
|
}, [getPermissionWifiAndroid]);
|
|
65
68
|
|
|
66
|
-
const handleSend = () => {
|
|
69
|
+
const handleSend = async () => {
|
|
67
70
|
const socket = dgram.createSocket({ type: 'udp4' });
|
|
68
|
-
socket.bind(54321);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
await socket.bind(54321);
|
|
72
|
+
let intervalSend = null;
|
|
73
|
+
if (isIos) {
|
|
74
|
+
intervalSend = setInterval(() => {
|
|
75
|
+
socket.send(
|
|
76
|
+
JSON.stringify({ type: 'scan', data: { wifi: '' } }),
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
54321,
|
|
80
|
+
'192.168.27.1',
|
|
81
|
+
undefined
|
|
82
|
+
);
|
|
83
|
+
}, 1000);
|
|
84
|
+
} else {
|
|
85
|
+
await socket.once('listening', async () => {
|
|
86
|
+
await socket.send(
|
|
87
|
+
JSON.stringify({ type: 'scan', data: { wifi: '' } }),
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
54321,
|
|
91
|
+
'192.168.27.1',
|
|
92
|
+
undefined
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
await socket.on('message', (msg, rinfo) => {
|
|
98
|
+
isIos && clearInterval(intervalSend);
|
|
80
99
|
const data = JSON.parse(msg.toString());
|
|
81
100
|
if (data.hasOwnProperty('wifi')) {
|
|
82
101
|
navigate(Routes.GatewayWifiList, {
|
|
83
102
|
list_wifi: data.wifi,
|
|
84
103
|
unit_id: unit_id,
|
|
85
104
|
chip_id: chip_id,
|
|
105
|
+
scan_sensor_data: { ...body },
|
|
106
|
+
wifi_ssid: wifi_ssid,
|
|
107
|
+
wifi_pass: wifi_pass,
|
|
108
|
+
unit_name: unit_name,
|
|
109
|
+
devicePrefixName: devicePrefixName,
|
|
86
110
|
socket: socket,
|
|
87
111
|
});
|
|
88
112
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
clearInterval(checkWifiInterval);
|
|
113
|
+
if (isIos) {
|
|
114
|
+
if (data.hasOwnProperty('gateway')) {
|
|
115
|
+
const checkWifiInterval = setInterval(() => {
|
|
116
|
+
WifiManager.getCurrentWifiSSID().then((ssid) => {
|
|
117
|
+
if (ssid !== wifi_ssid) {
|
|
118
|
+
const IsRobot = devicePrefixName === 'ROBOT';
|
|
119
|
+
if (IsRobot) {
|
|
120
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
121
|
+
navigate(Routes.AddDeviceStack, {
|
|
122
|
+
screen: Routes.AddCommonSelectSubUnit,
|
|
123
|
+
params: {
|
|
124
|
+
scan_sensor_data: { ...body },
|
|
125
|
+
addType: 'AddDeviceNewFlow',
|
|
126
|
+
gateway: data?.gateway,
|
|
127
|
+
unit_id: unit_id,
|
|
128
|
+
devicePrefixName: devicePrefixName,
|
|
129
|
+
wifi_ssid: wifi_ssid,
|
|
130
|
+
wifi_pass: wifi_pass,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
clearInterval(checkWifiInterval);
|
|
134
|
+
} else {
|
|
135
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
136
|
+
navigate(Routes.AddDeviceStack, {
|
|
137
|
+
screen: Routes.ConnectingProcess,
|
|
138
|
+
params: {
|
|
139
|
+
unit_id: unit_id,
|
|
140
|
+
unit_name: unit_name,
|
|
141
|
+
scan_sensor_data: { ...body },
|
|
142
|
+
gateway: data?.gateway,
|
|
143
|
+
devicePrefixName: devicePrefixName,
|
|
144
|
+
chip_id: chip_id,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
clearInterval(checkWifiInterval);
|
|
148
|
+
}
|
|
127
149
|
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
150
|
+
});
|
|
151
|
+
}, 3000);
|
|
152
|
+
}
|
|
131
153
|
}
|
|
132
154
|
});
|
|
133
155
|
socket.on('error', () => {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TouchableOpacity,
|
|
12
12
|
ScrollView,
|
|
13
13
|
ActivityIndicator,
|
|
14
|
+
Platform,
|
|
14
15
|
} from 'react-native';
|
|
15
16
|
import { HeaderCustom } from '../../../commons/Header';
|
|
16
17
|
import { Colors } from '../../../configs';
|
|
@@ -21,14 +22,31 @@ import ButtonPopup from '../../../commons/ButtonPopup';
|
|
|
21
22
|
import TextInputPassword from '../../../commons/Form/TextInputPassword';
|
|
22
23
|
import { SCContext, useSCContextSelector } from '../../../context';
|
|
23
24
|
import { Action } from '../../../context/actionType';
|
|
25
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
26
|
+
import Routes from '../../../utils/Route';
|
|
27
|
+
import WifiManager from 'react-native-wifi-reborn';
|
|
28
|
+
import { useNavigation } from '@react-navigation/native';
|
|
29
|
+
|
|
30
|
+
const isIos = Platform.OS === 'ios';
|
|
24
31
|
|
|
25
32
|
const GatewayWifiList = memo(({ route }) => {
|
|
26
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
list_wifi,
|
|
35
|
+
socket,
|
|
36
|
+
unit_name,
|
|
37
|
+
wifi_pass,
|
|
38
|
+
wifi_ssid,
|
|
39
|
+
scan_sensor_data,
|
|
40
|
+
unit_id,
|
|
41
|
+
chip_id,
|
|
42
|
+
devicePrefixName,
|
|
43
|
+
} = route.params;
|
|
27
44
|
const t = useTranslations();
|
|
28
|
-
|
|
45
|
+
const { navigate, goBack } = useNavigation();
|
|
29
46
|
const [isShowPopupPassword, setIsShowPopupPassword] = useState(false);
|
|
30
47
|
const [password, setPassword] = useState('');
|
|
31
48
|
const [selectedWifi, setSelectedWifi] = useState('');
|
|
49
|
+
const [isSendWifi, setIsSendWifi] = useState(false);
|
|
32
50
|
const { setAction } = useContext(SCContext);
|
|
33
51
|
|
|
34
52
|
const isConnectWifiGateway = useSCContextSelector(
|
|
@@ -42,31 +60,136 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
42
60
|
|
|
43
61
|
const onPasswordChange = useCallback(
|
|
44
62
|
(password) => {
|
|
45
|
-
setPassword(password
|
|
63
|
+
setPassword(password?.toString());
|
|
46
64
|
},
|
|
47
65
|
[setPassword]
|
|
48
66
|
);
|
|
67
|
+
|
|
68
|
+
const sendConnect = useCallback(
|
|
69
|
+
(i) => {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
i++;
|
|
72
|
+
socket.send(
|
|
73
|
+
JSON.stringify({
|
|
74
|
+
type: 'connect',
|
|
75
|
+
data: { wifi: { ssid: selectedWifi, pass: password } },
|
|
76
|
+
}),
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
54321,
|
|
80
|
+
'192.168.27.1',
|
|
81
|
+
undefined
|
|
82
|
+
);
|
|
83
|
+
if (i < 3) {
|
|
84
|
+
sendConnect(i);
|
|
85
|
+
}
|
|
86
|
+
}, 1000);
|
|
87
|
+
},
|
|
88
|
+
[password, selectedWifi, socket]
|
|
89
|
+
);
|
|
90
|
+
|
|
49
91
|
const connectWifi = useCallback(async () => {
|
|
50
92
|
if (!isConnectWifiGateway) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
if (isIos) {
|
|
94
|
+
sendConnect(1);
|
|
95
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, true);
|
|
96
|
+
setIsSendWifi(true);
|
|
97
|
+
} else {
|
|
98
|
+
await socket.send(
|
|
99
|
+
JSON.stringify({
|
|
100
|
+
type: 'connect',
|
|
101
|
+
data: { wifi: { ssid: selectedWifi, pass: password } },
|
|
102
|
+
}),
|
|
103
|
+
undefined,
|
|
104
|
+
undefined,
|
|
105
|
+
54321,
|
|
106
|
+
'192.168.27.1',
|
|
107
|
+
undefined
|
|
108
|
+
);
|
|
109
|
+
await socket.on('message', (msg, rinfo) => {
|
|
110
|
+
const data = JSON.parse(msg.toString());
|
|
111
|
+
if (data.hasOwnProperty('gateway')) {
|
|
112
|
+
const checkWifiInterval = setInterval(() => {
|
|
113
|
+
WifiManager.getCurrentWifiSSID().then((ssid) => {
|
|
114
|
+
if (ssid !== wifi_ssid) {
|
|
115
|
+
const IsRobot = devicePrefixName === 'ROBOT';
|
|
116
|
+
if (IsRobot) {
|
|
117
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
118
|
+
navigate(Routes.AddDeviceStack, {
|
|
119
|
+
screen: Routes.AddCommonSelectSubUnit,
|
|
120
|
+
params: {
|
|
121
|
+
scan_sensor_data: scan_sensor_data,
|
|
122
|
+
addType: 'AddDeviceNewFlow',
|
|
123
|
+
gateway: data?.gateway,
|
|
124
|
+
unit_id: unit_id,
|
|
125
|
+
devicePrefixName: devicePrefixName,
|
|
126
|
+
wifi_ssid: wifi_ssid,
|
|
127
|
+
wifi_pass: wifi_pass,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
clearInterval(checkWifiInterval);
|
|
131
|
+
} else {
|
|
132
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
133
|
+
navigate(Routes.AddDeviceStack, {
|
|
134
|
+
screen: Routes.ConnectingProcess,
|
|
135
|
+
params: {
|
|
136
|
+
unit_id: unit_id,
|
|
137
|
+
unit_name: unit_name,
|
|
138
|
+
scan_sensor_data: scan_sensor_data,
|
|
139
|
+
gateway: data?.gateway,
|
|
140
|
+
devicePrefixName: devicePrefixName,
|
|
141
|
+
chip_id: chip_id,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
clearInterval(checkWifiInterval);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}, 3000);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
socket.on('error', () => {
|
|
152
|
+
ToastBottomHelper.error(t('server_error'));
|
|
153
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
154
|
+
goBack();
|
|
155
|
+
});
|
|
156
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, true);
|
|
157
|
+
setIsSendWifi(true);
|
|
158
|
+
}
|
|
63
159
|
}
|
|
64
|
-
}, [
|
|
160
|
+
}, [
|
|
161
|
+
chip_id,
|
|
162
|
+
devicePrefixName,
|
|
163
|
+
goBack,
|
|
164
|
+
isConnectWifiGateway,
|
|
165
|
+
navigate,
|
|
166
|
+
password,
|
|
167
|
+
scan_sensor_data,
|
|
168
|
+
selectedWifi,
|
|
169
|
+
sendConnect,
|
|
170
|
+
setAction,
|
|
171
|
+
socket,
|
|
172
|
+
t,
|
|
173
|
+
unit_id,
|
|
174
|
+
unit_name,
|
|
175
|
+
wifi_pass,
|
|
176
|
+
wifi_ssid,
|
|
177
|
+
]);
|
|
178
|
+
|
|
65
179
|
useEffect(() => {
|
|
66
180
|
if (!isConnectWifiGateway) {
|
|
67
181
|
setIsShowPopupPassword(false);
|
|
68
182
|
}
|
|
69
183
|
}, [isConnectWifiGateway]);
|
|
184
|
+
|
|
185
|
+
const onCloseModal = useCallback(() => {
|
|
186
|
+
if (isSendWifi) {
|
|
187
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
188
|
+
setIsShowPopupPassword(false);
|
|
189
|
+
setIsSendWifi(false);
|
|
190
|
+
}
|
|
191
|
+
}, [isSendWifi, setAction]);
|
|
192
|
+
|
|
70
193
|
return (
|
|
71
194
|
<View style={styles.screen}>
|
|
72
195
|
<HeaderCustom title={t('connect_device')} isShowSeparator />
|
|
@@ -110,7 +233,8 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
110
233
|
secondaryTitle={t('cancel')}
|
|
111
234
|
typeSecondary={isConnectWifiGateway ? 'disabled' : 'cancel'}
|
|
112
235
|
onPressSecondary={() => setIsShowPopupPassword(false)}
|
|
113
|
-
hideClose
|
|
236
|
+
hideClose
|
|
237
|
+
onClose={isSendWifi ? onCloseModal : () => <></>}
|
|
114
238
|
>
|
|
115
239
|
<>
|
|
116
240
|
<Text>{t('enter_wifi_password')}</Text>
|
|
@@ -160,16 +284,6 @@ const styles = StyleSheet.create({
|
|
|
160
284
|
paddingVertical: 16,
|
|
161
285
|
paddingLeft: 16,
|
|
162
286
|
},
|
|
163
|
-
firstItem: {
|
|
164
|
-
paddingTop: 32,
|
|
165
|
-
paddingBottom: 16,
|
|
166
|
-
paddingLeft: 16,
|
|
167
|
-
},
|
|
168
|
-
lastItem: {
|
|
169
|
-
paddingBottom: 32,
|
|
170
|
-
paddingTop: 16,
|
|
171
|
-
paddingLeft: 16,
|
|
172
|
-
},
|
|
173
287
|
wifiIcon: {
|
|
174
288
|
paddingRight: 16,
|
|
175
289
|
},
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import ConnectWifiWarning from '../ConnectWifiWarning';
|
|
5
|
+
import { SCProvider } from '../../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
+
import { HeaderCustom } from '../../../../commons/Header';
|
|
8
|
+
|
|
9
|
+
const mockedGoBack = jest.fn();
|
|
10
|
+
const mockedNavigate = jest.fn();
|
|
11
|
+
const mockSetState = jest.fn();
|
|
12
|
+
jest.mock('react', () => {
|
|
13
|
+
return {
|
|
14
|
+
...jest.requireActual('react'),
|
|
15
|
+
memo: (x) => x,
|
|
16
|
+
useState: jest.fn((init) => [init, mockSetState]),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
jest.mock('@react-navigation/native', () => {
|
|
20
|
+
return {
|
|
21
|
+
...jest.requireActual('@react-navigation/native'),
|
|
22
|
+
useNavigation: () => ({
|
|
23
|
+
navigate: mockedNavigate,
|
|
24
|
+
goBack: mockedGoBack,
|
|
25
|
+
}),
|
|
26
|
+
useIsFocused: () => ({}),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const wrapComponent = (route) => (
|
|
31
|
+
<SCProvider initState={mockSCStore({})}>
|
|
32
|
+
<ConnectWifiWarning route={route} />
|
|
33
|
+
</SCProvider>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
describe('Test ConnectWifiWarning', () => {
|
|
37
|
+
let tree;
|
|
38
|
+
let route = {
|
|
39
|
+
params: {
|
|
40
|
+
wifi_ssid: 1,
|
|
41
|
+
wifi_pass: 'abc',
|
|
42
|
+
unit_id: 1,
|
|
43
|
+
chip_id: 1,
|
|
44
|
+
devicePrefixName: 'robot',
|
|
45
|
+
body: { wifi_ssid: 1 },
|
|
46
|
+
unit_name: 'abc',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
test('create ConnectWifiWarning', async () => {
|
|
51
|
+
await act(async () => {
|
|
52
|
+
tree = await create(wrapComponent(route));
|
|
53
|
+
});
|
|
54
|
+
const instance = tree.root;
|
|
55
|
+
const headerCustom = instance.findAllByType(HeaderCustom);
|
|
56
|
+
expect(headerCustom).toHaveLength(1);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
|
|
4
3
|
import GatewayWifiList from '../GatewayWifiList';
|
|
5
|
-
import { Text } from 'react-native';
|
|
4
|
+
import { Text, ScrollView, TouchableOpacity } from 'react-native';
|
|
6
5
|
import { getTranslate } from '../../../../utils/I18n';
|
|
7
6
|
import { SCProvider } from '../../../../context';
|
|
8
7
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
+
import TextInputPassword from '../../../../commons/Form/TextInputPassword';
|
|
9
9
|
|
|
10
10
|
const wrapComponent = (route) => (
|
|
11
11
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -32,4 +32,28 @@ describe('Test GatewayWifiList', () => {
|
|
|
32
32
|
expect(texts[1].props.children).toEqual(getTranslate('en', 'set_network'));
|
|
33
33
|
expect(texts[3].props.children).toEqual('eoh@io');
|
|
34
34
|
});
|
|
35
|
+
test('onPress wifi', async () => {
|
|
36
|
+
await act(async () => {
|
|
37
|
+
tree = await create(wrapComponent(route));
|
|
38
|
+
});
|
|
39
|
+
const instance = tree.root;
|
|
40
|
+
const scrollView = instance.findAllByType(ScrollView);
|
|
41
|
+
expect(scrollView).toHaveLength(1);
|
|
42
|
+
const touchableOpacity = instance.findAllByType(TouchableOpacity);
|
|
43
|
+
expect(touchableOpacity).toHaveLength(6);
|
|
44
|
+
await act(async () => {
|
|
45
|
+
await touchableOpacity[1].props.onPress();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
test('onChange TextInputPassword', async () => {
|
|
49
|
+
await act(async () => {
|
|
50
|
+
tree = await create(wrapComponent(route));
|
|
51
|
+
});
|
|
52
|
+
const instance = tree.root;
|
|
53
|
+
const textInputPassword = instance.findAllByType(TextInputPassword);
|
|
54
|
+
expect(textInputPassword).toHaveLength(1);
|
|
55
|
+
await act(async () => {
|
|
56
|
+
await textInputPassword[0].props.onChange();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
35
59
|
});
|
|
@@ -28,7 +28,12 @@ export const SensorConnectStatusViewHeader = (props) => {
|
|
|
28
28
|
</>
|
|
29
29
|
);
|
|
30
30
|
} else {
|
|
31
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<DisconnectedView
|
|
33
|
+
sensor={props.sensor}
|
|
34
|
+
isDeviceHasBle={props.isDeviceHasBle}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
32
37
|
}
|
|
33
38
|
} else {
|
|
34
39
|
if (props.sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
@@ -50,7 +55,13 @@ export const SensorConnectStatusViewHeader = (props) => {
|
|
|
50
55
|
</>
|
|
51
56
|
);
|
|
52
57
|
} else {
|
|
53
|
-
return
|
|
58
|
+
return (
|
|
59
|
+
<DisconnectedView
|
|
60
|
+
sensor={props.sensor}
|
|
61
|
+
type={'GoogleHome'}
|
|
62
|
+
isDeviceHasBle={props.isDeviceHasBle}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
67
|
}
|