@eohjsc/react-native-smart-city 0.2.87 → 0.2.90
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/Common/Calendar.svg +3 -0
- package/assets/images/Common/SmartPhone.svg +3 -0
- package/assets/images/Hanet/CaptureFaceID.svg +25 -0
- package/assets/images/Hanet/FaceFrame.svg +6 -0
- package/package.json +3 -3
- package/src/Images/SmartIr/Remote.svg +15 -0
- package/src/Images/SmartIr/SmartIr.svg +4 -0
- package/src/Images/SmartIr/Union.svg +9 -0
- package/src/Images/SmartIr/index.js +4 -1
- package/src/commons/ActionGroup/ColorPickerTemplate.js +51 -0
- package/src/commons/ActionGroup/ColorPickerTemplateStyles.js +17 -0
- package/src/commons/ActionGroup/SliderRangeTemplate.js +64 -0
- package/src/commons/ActionGroup/{LightActionTemplateStyles.js → SliderRangeTemplateStyles.js} +0 -8
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +47 -68
- package/src/commons/ActionGroup/index.js +6 -3
- package/src/commons/BottomSheet/index.js +2 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.js +109 -0
- package/src/commons/Device/HistoryChart.js +2 -2
- package/src/commons/Device/HorizontalBarChart.js +7 -0
- package/src/commons/Device/ItemDevice.js +18 -15
- package/src/commons/Device/LinearChart.js +11 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -2
- package/src/commons/SubUnit/ShortDetail.js +39 -20
- package/src/configs/API.js +22 -0
- package/src/configs/Constants.js +37 -0
- package/src/configs/SCConfig.js +1 -1
- package/src/context/actionType.ts +4 -0
- package/src/context/mockStore.ts +2 -0
- package/src/context/reducer.ts +20 -0
- package/src/iot/RemoteControl/Bluetooth.js +0 -19
- package/src/iot/RemoteControl/index.js +0 -1
- package/src/navigations/HanetCameraStack.js +41 -0
- package/src/navigations/UnitStack.js +34 -1
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +51 -66
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +68 -54
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +7 -0
- package/src/screens/Device/__test__/detail.test.js +0 -10
- package/src/screens/Device/detail.js +70 -29
- package/src/screens/Device/hooks/useDisconnectedDevice.js +16 -20
- package/src/screens/HanetCamera/CaptureFaceID.js +210 -0
- package/src/screens/HanetCamera/Detail.js +252 -0
- package/src/screens/HanetCamera/ManageAccess.js +173 -0
- package/src/screens/HanetCamera/MemberInfo.js +208 -0
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +133 -0
- package/src/screens/HanetCamera/__test__/Detail.test.js +185 -0
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +152 -0
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +178 -0
- package/src/screens/HanetCamera/components/CheckinHeader.js +37 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +151 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +71 -0
- package/src/screens/HanetCamera/hooks/index.js +5 -0
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +116 -0
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +86 -0
- package/src/screens/HanetCamera/hooks/useStateAlertAction.js +62 -0
- package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +50 -0
- package/src/screens/HanetCamera/styles/checkinHeaderStyles.js +24 -0
- package/src/screens/HanetCamera/styles/detailStyles.js +107 -0
- package/src/screens/HanetCamera/styles/manageAccessStyles.js +49 -0
- package/src/screens/HanetCamera/styles/memberInfoStyles.js +73 -0
- package/src/screens/HanetCamera/utils/Monitor.js +52 -0
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +31 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +35 -9
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +0 -9
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -8
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottom.js +45 -0
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottomStyles.js +31 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +156 -34
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByTypeStyles.js +52 -15
- package/src/screens/Unit/Detail.js +2 -10
- package/src/screens/Unit/__test__/Detail.test.js +0 -10
- package/src/utils/I18n/translations/en.json +28 -1
- package/src/utils/I18n/translations/vi.json +27 -0
- package/src/utils/Route/index.js +5 -0
- package/src/commons/ActionGroup/LightActionTemplate.js +0 -103
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +0 -59
|
@@ -149,6 +149,7 @@ const HorizontalBarChart = memo(({ datas, config }) => {
|
|
|
149
149
|
<HighchartsReactNative
|
|
150
150
|
styles={styles.chartStyle}
|
|
151
151
|
options={chartOptions}
|
|
152
|
+
webviewStyles={styles.webviewStyle}
|
|
152
153
|
/>
|
|
153
154
|
</View>
|
|
154
155
|
);
|
|
@@ -168,4 +169,10 @@ const styles = StyleSheet.create({
|
|
|
168
169
|
backgroundColor: Colors.White,
|
|
169
170
|
flex: 1,
|
|
170
171
|
},
|
|
172
|
+
webviewStyle: {
|
|
173
|
+
flex: 1,
|
|
174
|
+
minHeight: 200,
|
|
175
|
+
height: 300,
|
|
176
|
+
opacity: 0.99,
|
|
177
|
+
},
|
|
171
178
|
});
|
|
@@ -12,16 +12,12 @@ import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
|
12
12
|
import ItemQuickAction from '../../commons/Action/ItemQuickAction';
|
|
13
13
|
import Text from '../../commons/Text';
|
|
14
14
|
import { isDeviceConnected } from '../../iot/RemoteControl/Bluetooth';
|
|
15
|
+
import { useSCContextSelector } from '../../context';
|
|
15
16
|
|
|
16
|
-
import { Colors
|
|
17
|
-
import { TESTID, DEVICE_TYPE } from '../../configs/Constants';
|
|
17
|
+
import { Colors } from '../../configs';
|
|
18
|
+
import { TESTID, DEVICE_TYPE, DEVICE_SIZE } from '../../configs/Constants';
|
|
18
19
|
import FImage from '../../commons/FImage';
|
|
19
20
|
|
|
20
|
-
const marginItem = 12;
|
|
21
|
-
const marginHorizontal = 16;
|
|
22
|
-
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
23
|
-
const heightItem = (widthItem / 166) * 106;
|
|
24
|
-
|
|
25
21
|
const ItemDevice = memo(
|
|
26
22
|
({
|
|
27
23
|
svgMain,
|
|
@@ -30,14 +26,21 @@ const ItemDevice = memo(
|
|
|
30
26
|
sensor,
|
|
31
27
|
unit,
|
|
32
28
|
station,
|
|
33
|
-
isNetworkConnected,
|
|
34
29
|
isGGHomeConnected,
|
|
30
|
+
serverDown,
|
|
35
31
|
status,
|
|
36
32
|
wrapStyle,
|
|
37
33
|
}) => {
|
|
38
34
|
const t = useTranslations();
|
|
39
35
|
const navigation = useNavigation();
|
|
40
36
|
|
|
37
|
+
const isBluetoothEnabled = useSCContextSelector(
|
|
38
|
+
(state) => state.app.isBluetoothEnabled
|
|
39
|
+
);
|
|
40
|
+
const isNetworkConnected = useSCContextSelector(
|
|
41
|
+
(state) => state.app.isNetworkConnected
|
|
42
|
+
);
|
|
43
|
+
|
|
41
44
|
const goToSensorDisplay = useCallback(() => {
|
|
42
45
|
navigation.navigate(Routes.DeviceDetail, {
|
|
43
46
|
unitData: unit,
|
|
@@ -59,11 +62,11 @@ const ItemDevice = memo(
|
|
|
59
62
|
|
|
60
63
|
const isConnectedViaInternet =
|
|
61
64
|
status === undefined
|
|
62
|
-
? isNetworkConnected && sensor.is_connected
|
|
63
|
-
: isNetworkConnected && status.is_connected;
|
|
64
|
-
const isConnectedViaBLE =
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
? !serverDown && isNetworkConnected && sensor.is_connected
|
|
66
|
+
: !serverDown && isNetworkConnected && status.is_connected;
|
|
67
|
+
const isConnectedViaBLE =
|
|
68
|
+
isBluetoothEnabled &&
|
|
69
|
+
isDeviceConnected(sensor?.remote_control_options?.bluetooth?.address);
|
|
67
70
|
const isConnectedViaGGHome =
|
|
68
71
|
!!sensor &&
|
|
69
72
|
sensor?.is_other_device &&
|
|
@@ -129,8 +132,8 @@ const styles = StyleSheet.create({
|
|
|
129
132
|
shadowOpacity: 0.1,
|
|
130
133
|
shadowRadius: 3,
|
|
131
134
|
elevation: 4,
|
|
132
|
-
width:
|
|
133
|
-
height:
|
|
135
|
+
width: DEVICE_SIZE.width,
|
|
136
|
+
height: DEVICE_SIZE.height,
|
|
134
137
|
backgroundColor: Colors.White,
|
|
135
138
|
justifyContent: 'space-between',
|
|
136
139
|
marginBottom: 8,
|
|
@@ -89,7 +89,11 @@ function LinearChart({ datas }) {
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<View style={styles.container}>
|
|
92
|
-
<HighchartsReactNative
|
|
92
|
+
<HighchartsReactNative
|
|
93
|
+
styles={styles.chartStyle}
|
|
94
|
+
webviewStyles={styles.webviewStyle}
|
|
95
|
+
options={options}
|
|
96
|
+
/>
|
|
93
97
|
</View>
|
|
94
98
|
);
|
|
95
99
|
}
|
|
@@ -108,4 +112,10 @@ const styles = StyleSheet.create({
|
|
|
108
112
|
backgroundColor: Colors.White,
|
|
109
113
|
flex: 1,
|
|
110
114
|
},
|
|
115
|
+
webviewStyle: {
|
|
116
|
+
flex: 1,
|
|
117
|
+
minHeight: 200,
|
|
118
|
+
height: 300,
|
|
119
|
+
opacity: 0.99,
|
|
120
|
+
},
|
|
111
121
|
});
|
|
@@ -15,7 +15,7 @@ const SubUnitFavorites = ({
|
|
|
15
15
|
unit,
|
|
16
16
|
isOwner,
|
|
17
17
|
favorites,
|
|
18
|
-
|
|
18
|
+
serverDown,
|
|
19
19
|
isGGHomeConnected,
|
|
20
20
|
wrapItemStyle,
|
|
21
21
|
}) => {
|
|
@@ -72,8 +72,8 @@ const SubUnitFavorites = ({
|
|
|
72
72
|
sensor={sensor}
|
|
73
73
|
unit={unit}
|
|
74
74
|
station={sensor.station}
|
|
75
|
-
isNetworkConnected={isNetworkConnected}
|
|
76
75
|
isGGHomeConnected={isGGHomeConnected}
|
|
76
|
+
serverDown={serverDown}
|
|
77
77
|
status={sensorsStatus.find((s) => s.id === sensor.id)}
|
|
78
78
|
wrapStyle={wrapItemStyle}
|
|
79
79
|
/>
|
|
@@ -4,10 +4,11 @@ import { useNavigation, useIsFocused } from '@react-navigation/native';
|
|
|
4
4
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
5
|
|
|
6
6
|
import { Images, Device, API } from '../../configs';
|
|
7
|
-
import { TESTID } from '../../configs/Constants';
|
|
7
|
+
import { DEVICE_TYPE, TESTID } from '../../configs/Constants';
|
|
8
8
|
import { Section } from '../Section';
|
|
9
9
|
import Text from '../Text';
|
|
10
10
|
import ItemDevice from '../Device/ItemDevice';
|
|
11
|
+
import ItemHanetDevice from '../Device/Hanet/ItemHanetDevice';
|
|
11
12
|
import ItemAddNew from '../Device/ItemAddNew';
|
|
12
13
|
import { standardizeCameraScreenSize } from '../../utils/Utils';
|
|
13
14
|
import Routes from '../../utils/Route';
|
|
@@ -22,7 +23,7 @@ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
|
|
|
22
23
|
const ShortDetailSubUnit = ({
|
|
23
24
|
unit,
|
|
24
25
|
station,
|
|
25
|
-
|
|
26
|
+
serverDown,
|
|
26
27
|
isGGHomeConnected,
|
|
27
28
|
}) => {
|
|
28
29
|
const t = useTranslations();
|
|
@@ -126,24 +127,42 @@ const ShortDetailSubUnit = ({
|
|
|
126
127
|
|
|
127
128
|
<View style={styles.boxDevices}>
|
|
128
129
|
{!!station.sensors &&
|
|
129
|
-
station.sensors.map((sensor, index) =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
130
|
+
station.sensors.map((sensor, index) => {
|
|
131
|
+
switch (sensor.device_type) {
|
|
132
|
+
case DEVICE_TYPE.HANET:
|
|
133
|
+
return (
|
|
134
|
+
<ItemHanetDevice
|
|
135
|
+
key={`sensor-${sensor.id}`}
|
|
136
|
+
id={sensor.id}
|
|
137
|
+
svgMain={sensor.icon || 'sensor'}
|
|
138
|
+
title={sensor.name}
|
|
139
|
+
index={index}
|
|
140
|
+
sensor={sensor}
|
|
141
|
+
unit={unit}
|
|
142
|
+
station={station}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
default:
|
|
146
|
+
return (
|
|
147
|
+
<ItemDevice
|
|
148
|
+
key={`sensor-${sensor.id}`}
|
|
149
|
+
id={sensor.id}
|
|
150
|
+
svgMain={sensor.icon || 'sensor'}
|
|
151
|
+
statusIcon={sensor.action && sensor.action.icon}
|
|
152
|
+
statusColor={sensor.action && sensor.action.color}
|
|
153
|
+
description={sensor.value}
|
|
154
|
+
title={sensor.name}
|
|
155
|
+
index={index}
|
|
156
|
+
sensor={sensor}
|
|
157
|
+
unit={unit}
|
|
158
|
+
station={station}
|
|
159
|
+
isGGHomeConnected={isGGHomeConnected}
|
|
160
|
+
serverDown={serverDown}
|
|
161
|
+
status={sensorsStatus.find((s) => s.id === sensor.id)}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
})}
|
|
147
166
|
<ItemAddNew title={t('add_new_device')} onAddNew={handleOnAddNew} />
|
|
148
167
|
</View>
|
|
149
168
|
</Section>
|
package/src/configs/API.js
CHANGED
|
@@ -187,6 +187,28 @@ const API = {
|
|
|
187
187
|
`https://partner-api.vconnex.vn/oauth/authorize?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=code&scope=SYNCH&scope=CONTROL&scope=QUERY&state=${user_id}@${unit_id}@${station_id}`,
|
|
188
188
|
},
|
|
189
189
|
},
|
|
190
|
+
CAMERA: {
|
|
191
|
+
HANET: {
|
|
192
|
+
CHECKIN: (device_id) =>
|
|
193
|
+
SCConfig.apiRoot +
|
|
194
|
+
`/camera_manager/hanet/cameras/${device_id}/checkin/`,
|
|
195
|
+
PLACE_MEMBERS: (place_id) =>
|
|
196
|
+
SCConfig.apiRoot + `/camera_manager/hanet/places/${place_id}/members/`,
|
|
197
|
+
RENAME_MEMBER: (place_id, member_id) =>
|
|
198
|
+
SCConfig.apiRoot +
|
|
199
|
+
`/camera_manager/hanet/places/${place_id}/members/${member_id}/rename/`,
|
|
200
|
+
REMOVE_MEMBER: (place_id, member_id) =>
|
|
201
|
+
SCConfig.apiRoot +
|
|
202
|
+
`/camera_manager/hanet/places/${place_id}/members/${member_id}/`,
|
|
203
|
+
UPDATE_FACE_ID: (place_id, member_id) =>
|
|
204
|
+
SCConfig.apiRoot +
|
|
205
|
+
`/camera_manager/hanet/places/${place_id}/members/${member_id}/update_face_id/`,
|
|
206
|
+
REGISTER: (place_id) =>
|
|
207
|
+
SCConfig.apiRoot + `/camera_manager/hanet/places/${place_id}/members/`,
|
|
208
|
+
PUSHER_AUTH: () =>
|
|
209
|
+
SCConfig.apiRoot + '/camera_manager/hanet/pusher/auth/',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
190
212
|
NOTIFICATION: {
|
|
191
213
|
LIST_EOH_NOTIFICATIONS: (page, type) =>
|
|
192
214
|
SCConfig.apiRoot + `/notifications/eoh/?page=${page}&type=${type}`,
|
package/src/configs/Constants.js
CHANGED
|
@@ -73,6 +73,16 @@ export const Constants = {
|
|
|
73
73
|
|
|
74
74
|
export const DEVICE_TYPE = {
|
|
75
75
|
LG_THINQ: 'LG_THINQ',
|
|
76
|
+
HANET: 'HANET',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const marginItem = 12;
|
|
80
|
+
const marginHorizontal = 16;
|
|
81
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
82
|
+
const heightItem = (widthItem / 166) * 106;
|
|
83
|
+
export const DEVICE_SIZE = {
|
|
84
|
+
width: widthItem,
|
|
85
|
+
height: heightItem,
|
|
76
86
|
};
|
|
77
87
|
|
|
78
88
|
export const SCANNING_STATUS = {
|
|
@@ -100,6 +110,26 @@ export const AUTOMATE_TYPE = {
|
|
|
100
110
|
SCENARIO: 'scenario',
|
|
101
111
|
};
|
|
102
112
|
|
|
113
|
+
export const SMART_TIVI_BUTTON = {
|
|
114
|
+
ONOFF_BUTTON: 'OnOff',
|
|
115
|
+
EXIT_BUTTON: 'Exit',
|
|
116
|
+
VOLUME_UP_BUTTON: 'VolumeUp',
|
|
117
|
+
VOLUME_DOWN_BUTTON: 'VolumeDown',
|
|
118
|
+
CH_UP: 'ChUp',
|
|
119
|
+
CH_DOWN: 'ChDown',
|
|
120
|
+
PREV_BUTTON: 'Prev',
|
|
121
|
+
STOP_BUTTON: 'Stop',
|
|
122
|
+
NEXT_BUTTON: 'Next',
|
|
123
|
+
UP_BUTTON: 'Up',
|
|
124
|
+
DOWN_BUTTON: 'Down',
|
|
125
|
+
LEFT_BUTTON: 'Left',
|
|
126
|
+
RIGHT_BUTTON: 'Right',
|
|
127
|
+
OK_BUTTON: 'Ok',
|
|
128
|
+
HOME_BUTTON: 'Home',
|
|
129
|
+
BACK_BUTTON: 'Back',
|
|
130
|
+
CHANNEL_BUTTON: 'Channel',
|
|
131
|
+
};
|
|
132
|
+
|
|
103
133
|
export const AUTOMATE_SELECT = {
|
|
104
134
|
SELECT_DEVICE: 'select_device',
|
|
105
135
|
SELECT_SENSOR: 'select_sensor',
|
|
@@ -637,6 +667,13 @@ export const TESTID = {
|
|
|
637
667
|
// MoveToAnotherSubUnit
|
|
638
668
|
ROW_SUB_UNIT: 'ROW_SUB_UNIT',
|
|
639
669
|
|
|
670
|
+
// HanetCameraDetail
|
|
671
|
+
TEXT_COUNT_MEMBER: 'TEXT_COUNT_MEMBER',
|
|
672
|
+
TEXT_COUNT_STRANGER: 'TEXT_COUNT_STRANGER',
|
|
673
|
+
ROW_HANET_MANAGE_ACCESS: 'ROW_HANET_MANAGE_ACCESS',
|
|
674
|
+
HANET_MANAGE_ACCESS_ADD_BUTTON: 'HANET_MANAGE_ACCESS_ADD_BUTTON',
|
|
675
|
+
HANET_ADD_MEMBER_OPTION: 'HANET_ADD_MEMBER_OPTION',
|
|
676
|
+
|
|
640
677
|
//SetupGeneratePasscode
|
|
641
678
|
GENERATE_PASSCODE_CHOOSE_USER: 'GENERATE_PASSCODE_CHOOSE_USER',
|
|
642
679
|
GENERATE_PASSCODE_SET_TIME: 'GENERATE_PASSCODE_SET_TIME',
|
package/src/configs/SCConfig.js
CHANGED
|
@@ -7,6 +7,8 @@ export const Action = {
|
|
|
7
7
|
IS_FIRST_OPEN_CAMERA: 'IS_FIRST_OPEN_CAMERA',
|
|
8
8
|
IS_LAVIDA_SOURCE: 'IS_LAVIDA_SOURCE',
|
|
9
9
|
IS_CONNECT_WIFI_GATEWAY: 'IS_CONNECT_WIFI_GATEWAY',
|
|
10
|
+
SET_BLUETOOTH_STATE: 'SET_BLUETOOTH_STATE',
|
|
11
|
+
SET_NETWORK_CONNECTED: 'SET_NETWORK_CONNECTED',
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export type AuthData = {
|
|
@@ -52,4 +54,6 @@ export type AppType = {
|
|
|
52
54
|
isFirstOpenCamera: boolean;
|
|
53
55
|
isLavidaSource: boolean;
|
|
54
56
|
isConnectWifiGateway: boolean;
|
|
57
|
+
isBluetoothEnabled: boolean;
|
|
58
|
+
isNetworkConnected: boolean;
|
|
55
59
|
};
|
package/src/context/mockStore.ts
CHANGED
package/src/context/reducer.ts
CHANGED
|
@@ -41,6 +41,8 @@ export const initialState = {
|
|
|
41
41
|
isFirstOpenCamera: true,
|
|
42
42
|
isLavidaSource: false,
|
|
43
43
|
isConnectWifiGateway: false,
|
|
44
|
+
isBluetoothEnabled: false,
|
|
45
|
+
isNetworkConnected: false,
|
|
44
46
|
},
|
|
45
47
|
};
|
|
46
48
|
|
|
@@ -117,6 +119,24 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
117
119
|
},
|
|
118
120
|
};
|
|
119
121
|
}
|
|
122
|
+
case Action.SET_BLUETOOTH_STATE: {
|
|
123
|
+
return {
|
|
124
|
+
...currentState,
|
|
125
|
+
app: {
|
|
126
|
+
...currentState.app,
|
|
127
|
+
isBluetoothEnabled: payload,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
case Action.SET_NETWORK_CONNECTED: {
|
|
132
|
+
return {
|
|
133
|
+
...currentState,
|
|
134
|
+
app: {
|
|
135
|
+
...currentState.app,
|
|
136
|
+
isNetworkConnected: payload,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
120
140
|
default:
|
|
121
141
|
return currentState;
|
|
122
142
|
}
|
|
@@ -5,7 +5,6 @@ import t from '../../hooks/Common/useTranslations';
|
|
|
5
5
|
import base64 from 'react-native-base64';
|
|
6
6
|
import { BleManager } from 'react-native-ble-plx';
|
|
7
7
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
8
|
-
import { useEffect, useState } from 'react';
|
|
9
8
|
|
|
10
9
|
const bluetoothDevices = {};
|
|
11
10
|
const needToScanDevices = [];
|
|
@@ -192,24 +191,6 @@ export const sendDataOverBluetooth = async (
|
|
|
192
191
|
return result;
|
|
193
192
|
};
|
|
194
193
|
|
|
195
|
-
export const isBluetoothEnabled = async () => {
|
|
196
|
-
const state = await bleManager.state();
|
|
197
|
-
return state === 'PoweredOn';
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export const useIsBluetoothEnabled = () => {
|
|
201
|
-
const [isEnabled, setIsEnabled] = useState(null);
|
|
202
|
-
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
const subscription = bleManager.onStateChange((state) => {
|
|
205
|
-
setIsEnabled(state === 'PoweredOn');
|
|
206
|
-
}, true);
|
|
207
|
-
|
|
208
|
-
return () => subscription.remove();
|
|
209
|
-
}, []);
|
|
210
|
-
return isEnabled;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
194
|
export const enableBluetoothForAndroid = async () => {
|
|
214
195
|
await bleManager.enable();
|
|
215
196
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
2
|
+
import React, { memo } from 'react';
|
|
3
|
+
import HanetCameraDetail from '../screens/HanetCamera/Detail';
|
|
4
|
+
import HanetManageAccess from '../screens/HanetCamera/ManageAccess';
|
|
5
|
+
import HanetMemberInfo from '../screens/HanetCamera/MemberInfo';
|
|
6
|
+
import HanetCaptureFaceID from '../screens/HanetCamera/CaptureFaceID';
|
|
7
|
+
import Route from '../utils/Route';
|
|
8
|
+
import { screenOptions } from './utils';
|
|
9
|
+
|
|
10
|
+
const Stack = createStackNavigator();
|
|
11
|
+
|
|
12
|
+
export const HanetCameraStack = memo(() => {
|
|
13
|
+
return (
|
|
14
|
+
<Stack.Navigator
|
|
15
|
+
screenOptions={{
|
|
16
|
+
...screenOptions,
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
<Stack.Screen
|
|
20
|
+
name={Route.HanetCameraDetail}
|
|
21
|
+
component={HanetCameraDetail}
|
|
22
|
+
options={{ headerShown: false }}
|
|
23
|
+
/>
|
|
24
|
+
<Stack.Screen
|
|
25
|
+
name={Route.HanetManageAccess}
|
|
26
|
+
component={HanetManageAccess}
|
|
27
|
+
options={{ headerShown: false }}
|
|
28
|
+
/>
|
|
29
|
+
<Stack.Screen
|
|
30
|
+
name={Route.HanetMemberInfo}
|
|
31
|
+
component={HanetMemberInfo}
|
|
32
|
+
options={{ headerShown: false }}
|
|
33
|
+
/>
|
|
34
|
+
<Stack.Screen
|
|
35
|
+
name={Route.HanetCaptureFaceID}
|
|
36
|
+
component={HanetCaptureFaceID}
|
|
37
|
+
options={{ headerShown: false }}
|
|
38
|
+
/>
|
|
39
|
+
</Stack.Navigator>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
1
|
+
import React, { memo, useContext, useEffect } from 'react';
|
|
2
2
|
import { View, StyleSheet } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
5
|
+
import { BleManager } from 'react-native-ble-plx';
|
|
6
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
5
7
|
import { get } from 'lodash';
|
|
6
8
|
|
|
7
9
|
import Text from '../commons/Text';
|
|
@@ -10,6 +12,8 @@ import { Colors, Device } from '../configs';
|
|
|
10
12
|
import Route from '../utils/Route';
|
|
11
13
|
import ActivityLogScreen from '../screens/ActivityLog';
|
|
12
14
|
import { screenOptions } from './utils';
|
|
15
|
+
import { SCContext } from '../context';
|
|
16
|
+
import { Action } from '../context/actionType';
|
|
13
17
|
|
|
14
18
|
import AQIGuide from '../screens/AQIGuide';
|
|
15
19
|
import DeviceDetail from '../screens/Device/detail';
|
|
@@ -45,11 +49,33 @@ import SetUpSensor from '../screens/AddNewAction/SetupSensor';
|
|
|
45
49
|
import EditDevice from '../screens/Device/EditDevice/index';
|
|
46
50
|
import EmergencySetting from '../screens/EmergencySetting';
|
|
47
51
|
import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
|
|
52
|
+
import { HanetCameraStack } from './HanetCameraStack';
|
|
48
53
|
|
|
49
54
|
const Stack = createStackNavigator();
|
|
50
55
|
|
|
56
|
+
const bleManager = new BleManager();
|
|
57
|
+
|
|
51
58
|
export const UnitStack = memo((props) => {
|
|
52
59
|
const t = useTranslations();
|
|
60
|
+
const { setAction } = useContext(SCContext);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
64
|
+
setAction(Action.SET_NETWORK_CONNECTED, state.isConnected);
|
|
65
|
+
});
|
|
66
|
+
return () => unsubscribe();
|
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const subscription = bleManager.onStateChange((state) => {
|
|
72
|
+
setAction(Action.SET_BLUETOOTH_STATE, state === 'PoweredOn');
|
|
73
|
+
}, true);
|
|
74
|
+
|
|
75
|
+
return () => subscription.remove();
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
53
79
|
return (
|
|
54
80
|
<Stack.Navigator
|
|
55
81
|
screenOptions={{
|
|
@@ -166,6 +192,13 @@ export const UnitStack = memo((props) => {
|
|
|
166
192
|
headerShown: false,
|
|
167
193
|
}}
|
|
168
194
|
/>
|
|
195
|
+
<Stack.Screen
|
|
196
|
+
name={Route.HanetCameraStack}
|
|
197
|
+
component={HanetCameraStack}
|
|
198
|
+
options={{
|
|
199
|
+
headerShown: false,
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
169
202
|
<Stack.Screen
|
|
170
203
|
name={Route.UVIndexGuide}
|
|
171
204
|
component={UVIndexGuide}
|
|
@@ -93,9 +93,9 @@ export default ({ id, type, share, filterEnabled }) => {
|
|
|
93
93
|
setData(api.standardizeData(results));
|
|
94
94
|
} else {
|
|
95
95
|
dataTemp = dataTemp.concat(results);
|
|
96
|
-
setIsCanLoadMore(page < Math.ceil(data.count / 20));
|
|
97
96
|
setData(api.standardizeData(dataTemp));
|
|
98
97
|
}
|
|
98
|
+
setIsCanLoadMore(page < Math.ceil(data.count / 20));
|
|
99
99
|
}
|
|
100
100
|
page === 1 ? setIsRefreshing(false) : setIsLoading(false);
|
|
101
101
|
};
|