@eohjsc/react-native-smart-city 0.3.6 → 0.3.9
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 +2 -2
- package/src/commons/Device/ItemDevice.js +17 -3
- package/src/commons/MediaPlayerDetail/index.js +1 -0
- package/src/configs/Constants.js +4 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/mockStore.ts +1 -0
- package/src/context/reducer.ts +13 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +3 -3
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +2 -1
- package/src/hooks/IoT/useGGHomeConnection.js +2 -0
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -25
- package/src/screens/Device/detail.js +6 -3
- package/src/screens/PlayBackCamera/index.js +35 -32
- package/src/screens/Unit/Detail.js +7 -6
- package/src/screens/Unit/__test__/Detail.test.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.09",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
"react-native-udp": "^4.1.3",
|
|
194
194
|
"react-native-unimodules": "^0.11.0",
|
|
195
195
|
"react-native-version-check": "^3.4.2",
|
|
196
|
-
"react-native-vlc-media-player": "^1.0.
|
|
196
|
+
"react-native-vlc-media-player": "^1.0.41",
|
|
197
197
|
"react-native-webview": "11.17.2",
|
|
198
198
|
"react-native-wheel-color-picker": "^1.2.0",
|
|
199
199
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
@@ -39,7 +39,8 @@ const ItemDevice = memo(
|
|
|
39
39
|
const isNetworkConnected = useSCContextSelector(
|
|
40
40
|
(state) => state.app.isNetworkConnected
|
|
41
41
|
);
|
|
42
|
-
const { isConnected: isGGHomeConnected } =
|
|
42
|
+
const { isConnected: isGGHomeConnected, isConnecting: isGGHomeConnecting } =
|
|
43
|
+
useGGHomeDeviceConnected(sensor);
|
|
43
44
|
|
|
44
45
|
const goToSensorDisplay = useCallback(() => {
|
|
45
46
|
navigation.navigate(Routes.DeviceDetail, {
|
|
@@ -68,8 +69,21 @@ const ItemDevice = memo(
|
|
|
68
69
|
: isGGHomeConnected
|
|
69
70
|
: isConnectedViaInternet || isConnectedViaBLE;
|
|
70
71
|
|
|
71
|
-
const
|
|
72
|
-
|
|
72
|
+
const isConnecting =
|
|
73
|
+
!!sensor &&
|
|
74
|
+
sensor?.is_other_device &&
|
|
75
|
+
sensor?.device_type !== DEVICE_TYPE.LG_THINQ
|
|
76
|
+
? isGGHomeConnecting
|
|
77
|
+
: false;
|
|
78
|
+
|
|
79
|
+
const borderColor =
|
|
80
|
+
isConnected || isConnecting ? Colors.Gray4 : Colors.Red6;
|
|
81
|
+
|
|
82
|
+
const textConnected = isConnected
|
|
83
|
+
? t('connected')
|
|
84
|
+
: isConnecting
|
|
85
|
+
? ''
|
|
86
|
+
: t('disconnected');
|
|
73
87
|
|
|
74
88
|
return (
|
|
75
89
|
<TouchableWithoutFeedback
|
package/src/configs/Constants.js
CHANGED
|
@@ -69,6 +69,7 @@ export const Constants = {
|
|
|
69
69
|
FONT_PREFIX,
|
|
70
70
|
isIphoneX,
|
|
71
71
|
DEEP_LINK,
|
|
72
|
+
URL_STREAM_BALCONY_CAMERA,
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
export const DEVICE_TYPE = {
|
|
@@ -829,3 +830,6 @@ export const PROBLEM_CODE = {
|
|
|
829
830
|
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
830
831
|
CANCEL_ERROR: 'CANCEL_ERROR',
|
|
831
832
|
};
|
|
833
|
+
|
|
834
|
+
const URL_STREAM_BALCONY_CAMERA =
|
|
835
|
+
'rtsp://admin:Eoh@2020@101.99.33.220:30554/main';
|
|
@@ -17,6 +17,7 @@ export const Action = {
|
|
|
17
17
|
SET_STARRED_SCRIPTS: 'SET_STARRED_SCRIPTS',
|
|
18
18
|
STAR_SCRIPT: 'STAR_SCRIPT',
|
|
19
19
|
UNSTAR_SCRIPT: 'UNSTAR_SCRIPT',
|
|
20
|
+
CONNECTING_GOOGLE_HOME: 'CONNECTING_GOOGLE_HOME',
|
|
20
21
|
SET_GOOGLE_HOME_CONNECTIONS: 'SET_GOOGLE_HOME_CONNECTIONS',
|
|
21
22
|
CHANGE_GOOGLE_HOME_CONN_STATE: 'CHANGE_GOOGLE_HOME_CONN_STATE',
|
|
22
23
|
};
|
|
@@ -79,6 +80,7 @@ export type AppType = {
|
|
|
79
80
|
|
|
80
81
|
export type IoTType = {
|
|
81
82
|
googlehome: {
|
|
83
|
+
isConnecting: boolean;
|
|
82
84
|
connections: {};
|
|
83
85
|
};
|
|
84
86
|
};
|
package/src/context/mockStore.ts
CHANGED
package/src/context/reducer.ts
CHANGED
|
@@ -256,6 +256,7 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
256
256
|
...currentState.iot,
|
|
257
257
|
googlehome: {
|
|
258
258
|
...currentState.iot.googlehome,
|
|
259
|
+
isConnecting: false,
|
|
259
260
|
connections: payload,
|
|
260
261
|
},
|
|
261
262
|
},
|
|
@@ -267,6 +268,7 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
267
268
|
...currentState.iot,
|
|
268
269
|
googlehome: {
|
|
269
270
|
...currentState.iot.googlehome,
|
|
271
|
+
isConnecting: false,
|
|
270
272
|
connections: {
|
|
271
273
|
...currentState.iot.googlehome.connections,
|
|
272
274
|
[payload.option.chip_id]: payload.data,
|
|
@@ -274,6 +276,17 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
274
276
|
},
|
|
275
277
|
},
|
|
276
278
|
};
|
|
279
|
+
case Action.CONNECTING_GOOGLE_HOME:
|
|
280
|
+
return {
|
|
281
|
+
...currentState,
|
|
282
|
+
iot: {
|
|
283
|
+
...currentState.iot,
|
|
284
|
+
googlehome: {
|
|
285
|
+
...currentState.iot.googlehome,
|
|
286
|
+
isConnecting: true,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
277
290
|
|
|
278
291
|
default:
|
|
279
292
|
return currentState;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useSCContextSelector } from '../../context';
|
|
2
2
|
|
|
3
3
|
const useGGHomeDeviceConnected = (device) => {
|
|
4
|
-
const connections = useSCContextSelector(
|
|
5
|
-
(state) => state.iot.googlehome
|
|
4
|
+
const { connections, isConnecting } = useSCContextSelector(
|
|
5
|
+
(state) => state.iot.googlehome
|
|
6
6
|
);
|
|
7
7
|
|
|
8
8
|
const isConnected =
|
|
@@ -10,7 +10,7 @@ const useGGHomeDeviceConnected = (device) => {
|
|
|
10
10
|
device.chip_id in connections &&
|
|
11
11
|
!!connections[device.chip_id];
|
|
12
12
|
|
|
13
|
-
return { isConnected };
|
|
13
|
+
return { isConnected, isConnecting };
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export default useGGHomeDeviceConnected;
|
|
@@ -167,7 +167,8 @@ describe('Test useGGHomeConnection', () => {
|
|
|
167
167
|
await act(async () => {
|
|
168
168
|
await result.current.connectGoogleHome(options);
|
|
169
169
|
});
|
|
170
|
-
expect(mockedSetAction).toBeCalledTimes(
|
|
170
|
+
expect(mockedSetAction).toBeCalledTimes(3);
|
|
171
|
+
expect(mockedSetAction).toBeCalledWith(Action.CONNECTING_GOOGLE_HOME);
|
|
171
172
|
expect(mockedSetAction).toBeCalledWith(
|
|
172
173
|
Action.SET_GOOGLE_HOME_CONNECTIONS,
|
|
173
174
|
conns
|
|
@@ -63,6 +63,7 @@ const useGGHomeConnection = () => {
|
|
|
63
63
|
|
|
64
64
|
const connectGoogleHome = useCallback(
|
|
65
65
|
async (options) => {
|
|
66
|
+
setAction(Action.CONNECTING_GOOGLE_HOME);
|
|
66
67
|
await googleHomeConnect(
|
|
67
68
|
connections,
|
|
68
69
|
options,
|
|
@@ -71,6 +72,7 @@ const useGGHomeConnection = () => {
|
|
|
71
72
|
onReconnected
|
|
72
73
|
);
|
|
73
74
|
},
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
76
|
[connections, onEstablished, onDisconnected, onReconnected]
|
|
75
77
|
);
|
|
76
78
|
|
|
@@ -2,65 +2,84 @@ import React from 'react';
|
|
|
2
2
|
import { ConnectedViewHeader, DisconnectedView } from '../../../commons/Device';
|
|
3
3
|
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
4
4
|
|
|
5
|
-
export const SensorConnectStatusViewHeader = (
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export const SensorConnectStatusViewHeader = ({
|
|
6
|
+
sensor,
|
|
7
|
+
connectedViaNetwork,
|
|
8
|
+
connectedViaBle,
|
|
9
|
+
isDeviceHasBle,
|
|
10
|
+
connectedViaGGHome,
|
|
11
|
+
isGGHomeConnecting,
|
|
12
|
+
lastUpdated,
|
|
13
|
+
isDisplayTime,
|
|
14
|
+
showWindDirection,
|
|
15
|
+
children,
|
|
16
|
+
}) => {
|
|
17
|
+
const isConnecting =
|
|
18
|
+
!!sensor &&
|
|
19
|
+
sensor?.is_other_device &&
|
|
20
|
+
sensor?.device_type !== DEVICE_TYPE.LG_THINQ
|
|
21
|
+
? isGGHomeConnecting
|
|
22
|
+
: false;
|
|
23
|
+
|
|
24
|
+
if (isConnecting) {
|
|
25
|
+
return <></>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!!sensor && !sensor?.is_other_device) {
|
|
29
|
+
if (connectedViaNetwork) {
|
|
8
30
|
return (
|
|
9
31
|
<>
|
|
10
32
|
<ConnectedViewHeader
|
|
11
|
-
lastUpdated={
|
|
12
|
-
isDisplayTime={
|
|
13
|
-
showWindDirection={
|
|
33
|
+
lastUpdated={lastUpdated}
|
|
34
|
+
isDisplayTime={isDisplayTime}
|
|
35
|
+
showWindDirection={showWindDirection}
|
|
14
36
|
/>
|
|
15
|
-
{
|
|
37
|
+
{children}
|
|
16
38
|
</>
|
|
17
39
|
);
|
|
18
|
-
} else if (
|
|
40
|
+
} else if (connectedViaBle) {
|
|
19
41
|
return (
|
|
20
42
|
<>
|
|
21
43
|
<ConnectedViewHeader
|
|
22
|
-
lastUpdated={
|
|
44
|
+
lastUpdated={lastUpdated}
|
|
23
45
|
type={'Bluetooth'}
|
|
24
|
-
isDisplayTime={
|
|
25
|
-
showWindDirection={
|
|
46
|
+
isDisplayTime={isDisplayTime}
|
|
47
|
+
showWindDirection={showWindDirection}
|
|
26
48
|
/>
|
|
27
|
-
{
|
|
49
|
+
{children}
|
|
28
50
|
</>
|
|
29
51
|
);
|
|
30
52
|
} else {
|
|
31
53
|
return (
|
|
32
|
-
<DisconnectedView
|
|
33
|
-
sensor={props.sensor}
|
|
34
|
-
isDeviceHasBle={props.isDeviceHasBle}
|
|
35
|
-
/>
|
|
54
|
+
<DisconnectedView sensor={sensor} isDeviceHasBle={isDeviceHasBle} />
|
|
36
55
|
);
|
|
37
56
|
}
|
|
38
57
|
} else {
|
|
39
|
-
if (
|
|
58
|
+
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
40
59
|
return (
|
|
41
60
|
<>
|
|
42
|
-
<ConnectedViewHeader lastUpdated={
|
|
43
|
-
{
|
|
61
|
+
<ConnectedViewHeader lastUpdated={lastUpdated} />
|
|
62
|
+
{children}
|
|
44
63
|
</>
|
|
45
64
|
);
|
|
46
65
|
} else {
|
|
47
|
-
if (
|
|
66
|
+
if (connectedViaGGHome) {
|
|
48
67
|
return (
|
|
49
68
|
<>
|
|
50
69
|
<ConnectedViewHeader
|
|
51
|
-
lastUpdated={
|
|
52
|
-
isDisplayTime={
|
|
70
|
+
lastUpdated={lastUpdated}
|
|
71
|
+
isDisplayTime={isDisplayTime}
|
|
53
72
|
type={'GoogleHome'}
|
|
54
73
|
/>
|
|
55
|
-
{
|
|
74
|
+
{children}
|
|
56
75
|
</>
|
|
57
76
|
);
|
|
58
77
|
} else {
|
|
59
78
|
return (
|
|
60
79
|
<DisconnectedView
|
|
61
|
-
sensor={
|
|
80
|
+
sensor={sensor}
|
|
62
81
|
type={'GoogleHome'}
|
|
63
|
-
isDeviceHasBle={
|
|
82
|
+
isDeviceHasBle={isDeviceHasBle}
|
|
64
83
|
/>
|
|
65
84
|
);
|
|
66
85
|
}
|
|
@@ -93,7 +93,8 @@ const DeviceDetail = ({ route }) => {
|
|
|
93
93
|
const isBluetoothEnabled = useSCContextSelector((state) => {
|
|
94
94
|
return state.app.isBluetoothEnabled;
|
|
95
95
|
});
|
|
96
|
-
const { isConnected: isGGHomeConnected } =
|
|
96
|
+
const { isConnected: isGGHomeConnected, isConnecting: isGGHomeConnecting } =
|
|
97
|
+
useGGHomeDeviceConnected(sensor);
|
|
97
98
|
|
|
98
99
|
const isDeviceConnectedViaBle = useMemo(
|
|
99
100
|
() =>
|
|
@@ -568,11 +569,13 @@ const DeviceDetail = ({ route }) => {
|
|
|
568
569
|
return (
|
|
569
570
|
<SensorConnectStatusViewHeader
|
|
570
571
|
sensor={sensor}
|
|
571
|
-
|
|
572
|
-
|
|
572
|
+
connectedViaNetwork={isNetworkConnected && isConnected}
|
|
573
|
+
connectedViaBle={
|
|
573
574
|
(!isNetworkConnected || (isNetworkConnected && !isConnected)) &&
|
|
574
575
|
isDeviceConnectedViaBle
|
|
575
576
|
}
|
|
577
|
+
connectedViaGGHome={isGGHomeConnected}
|
|
578
|
+
isGGHomeConnecting={isGGHomeConnecting}
|
|
576
579
|
lastUpdated={lastUpdated}
|
|
577
580
|
isDisplayTime={isShowSetupEmergencyContact ? false : isDisplayTime}
|
|
578
581
|
showWindDirection={showWindDirection}
|
|
@@ -62,39 +62,42 @@ const PlayBackCamera = () => {
|
|
|
62
62
|
dateTemp = date;
|
|
63
63
|
}, [selected]);
|
|
64
64
|
|
|
65
|
-
const onChangeValue = (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
date[
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
const onChangeValue = useCallback(
|
|
66
|
+
(value, selectedTime) => {
|
|
67
|
+
if (!isFirstTime) {
|
|
68
|
+
const currentTime =
|
|
69
|
+
parseFloat(arrHourTemp[0]) +
|
|
70
|
+
parseFloat(arrHourTemp[1] / 60) +
|
|
71
|
+
parseFloat(arrHourTemp[2] / 3600);
|
|
72
|
+
setPaused(true);
|
|
73
|
+
const t1 = value / 96;
|
|
74
|
+
const t2 = t1.toString().split('.');
|
|
75
|
+
const t3 = parseFloat('0.' + t2[1]) * 60;
|
|
76
|
+
const t4 = t3.toString().split('.');
|
|
77
|
+
const t5 = parseInt(parseFloat('0.' + t4[1]) * 60, 10);
|
|
78
|
+
const h = t2[0] < 10 ? '0' + t2[0] : t2[0];
|
|
79
|
+
const m = t4[0] < 10 ? '0' + t4[0] : t4[0];
|
|
80
|
+
const s = t5 < 10 ? '0' + t5 : t5;
|
|
81
|
+
setHour({ h, m, s });
|
|
82
|
+
if (value + 0.5 > currentTime * 96 && selectedTime === now) {
|
|
83
|
+
setUri(item?.configuration?.uri);
|
|
84
|
+
} else {
|
|
85
|
+
const playback = item?.configuration?.playback || '';
|
|
86
|
+
const date = selectedTime.split('-');
|
|
87
|
+
setUri(
|
|
88
|
+
`${playback.split('=')[0]}=${date[0]}${date[1]}${
|
|
89
|
+
date[2]
|
|
90
|
+
}T${h}${m}${s}Z`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const to = setTimeout(() => {
|
|
94
|
+
setPaused(false);
|
|
95
|
+
clearTimeout(to);
|
|
96
|
+
}, 100);
|
|
91
97
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, 100);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
+
},
|
|
99
|
+
[arrHourTemp, item?.configuration, now]
|
|
100
|
+
);
|
|
98
101
|
|
|
99
102
|
useEffect(() => {
|
|
100
103
|
setPaused(true);
|
|
@@ -7,7 +7,6 @@ import React, {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { AppState, RefreshControl, View } from 'react-native';
|
|
9
9
|
import { useIsFocused } from '@react-navigation/native';
|
|
10
|
-
import { VLCPlayer } from 'react-native-vlc-media-player';
|
|
11
10
|
|
|
12
11
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
13
12
|
import styles from './styles';
|
|
@@ -39,6 +38,7 @@ import SubUnitAutomate from '../../commons/SubUnit/OneTap';
|
|
|
39
38
|
import SubUnitFavorites from '../../commons/SubUnit/Favorites';
|
|
40
39
|
import {
|
|
41
40
|
AUTOMATE_TYPE,
|
|
41
|
+
Constants,
|
|
42
42
|
NOTIFICATION_TYPES,
|
|
43
43
|
TESTID,
|
|
44
44
|
} from '../../configs/Constants';
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
unwatchNotificationData,
|
|
48
48
|
} from '../../utils/Monitor';
|
|
49
49
|
import PreventAccess from '../../commons/PreventAccess';
|
|
50
|
+
import MediaPlayerDetail from '../../commons/MediaPlayerDetail';
|
|
50
51
|
|
|
51
52
|
const UnitDetail = ({ route }) => {
|
|
52
53
|
const t = useTranslations();
|
|
@@ -315,11 +316,11 @@ const UnitDetail = ({ route }) => {
|
|
|
315
316
|
>
|
|
316
317
|
{/* NOTE: This is a trick to fix camera not full screen on first open app */}
|
|
317
318
|
{isFirstOpenCamera && (
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
319
|
+
<MediaPlayerDetail
|
|
320
|
+
uri={Constants.URL_STREAM_BALCONY_CAMERA}
|
|
321
|
+
isPaused={false}
|
|
322
|
+
width={1}
|
|
323
|
+
height={1}
|
|
323
324
|
/>
|
|
324
325
|
)}
|
|
325
326
|
|