@eohjsc/react-native-smart-city 0.3.61 → 0.3.63
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/Dashboard/MyPinnedSharedUnit/index.js +10 -0
- package/src/commons/Dashboard/MyUnit/index.js +9 -3
- package/src/commons/Device/HorizontalBarChart.js +3 -3
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +2 -1
- package/src/commons/Header/HeaderCustom.js +4 -1
- package/src/configs/API.js +14 -0
- package/src/configs/Constants.js +1 -0
- package/src/context/actionType.ts +1 -0
- package/src/context/reducer.ts +10 -0
- package/src/navigations/AllGatewayStack.js +68 -0
- package/src/navigations/Main.js +197 -197
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +104 -0
- package/src/screens/AllGateway/DetailConfigActionInternal/index.js +97 -0
- package/src/screens/{Gateway/DetailConfigActionModbus → AllGateway/DetailConfigActionInternal}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionModbus/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionModbus/index.js +0 -0
- package/src/screens/{Gateway/DeviceGatewayInfo → AllGateway/DetailConfigActionModbus}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceGatewayInfo/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceGatewayInfo/index.js +26 -2
- package/src/screens/{Gateway/GatewayInfo → AllGateway/DeviceGatewayInfo}/styles.js +0 -0
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +387 -0
- package/src/screens/AllGateway/DeviceInternalDetail/index.js +188 -0
- package/src/screens/{Gateway/DeviceModbusDetail → AllGateway/DeviceInternalDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceModbusDetail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceModbusDetail/index.js +9 -17
- package/src/screens/{Gateway/DeviceZigbeeDetail → AllGateway/DeviceModbusDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceZigbeeDetail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceZigbeeDetail/index.js +9 -17
- package/src/screens/{Gateway/GatewayDetail → AllGateway/DeviceZigbeeDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayDetail/__test__/index.test.js +71 -31
- package/src/screens/{Gateway → AllGateway}/GatewayDetail/index.js +62 -42
- package/src/screens/AllGateway/GatewayDetail/styles.js +12 -0
- package/src/screens/{Gateway → AllGateway}/GatewayInfo/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayInfo/index.js +14 -17
- package/src/screens/AllGateway/GatewayInfo/styles.js +12 -0
- package/src/screens/{Gateway → AllGateway}/__test__/index.test.js +8 -2
- package/src/screens/{Gateway → AllGateway}/components/Detail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Detail/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Detail/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/hooks/__test__/index.test.js +15 -2
- package/src/screens/{Gateway → AllGateway}/hooks/useGateway.js +91 -11
- package/src/screens/{Gateway → AllGateway}/index.js +38 -26
- package/src/screens/{Gateway → AllGateway}/styles.js +9 -1
- package/src/screens/{Gateway → AllGateway}/utils/index.js +0 -0
- package/src/screens/Unit/MoreMenu.js +12 -1
- package/src/screens/WaterQualityGuide/__test__/index.test.js +8 -8
- package/src/screens/WaterQualityGuide/index.js +32 -53
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/Functions/preloadImages.js +39 -0
- package/src/utils/I18n/translations/en.json +22 -16
- package/src/utils/I18n/translations/vi.json +22 -19
- package/src/utils/Route/index.js +4 -0
- package/src/utils/Storage.js +6 -0
- package/src/utils/Utils.js +7 -0
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/AllGateway';
|
|
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
|
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { create, act } from 'react-test-renderer';
|
|
3
|
+
import { useRoute } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { SCProvider } from '../../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
+
import DetailConfigAction from '../../components/DetailConfigAction';
|
|
8
|
+
import DetailConfigActionInternal from '..';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = () => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<DetailConfigActionInternal />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useRoute: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const mockNavigate = jest.fn();
|
|
24
|
+
jest.mock('@react-navigation/native', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('@react-navigation/native'),
|
|
27
|
+
useNavigation: () => ({
|
|
28
|
+
navigate: mockNavigate,
|
|
29
|
+
pop: jest.fn(),
|
|
30
|
+
}),
|
|
31
|
+
useRoute: jest.fn(),
|
|
32
|
+
useIsFocused: () => true,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('Test DetailConfigActionInternal', () => {
|
|
37
|
+
let tree;
|
|
38
|
+
it('test render DetailConfigActionInternal isConfigRead', async () => {
|
|
39
|
+
useRoute.mockReturnValue({
|
|
40
|
+
params: {
|
|
41
|
+
isConfigRead: true,
|
|
42
|
+
isConfigWrite: false,
|
|
43
|
+
isAction: false,
|
|
44
|
+
itemActionConfig: {
|
|
45
|
+
id: 1,
|
|
46
|
+
config: { name: 'config1' },
|
|
47
|
+
value_type: 'boolean',
|
|
48
|
+
pin_number: 0,
|
|
49
|
+
pin_mode: 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
await act(async () => {
|
|
54
|
+
tree = await create(wrapComponent());
|
|
55
|
+
});
|
|
56
|
+
const instance = tree.root;
|
|
57
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
58
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
59
|
+
});
|
|
60
|
+
it('test render DetailConfigActionInternal isConfigWrite', async () => {
|
|
61
|
+
useRoute.mockReturnValue({
|
|
62
|
+
params: {
|
|
63
|
+
isConfigRead: false,
|
|
64
|
+
isConfigWrite: true,
|
|
65
|
+
isAction: false,
|
|
66
|
+
itemActionConfig: {
|
|
67
|
+
id: 1,
|
|
68
|
+
config: { name: 'config1' },
|
|
69
|
+
value_type: 'boolean',
|
|
70
|
+
pin_number: 0,
|
|
71
|
+
pin_mode: 1,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
await act(async () => {
|
|
76
|
+
tree = await create(wrapComponent());
|
|
77
|
+
});
|
|
78
|
+
const instance = tree.root;
|
|
79
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
80
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
81
|
+
});
|
|
82
|
+
it('test render DetailConfigActionInternal isAction', async () => {
|
|
83
|
+
useRoute.mockReturnValue({
|
|
84
|
+
params: {
|
|
85
|
+
isConfigRead: false,
|
|
86
|
+
isConfigWrite: false,
|
|
87
|
+
isAction: true,
|
|
88
|
+
isChildAction: false,
|
|
89
|
+
itemActionConfig: {
|
|
90
|
+
id: 1,
|
|
91
|
+
action: { name: 'config1' },
|
|
92
|
+
pin: 'boolean',
|
|
93
|
+
default_value: 0,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
await act(async () => {
|
|
98
|
+
tree = await create(wrapComponent());
|
|
99
|
+
});
|
|
100
|
+
const instance = tree.root;
|
|
101
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
102
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useRoute } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
import DetailConfigAction from '../components/DetailConfigAction';
|
|
7
|
+
|
|
8
|
+
const DetailConfigActionInternal = () => {
|
|
9
|
+
const { params = {} } = useRoute();
|
|
10
|
+
const {
|
|
11
|
+
device = {},
|
|
12
|
+
itemActionConfig,
|
|
13
|
+
isConfigRead,
|
|
14
|
+
isConfigWrite,
|
|
15
|
+
isAction,
|
|
16
|
+
} = params;
|
|
17
|
+
|
|
18
|
+
const listData = useMemo(() => {
|
|
19
|
+
if (isConfigRead || isConfigWrite) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
id: 1,
|
|
23
|
+
title: 'config_name',
|
|
24
|
+
data: itemActionConfig?.config?.name || '--',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
title: 'config_type',
|
|
29
|
+
data:
|
|
30
|
+
itemActionConfig?.value_type === 'boolean'
|
|
31
|
+
? 'Digital'
|
|
32
|
+
: itemActionConfig?.value_type === 'integer'
|
|
33
|
+
? 'Analog'
|
|
34
|
+
: '--',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 3,
|
|
38
|
+
title: 'pin',
|
|
39
|
+
data: itemActionConfig?.pin_number || '0',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 4,
|
|
43
|
+
title: 'pin_mode',
|
|
44
|
+
data: itemActionConfig?.pin_mode || '--',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
if (isAction) {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: 1,
|
|
52
|
+
title: 'action_name',
|
|
53
|
+
data: itemActionConfig?.action?.name || '--',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
title: 'pin_number',
|
|
58
|
+
data: itemActionConfig?.pin || '0',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 3,
|
|
62
|
+
title: 'default_value',
|
|
63
|
+
data: itemActionConfig?.default_value || '--',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}, [isAction, isConfigRead, isConfigWrite, itemActionConfig]);
|
|
69
|
+
|
|
70
|
+
const title = useMemo(
|
|
71
|
+
() =>
|
|
72
|
+
((isConfigRead || isConfigWrite) && itemActionConfig?.config?.name) ||
|
|
73
|
+
(isAction && itemActionConfig?.action?.name) ||
|
|
74
|
+
'',
|
|
75
|
+
[
|
|
76
|
+
isConfigRead,
|
|
77
|
+
isConfigWrite,
|
|
78
|
+
itemActionConfig?.config?.name,
|
|
79
|
+
itemActionConfig?.action?.name,
|
|
80
|
+
isAction,
|
|
81
|
+
]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const subTitle = useMemo(() => device?.sensor?.name || '--', [device]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View style={styles.wrap}>
|
|
88
|
+
<DetailConfigAction
|
|
89
|
+
title={title}
|
|
90
|
+
subTitle={subTitle}
|
|
91
|
+
listData={listData}
|
|
92
|
+
/>
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default memo(DetailConfigActionInternal);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/screens/{Gateway/DeviceGatewayInfo → AllGateway/DetailConfigActionModbus}/styles.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|