@eohjsc/react-native-smart-city 0.3.61 → 0.3.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -2
- package/package.json +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +2 -1
- package/src/commons/Header/HeaderCustom.js +4 -1
- package/src/navigations/AllGatewayStack.js +58 -0
- package/src/navigations/Main.js +197 -197
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/Gateway/__test__/index.test.js +8 -2
- package/src/screens/Gateway/index.js +36 -24
- package/src/screens/Gateway/styles.js +9 -1
- package/src/screens/Unit/MoreMenu.js +12 -1
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/I18n/translations/en.json +2 -1
- package/src/utils/I18n/translations/vi.json +2 -1
- package/src/utils/Route/index.js +2 -0
- package/src/utils/Utils.js +7 -0
package/index.js
CHANGED
|
@@ -19,8 +19,9 @@ import MyUnit from './src/commons/Dashboard/MyUnit';
|
|
|
19
19
|
import SharedUnit from './src/commons/Unit/SharedUnit';
|
|
20
20
|
import { Action } from './src/context/actionType';
|
|
21
21
|
import { withRemoteControl } from './src/hoc';
|
|
22
|
-
import DevModeStack from './src/navigations/Main';
|
|
22
|
+
// import DevModeStack from './src/navigations/Main';
|
|
23
23
|
import { SmartAccountStack } from './src/navigations/SmartAccountStack';
|
|
24
|
+
import { AllGatewayStack } from './src/navigations/AllGatewayStack';
|
|
24
25
|
|
|
25
26
|
export {
|
|
26
27
|
AddSubUnitStack,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
SCWrapper,
|
|
47
48
|
Action,
|
|
48
49
|
withRemoteControl,
|
|
49
|
-
DevModeStack,
|
|
50
|
+
// DevModeStack,
|
|
50
51
|
SmartAccountStack,
|
|
52
|
+
AllGatewayStack,
|
|
51
53
|
};
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { FlatList } from 'react-native';
|
|
4
4
|
import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
|
|
5
5
|
import styles from './PMSensorIndicatorStyles';
|
|
6
|
+
import { roundNumber } from '../../../utils/Utils';
|
|
6
7
|
|
|
7
8
|
//using for PM2.5-10, CO, UV, Rainflow Sensor
|
|
8
9
|
const keyExtractor = (item) => item.id.toString();
|
|
@@ -11,7 +12,7 @@ const PMSensorIndicatior = memo(({ data = [], style }) => {
|
|
|
11
12
|
({ item }) => {
|
|
12
13
|
const getValue = ['', null, undefined, NaN].includes(item?.value)
|
|
13
14
|
? '--'
|
|
14
|
-
: item?.value;
|
|
15
|
+
: roundNumber(item?.value);
|
|
15
16
|
return (
|
|
16
17
|
<QualityIndicatorItem
|
|
17
18
|
key={item.id.toString()}
|
|
@@ -28,6 +28,7 @@ const HeaderCustom = ({
|
|
|
28
28
|
isCanBack = true,
|
|
29
29
|
customTitle = false,
|
|
30
30
|
buttonBackStyles,
|
|
31
|
+
headerStyles,
|
|
31
32
|
}) => {
|
|
32
33
|
const t = useTranslations();
|
|
33
34
|
const { goBack } = useNavigation();
|
|
@@ -46,7 +47,9 @@ const HeaderCustom = ({
|
|
|
46
47
|
}, []);
|
|
47
48
|
|
|
48
49
|
return (
|
|
49
|
-
<View
|
|
50
|
+
<View
|
|
51
|
+
style={[styles.wrap, isShowSeparator && styles.separator, headerStyles]}
|
|
52
|
+
>
|
|
50
53
|
{isCanBack && (
|
|
51
54
|
<TouchableOpacity
|
|
52
55
|
style={[styles.buttonBack, buttonBackStyles]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
+
|
|
4
|
+
import GatewayDetail from '../screens/Gateway/GatewayDetail';
|
|
5
|
+
import GatewayInfo from '../screens/Gateway/GatewayInfo';
|
|
6
|
+
import GatewayConnectionMethods from '../screens/Gateway/GatewayConnectionMethods';
|
|
7
|
+
import DeviceZigbeeDetail from '../screens/Gateway/DeviceZigbeeDetail';
|
|
8
|
+
import DeviceGatewayInfo from '../screens/Gateway/DeviceGatewayInfo';
|
|
9
|
+
import DetailConfigActionZigbee from '../screens/Gateway/DetailConfigActionZigbee';
|
|
10
|
+
import DeviceModbusDetail from '../screens/Gateway/DeviceModbusDetail';
|
|
11
|
+
import DetailConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
12
|
+
import DetailChildConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
13
|
+
import Route from '../utils/Route'; // utils/Route
|
|
14
|
+
import { screenOptions } from './utils';
|
|
15
|
+
|
|
16
|
+
const Stack = createStackNavigator();
|
|
17
|
+
|
|
18
|
+
export const AllGatewayStack = memo(() => {
|
|
19
|
+
return (
|
|
20
|
+
<Stack.Navigator
|
|
21
|
+
screenOptions={{
|
|
22
|
+
...screenOptions,
|
|
23
|
+
headerShown: false,
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Stack.Screen component={GatewayDetail} name={Route.GatewayDetail} />
|
|
27
|
+
<Stack.Screen component={GatewayInfo} name={Route.GatewayInfo} />
|
|
28
|
+
<Stack.Screen
|
|
29
|
+
component={DeviceGatewayInfo}
|
|
30
|
+
name={Route.DeviceGatewayInfo}
|
|
31
|
+
/>
|
|
32
|
+
<Stack.Screen
|
|
33
|
+
component={GatewayConnectionMethods}
|
|
34
|
+
name={Route.GatewayConnectionMethods}
|
|
35
|
+
/>
|
|
36
|
+
<Stack.Screen
|
|
37
|
+
component={DeviceZigbeeDetail}
|
|
38
|
+
name={Route.DeviceZigbeeDetail}
|
|
39
|
+
/>
|
|
40
|
+
<Stack.Screen
|
|
41
|
+
component={DeviceModbusDetail}
|
|
42
|
+
name={Route.DeviceModbusDetail}
|
|
43
|
+
/>
|
|
44
|
+
<Stack.Screen
|
|
45
|
+
component={DetailConfigActionZigbee}
|
|
46
|
+
name={Route.DetailConfigActionZigbee}
|
|
47
|
+
/>
|
|
48
|
+
<Stack.Screen
|
|
49
|
+
component={DetailConfigActionModbus}
|
|
50
|
+
name={Route.DetailConfigActionModbus}
|
|
51
|
+
/>
|
|
52
|
+
<Stack.Screen
|
|
53
|
+
component={DetailChildConfigActionModbus}
|
|
54
|
+
name={Route.DetailChildConfigActionModbus}
|
|
55
|
+
/>
|
|
56
|
+
</Stack.Navigator>
|
|
57
|
+
);
|
|
58
|
+
});
|
package/src/navigations/Main.js
CHANGED
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
import React, { useMemo, useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
10
|
-
import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
11
|
-
import { useNavigation } from '@react-navigation/native';
|
|
12
|
-
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
13
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
1
|
+
// import React, { useMemo, useRef } from 'react';
|
|
2
|
+
// import {
|
|
3
|
+
// Animated,
|
|
4
|
+
// View,
|
|
5
|
+
// TouchableOpacity,
|
|
6
|
+
// StyleSheet,
|
|
7
|
+
// Image,
|
|
8
|
+
// } from 'react-native';
|
|
9
|
+
// import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
10
|
+
// import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
11
|
+
// import { useNavigation } from '@react-navigation/native';
|
|
12
|
+
// import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
13
|
+
// import { createStackNavigator } from '@react-navigation/stack';
|
|
14
14
|
|
|
15
|
-
import Tabbar from '../commons/Tabbar';
|
|
16
|
-
import { Colors, Constants, Images } from '../configs';
|
|
17
|
-
import t from '../hooks/Common/useTranslations';
|
|
18
|
-
import Routes from '../utils/Route';
|
|
19
|
-
import GatewayStack from './GatewayStack';
|
|
20
|
-
import SmartStack from './SmartStack';
|
|
21
|
-
import TemplateStack from './TemplateStack';
|
|
22
|
-
import DrawerContainer from '../screens/Drawer';
|
|
23
|
-
import { AccessibilityLabel } from '../configs/Constants';
|
|
24
|
-
import Text from '../commons/Text';
|
|
25
|
-
import { screenOptions } from './utils';
|
|
26
|
-
import TemplateDetail from '../screens/Template/detail';
|
|
27
|
-
import Information from '../screens/Template/Information';
|
|
28
|
-
import GatewayList from '../screens/Template/GatewayList';
|
|
29
|
-
import EditTemplate from '../screens/Template/EditTemplate';
|
|
30
|
-
import GatewayDetail from '../screens/Gateway/GatewayDetail';
|
|
31
|
-
import GatewayInfo from '../screens/Gateway/GatewayInfo';
|
|
32
|
-
import GatewayConnectionMethods from '../screens/Gateway/GatewayConnectionMethods';
|
|
33
|
-
import DeviceZigbeeDetail from '../screens/Gateway/DeviceZigbeeDetail';
|
|
34
|
-
import DeviceGatewayInfo from '../screens/Gateway/DeviceGatewayInfo';
|
|
35
|
-
import DetailConfigActionZigbee from '../screens/Gateway/DetailConfigActionZigbee';
|
|
36
|
-
import DeviceModbusDetail from '../screens/Gateway/DeviceModbusDetail';
|
|
37
|
-
import DetailConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
38
|
-
import DetailChildConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
39
|
-
import { useBlockBackAndroid } from '../hooks/Common';
|
|
15
|
+
// import Tabbar from '../commons/Tabbar';
|
|
16
|
+
// import { Colors, Constants, Images } from '../configs';
|
|
17
|
+
// import t from '../hooks/Common/useTranslations';
|
|
18
|
+
// import Routes from '../utils/Route';
|
|
19
|
+
// import GatewayStack from './GatewayStack';
|
|
20
|
+
// import SmartStack from './SmartStack';
|
|
21
|
+
// import TemplateStack from './TemplateStack';
|
|
22
|
+
// import DrawerContainer from '../screens/Drawer';
|
|
23
|
+
// import { AccessibilityLabel } from '../configs/Constants';
|
|
24
|
+
// import Text from '../commons/Text';
|
|
25
|
+
// import { screenOptions } from './utils';
|
|
26
|
+
// import TemplateDetail from '../screens/Template/detail';
|
|
27
|
+
// import Information from '../screens/Template/Information';
|
|
28
|
+
// import GatewayList from '../screens/Template/GatewayList';
|
|
29
|
+
// import EditTemplate from '../screens/Template/EditTemplate';
|
|
30
|
+
// import GatewayDetail from '../screens/Gateway/GatewayDetail';
|
|
31
|
+
// import GatewayInfo from '../screens/Gateway/GatewayInfo';
|
|
32
|
+
// import GatewayConnectionMethods from '../screens/Gateway/GatewayConnectionMethods';
|
|
33
|
+
// import DeviceZigbeeDetail from '../screens/Gateway/DeviceZigbeeDetail';
|
|
34
|
+
// import DeviceGatewayInfo from '../screens/Gateway/DeviceGatewayInfo';
|
|
35
|
+
// import DetailConfigActionZigbee from '../screens/Gateway/DetailConfigActionZigbee';
|
|
36
|
+
// import DeviceModbusDetail from '../screens/Gateway/DeviceModbusDetail';
|
|
37
|
+
// import DetailConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
38
|
+
// import DetailChildConfigActionModbus from '../screens/Gateway/DetailConfigActionModbus';
|
|
39
|
+
// import { useBlockBackAndroid } from '../hooks/Common';
|
|
40
40
|
|
|
41
|
-
const Tab = createBottomTabNavigator();
|
|
42
|
-
const Drawer = createDrawerNavigator();
|
|
43
|
-
const Stack = createStackNavigator();
|
|
41
|
+
// const Tab = createBottomTabNavigator();
|
|
42
|
+
// const Drawer = createDrawerNavigator();
|
|
43
|
+
// const Stack = createStackNavigator();
|
|
44
44
|
|
|
45
|
-
const getWidth = () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
45
|
+
// const getWidth = () => {
|
|
46
|
+
// const Width = Constants.width - 12;
|
|
47
|
+
// return Width / 3;
|
|
48
|
+
// };
|
|
49
49
|
|
|
50
|
-
const MainDevMode = () => {
|
|
51
|
-
|
|
50
|
+
// const MainDevMode = () => {
|
|
51
|
+
// const navigation = useNavigation();
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
// const listTabName = useMemo(
|
|
54
|
+
// () => [
|
|
55
|
+
// {
|
|
56
|
+
// name: Routes.TemplateStack,
|
|
57
|
+
// tabBarLabel: t('dashboard'),
|
|
58
|
+
// component: TemplateStack,
|
|
59
|
+
// },
|
|
60
|
+
// {
|
|
61
|
+
// name: Routes.GatewayStack,
|
|
62
|
+
// tabBarLabel: t('gateways'),
|
|
63
|
+
// component: GatewayStack,
|
|
64
|
+
// },
|
|
65
|
+
// {
|
|
66
|
+
// name: Routes.SmartStack,
|
|
67
|
+
// tabBarLabel: t('smart'),
|
|
68
|
+
// component: SmartStack,
|
|
69
|
+
// },
|
|
70
|
+
// ],
|
|
71
|
+
// []
|
|
72
|
+
// );
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
// const tabOffSetValue = useRef(new Animated.Value(0)).current;
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
// const Header = () => {
|
|
77
|
+
// return (
|
|
78
|
+
// <View style={styles.wrapHeader}>
|
|
79
|
+
// <TouchableOpacity
|
|
80
|
+
// style={styles.btnMenu}
|
|
81
|
+
// onPress={() => navigation.toggleDrawer()}
|
|
82
|
+
// accessibilityLabel={AccessibilityLabel.BURGER_MENU_ICON}
|
|
83
|
+
// >
|
|
84
|
+
// <Image source={Images.menu} style={styles.menu} />
|
|
85
|
+
// </TouchableOpacity>
|
|
86
|
+
// <Text style={styles.textHeader}>{t('developer_mode')}</Text>
|
|
87
|
+
// </View>
|
|
88
|
+
// );
|
|
89
|
+
// };
|
|
90
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
|
-
};
|
|
91
|
+
// return (
|
|
92
|
+
// <>
|
|
93
|
+
// <Header />
|
|
94
|
+
// <Tab.Navigator tabBar={(props) => <Tabbar {...props} />}>
|
|
95
|
+
// {listTabName.map((item) => (
|
|
96
|
+
// <Tab.Screen
|
|
97
|
+
// name={item.name}
|
|
98
|
+
// component={item.component}
|
|
99
|
+
// options={{
|
|
100
|
+
// tabBarLabel: item.tabBarLabel,
|
|
101
|
+
// tabOffSetValue,
|
|
102
|
+
// }}
|
|
103
|
+
// />
|
|
104
|
+
// ))}
|
|
105
|
+
// </Tab.Navigator>
|
|
106
|
+
// <Animated.View
|
|
107
|
+
// // eslint-disable-next-line react-native/no-inline-styles
|
|
108
|
+
// style={{
|
|
109
|
+
// width: getWidth() - 4,
|
|
110
|
+
// transform: [{ translateX: tabOffSetValue }],
|
|
111
|
+
// height: 2,
|
|
112
|
+
// backgroundColor: Colors.Primary,
|
|
113
|
+
// position: 'absolute',
|
|
114
|
+
// bottom: 70,
|
|
115
|
+
// left: 8,
|
|
116
|
+
// borderRadius: 1,
|
|
117
|
+
// }}
|
|
118
|
+
// />
|
|
119
|
+
// </>
|
|
120
|
+
// );
|
|
121
|
+
// };
|
|
122
122
|
|
|
123
|
-
const DrawerScreen = () => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
123
|
+
// const DrawerScreen = () => {
|
|
124
|
+
// useBlockBackAndroid();
|
|
125
|
+
// return (
|
|
126
|
+
// <Drawer.Navigator
|
|
127
|
+
// backBehavior="none"
|
|
128
|
+
// drawerContent={(props) => <DrawerContainer {...props} />}
|
|
129
|
+
// drawerStyle={{ paddingTop: getStatusBarHeight() }}
|
|
130
|
+
// >
|
|
131
|
+
// <Drawer.Screen name={Routes.MainDevMode} component={MainDevMode} />
|
|
132
|
+
// </Drawer.Navigator>
|
|
133
|
+
// );
|
|
134
|
+
// };
|
|
135
135
|
|
|
136
|
-
const DevModeStack = () => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
};
|
|
136
|
+
// const DevModeStack = () => {
|
|
137
|
+
// return (
|
|
138
|
+
// <Stack.Navigator
|
|
139
|
+
// screenOptions={{
|
|
140
|
+
// ...screenOptions,
|
|
141
|
+
// headerShown: false,
|
|
142
|
+
// }}
|
|
143
|
+
// >
|
|
144
|
+
// <Stack.Screen component={DrawerScreen} name={Routes.DrawerScreen} />
|
|
145
|
+
// <Stack.Screen component={TemplateDetail} name={Routes.TemplateDetail} />
|
|
146
|
+
// <Stack.Screen component={GatewayDetail} name={Routes.GatewayDetail} />
|
|
147
|
+
// <Stack.Screen component={GatewayInfo} name={Routes.GatewayInfo} />
|
|
148
|
+
// <Stack.Screen
|
|
149
|
+
// component={DeviceGatewayInfo}
|
|
150
|
+
// name={Routes.DeviceGatewayInfo}
|
|
151
|
+
// />
|
|
152
|
+
// <Stack.Screen
|
|
153
|
+
// component={GatewayConnectionMethods}
|
|
154
|
+
// name={Routes.GatewayConnectionMethods}
|
|
155
|
+
// />
|
|
156
|
+
// <Stack.Screen
|
|
157
|
+
// component={DeviceZigbeeDetail}
|
|
158
|
+
// name={Routes.DeviceZigbeeDetail}
|
|
159
|
+
// />
|
|
160
|
+
// <Stack.Screen
|
|
161
|
+
// component={DeviceModbusDetail}
|
|
162
|
+
// name={Routes.DeviceModbusDetail}
|
|
163
|
+
// />
|
|
164
|
+
// <Stack.Screen
|
|
165
|
+
// component={DetailConfigActionZigbee}
|
|
166
|
+
// name={Routes.DetailConfigActionZigbee}
|
|
167
|
+
// />
|
|
168
|
+
// <Stack.Screen
|
|
169
|
+
// component={DetailConfigActionModbus}
|
|
170
|
+
// name={Routes.DetailConfigActionModbus}
|
|
171
|
+
// />
|
|
172
|
+
// <Stack.Screen
|
|
173
|
+
// component={DetailChildConfigActionModbus}
|
|
174
|
+
// name={Routes.DetailChildConfigActionModbus}
|
|
175
|
+
// />
|
|
176
|
+
// <Stack.Screen component={Information} name={Routes.Information} />
|
|
177
|
+
// <Stack.Screen component={GatewayList} name={Routes.GatewayList} />
|
|
178
|
+
// <Stack.Screen component={EditTemplate} name={Routes.EditTemplate} />
|
|
179
|
+
// </Stack.Navigator>
|
|
180
|
+
// );
|
|
181
|
+
// };
|
|
182
182
|
|
|
183
|
-
export default DevModeStack;
|
|
183
|
+
// export default DevModeStack;
|
|
184
184
|
|
|
185
|
-
const styles = StyleSheet.create({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
185
|
+
// const styles = StyleSheet.create({
|
|
186
|
+
// btnMenu: {
|
|
187
|
+
// width: 40,
|
|
188
|
+
// height: 40,
|
|
189
|
+
// justifyContent: 'center',
|
|
190
|
+
// alignItems: 'center',
|
|
191
|
+
// marginLeft: 10,
|
|
192
|
+
// },
|
|
193
|
+
// wrapHeader: {
|
|
194
|
+
// height: 100,
|
|
195
|
+
// paddingTop: getStatusBarHeight(),
|
|
196
|
+
// flexDirection: 'row',
|
|
197
|
+
// alignItems: 'center',
|
|
198
|
+
// backgroundColor: Colors.Gray2,
|
|
199
|
+
// },
|
|
200
|
+
// textHeader: {
|
|
201
|
+
// fontSize: 20,
|
|
202
|
+
// fontWeight: 'bold',
|
|
203
|
+
// color: Colors.Gray9,
|
|
204
|
+
// },
|
|
205
|
+
// menu: {
|
|
206
|
+
// width: 24,
|
|
207
|
+
// height: 24,
|
|
208
|
+
// },
|
|
209
|
+
// });
|
|
@@ -53,6 +53,7 @@ import EmergencySetting from '../screens/EmergencySetting';
|
|
|
53
53
|
import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
|
|
54
54
|
import InfoMemberUnit from '../screens/Sharing/InfoMemberUnit';
|
|
55
55
|
import EnterPassword from '../screens/EnterPassword';
|
|
56
|
+
import AllGateway from '../screens/Gateway';
|
|
56
57
|
import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
|
|
57
58
|
import { HanetCameraStack } from './HanetCameraStack';
|
|
58
59
|
import { axiosGet, fetchWithCache } from '../utils/Apis/axios';
|
|
@@ -462,6 +463,13 @@ export const UnitStack = memo((props) => {
|
|
|
462
463
|
headerShown: false,
|
|
463
464
|
}}
|
|
464
465
|
/>
|
|
466
|
+
<Stack.Screen
|
|
467
|
+
name={Route.AllGateway}
|
|
468
|
+
component={AllGateway}
|
|
469
|
+
options={{
|
|
470
|
+
headerShown: false,
|
|
471
|
+
}}
|
|
472
|
+
/>
|
|
465
473
|
</Stack.Navigator>
|
|
466
474
|
);
|
|
467
475
|
});
|
|
@@ -65,8 +65,14 @@ describe('Test Gateway screen', () => {
|
|
|
65
65
|
await act(async () => {
|
|
66
66
|
await gatewayItems[0].props.onPress();
|
|
67
67
|
});
|
|
68
|
-
expect(mockNavigate).toBeCalledWith(Routes.
|
|
69
|
-
|
|
68
|
+
expect(mockNavigate).toBeCalledWith(Routes.AllGatewayStack, {
|
|
69
|
+
params: {
|
|
70
|
+
item: {
|
|
71
|
+
id: 1,
|
|
72
|
+
name: 'device 1',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
screen: 'GatewayDetail',
|
|
70
76
|
});
|
|
71
77
|
});
|
|
72
78
|
|
|
@@ -9,6 +9,7 @@ import { useGateway } from './hooks/useGateway';
|
|
|
9
9
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
10
10
|
import Routes from '../../utils/Route';
|
|
11
11
|
import styles from './styles';
|
|
12
|
+
import { HeaderCustom } from '../../commons/Header';
|
|
12
13
|
|
|
13
14
|
const Gateway = ({ route }) => {
|
|
14
15
|
const t = useTranslations();
|
|
@@ -25,7 +26,10 @@ const Gateway = ({ route }) => {
|
|
|
25
26
|
|
|
26
27
|
const goGoDetail = useCallback(
|
|
27
28
|
(item) => () => {
|
|
28
|
-
navigate(Routes.
|
|
29
|
+
navigate(Routes.AllGatewayStack, {
|
|
30
|
+
screen: Routes.GatewayDetail,
|
|
31
|
+
params: { item },
|
|
32
|
+
});
|
|
29
33
|
},
|
|
30
34
|
[navigate]
|
|
31
35
|
);
|
|
@@ -66,30 +70,38 @@ const Gateway = ({ route }) => {
|
|
|
66
70
|
}, [isFocused, fetchDataGateways]);
|
|
67
71
|
|
|
68
72
|
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<FlatList
|
|
76
|
-
onRefresh={onRefresh}
|
|
77
|
-
refreshing={refresh}
|
|
78
|
-
columnWrapperStyle={styles.spaceBetween}
|
|
79
|
-
showsVerticalScrollIndicator={false}
|
|
80
|
-
showsHorizontalScrollIndicator={false}
|
|
81
|
-
contentContainerStyle={[
|
|
82
|
-
styles.contentContainerStyle,
|
|
83
|
-
gatewaysSearched?.length === 0 && styles.flex1,
|
|
84
|
-
]}
|
|
85
|
-
keyExtractor={(item) => item?.id}
|
|
86
|
-
data={gatewaysSearched}
|
|
87
|
-
renderItem={renderItem}
|
|
88
|
-
extraData={gatewaysSearched}
|
|
89
|
-
ListEmptyComponent={renderListEmptyComponent}
|
|
90
|
-
numColumns={2}
|
|
73
|
+
<>
|
|
74
|
+
<HeaderCustom
|
|
75
|
+
title={t('all_gateway')}
|
|
76
|
+
titleStyles={styles.titleLeft}
|
|
77
|
+
buttonBackStyles={styles.buttonBackStyles}
|
|
78
|
+
headerStyles={styles.header}
|
|
91
79
|
/>
|
|
92
|
-
|
|
80
|
+
<View
|
|
81
|
+
style={styles.wrap}
|
|
82
|
+
accessibilityLabel={AccessibilityLabel.LIST_GATEWAY}
|
|
83
|
+
>
|
|
84
|
+
<Label name={t('gateway')} />
|
|
85
|
+
<Search onSearch={setNameSearch} />
|
|
86
|
+
<FlatList
|
|
87
|
+
onRefresh={onRefresh}
|
|
88
|
+
refreshing={refresh}
|
|
89
|
+
columnWrapperStyle={styles.spaceBetween}
|
|
90
|
+
showsVerticalScrollIndicator={false}
|
|
91
|
+
showsHorizontalScrollIndicator={false}
|
|
92
|
+
contentContainerStyle={[
|
|
93
|
+
styles.contentContainerStyle,
|
|
94
|
+
gatewaysSearched?.length === 0 && styles.flex1,
|
|
95
|
+
]}
|
|
96
|
+
keyExtractor={(item) => item?.id}
|
|
97
|
+
data={gatewaysSearched}
|
|
98
|
+
renderItem={renderItem}
|
|
99
|
+
extraData={gatewaysSearched}
|
|
100
|
+
ListEmptyComponent={renderListEmptyComponent}
|
|
101
|
+
numColumns={2}
|
|
102
|
+
/>
|
|
103
|
+
</View>
|
|
104
|
+
</>
|
|
93
105
|
);
|
|
94
106
|
};
|
|
95
107
|
|
|
@@ -4,7 +4,6 @@ import { Colors } from '../../configs';
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
6
|
flex: 1,
|
|
7
|
-
paddingTop: 16,
|
|
8
7
|
paddingHorizontal: 16,
|
|
9
8
|
backgroundColor: Colors.White,
|
|
10
9
|
},
|
|
@@ -29,4 +28,13 @@ export default StyleSheet.create({
|
|
|
29
28
|
flex1: {
|
|
30
29
|
flex: 1,
|
|
31
30
|
},
|
|
31
|
+
titleLeft: {
|
|
32
|
+
textAlign: 'left',
|
|
33
|
+
},
|
|
34
|
+
buttonBackStyles: {
|
|
35
|
+
marginRight: 24,
|
|
36
|
+
},
|
|
37
|
+
header: {
|
|
38
|
+
backgroundColor: Colors.White,
|
|
39
|
+
},
|
|
32
40
|
});
|
|
@@ -44,8 +44,19 @@ const MoreMenu = ({
|
|
|
44
44
|
text: t('smart_account'),
|
|
45
45
|
data: { unitId: unit?.id, unit },
|
|
46
46
|
};
|
|
47
|
+
const RouteAllGateway = {
|
|
48
|
+
id: 'all-gateway',
|
|
49
|
+
route: Routes.AllGateway,
|
|
50
|
+
text: t('all_gateway'),
|
|
51
|
+
data: { unitId: unit?.id, unit },
|
|
52
|
+
};
|
|
47
53
|
return isOwner
|
|
48
|
-
? [
|
|
54
|
+
? [
|
|
55
|
+
RouteManageUnit,
|
|
56
|
+
RouteUnitMemberList,
|
|
57
|
+
ListSmartAccount,
|
|
58
|
+
RouteAllGateway,
|
|
59
|
+
]
|
|
49
60
|
: [RouteUnitMemberList];
|
|
50
61
|
}, [t, unit, isOwner]);
|
|
51
62
|
|
package/src/utils/Apis/axios.js
CHANGED
|
@@ -50,7 +50,7 @@ const shouldHideError = async (message) => {
|
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if (message === 'Network Error') {
|
|
53
|
+
if (message === 'Network Error' || message === PROBLEM_CODE.NETWORK_ERROR) {
|
|
54
54
|
const netState = await NetInfo.fetch();
|
|
55
55
|
if (!netState.isConnected) {
|
|
56
56
|
return true;
|
|
@@ -1107,5 +1107,6 @@
|
|
|
1107
1107
|
"text_understand_modal_popup_ct": "I fully understand that this action is critical and will lead to data loss.",
|
|
1108
1108
|
"cannot_find_device_wifi": "Cannot find Device's Wifi",
|
|
1109
1109
|
"this_command_is_just_support_bluetooth_only": "This command is just support bluetooth only",
|
|
1110
|
-
"photo_request_permission_des": "To select photo from gallery, please unlock access photo permission"
|
|
1110
|
+
"photo_request_permission_des": "To select photo from gallery, please unlock access photo permission",
|
|
1111
|
+
"all_gateway": "All Gateway"
|
|
1111
1112
|
}
|
|
@@ -1106,5 +1106,6 @@
|
|
|
1106
1106
|
"photo_request_permission": "Quyền yêu cầu ảnh",
|
|
1107
1107
|
"cannot_find_device_wifi": "Không thể tìm thấy Wifi của thiết bị",
|
|
1108
1108
|
"this_command_is_just_support_bluetooth_only": "Lệnh gửi này chỉ hỗ trợ bluetooth",
|
|
1109
|
-
"photo_request_permission_des": "Để chọn ảnh từ thư viện, vui lòng mở khóa quyền truy cập ảnh"
|
|
1109
|
+
"photo_request_permission_des": "Để chọn ảnh từ thư viện, vui lòng mở khóa quyền truy cập ảnh",
|
|
1110
|
+
"all_gateway": "Tất cả cổng kết nối"
|
|
1110
1111
|
}
|
package/src/utils/Route/index.js
CHANGED
|
@@ -180,6 +180,8 @@ const Routes = {
|
|
|
180
180
|
EditTemplate: 'EditTemplate',
|
|
181
181
|
SmartAccountStack: 'SmartAccountStack',
|
|
182
182
|
SuccessfullyConnected: 'SuccessfullyConnected',
|
|
183
|
+
AllGatewayStack: 'AllGatewayStack',
|
|
184
|
+
AllGateway: 'AllGateway',
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
export default Routes;
|
package/src/utils/Utils.js
CHANGED
|
@@ -133,6 +133,13 @@ export const notImplemented = (t) => {
|
|
|
133
133
|
Alert.alert(t('feature_under_development'));
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
export const roundNumber = (value, round = 2) => {
|
|
137
|
+
if (!isNaN) {
|
|
138
|
+
return Math.round((value || 0) * 10 ** round) / 10 ** round;
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
|
|
136
143
|
export default {
|
|
137
144
|
validateEmail,
|
|
138
145
|
isObjectEmpty,
|