@eohjsc/react-native-smart-city 0.2.62 → 0.2.66
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/navigations/SharedStack.js +12 -10
- package/src/screens/AddNewGateway/AddNewGatewayStyles.js +6 -1
- package/src/screens/AllCamera/index.js +27 -5
- package/src/screens/Device/EditDevice/index.js +3 -3
- package/src/screens/ScriptDetail/Styles/indexStyles.js +3 -0
- package/src/screens/ScriptDetail/index.js +6 -1
- package/src/screens/SubUnit/AddSubUnit.js +13 -25
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +2 -1
- package/src/screens/TDSGuide/index.js +5 -2
- package/src/screens/Unit/Detail.js +4 -1
- package/src/screens/WaterQualityGuide/index.js +2 -2
- package/src/utils/Apis/axios.js +2 -3
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.2.
|
|
4
|
+
"version": "0.2.66",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@react-native-community/async-storage": "^1.12.1",
|
|
107
107
|
"@react-native-community/cameraroll": "^4.0.0",
|
|
108
108
|
"@react-native-community/checkbox": "^0.5.5",
|
|
109
|
-
"@react-native-community/datetimepicker": "
|
|
109
|
+
"@react-native-community/datetimepicker": "https://github.com/hinh-eoh/datepicker",
|
|
110
110
|
"@react-native-community/geolocation": "^2.0.2",
|
|
111
111
|
"@react-native-community/masked-view": "^0.1.10",
|
|
112
112
|
"@react-native-community/netinfo": "^6.0.0",
|
|
@@ -12,7 +12,7 @@ import Routes from '../utils/Route';
|
|
|
12
12
|
const Stack = createStackNavigator();
|
|
13
13
|
const SharedStack = memo(() => {
|
|
14
14
|
const t = useTranslations();
|
|
15
|
-
const
|
|
15
|
+
const { toggleDrawer, goBack } = useNavigation();
|
|
16
16
|
const { params } = useRoute();
|
|
17
17
|
return (
|
|
18
18
|
<Stack.Navigator>
|
|
@@ -21,15 +21,17 @@ const SharedStack = memo(() => {
|
|
|
21
21
|
component={Shared}
|
|
22
22
|
options={{
|
|
23
23
|
title: t('text_shared_with_me'),
|
|
24
|
-
headerLeft: () =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
headerLeft: () => (
|
|
25
|
+
<TouchableOpacity
|
|
26
|
+
style={styles.btnMenu}
|
|
27
|
+
onPress={() => (params?.isMainSource ? toggleDrawer() : goBack())}
|
|
28
|
+
>
|
|
29
|
+
<Icon
|
|
30
|
+
name={params?.isMainSource ? 'menu' : 'arrow-left'}
|
|
31
|
+
color={Colors.Black}
|
|
32
|
+
/>
|
|
33
|
+
</TouchableOpacity>
|
|
34
|
+
),
|
|
33
35
|
headerTitleAlign: 'left',
|
|
34
36
|
headerStyle: {
|
|
35
37
|
backgroundColor: Colors.Gray2,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
1
|
+
import { StyleSheet, StatusBar, Platform } from 'react-native';
|
|
2
2
|
import { Colors } from '../../configs';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
6
|
flex: 1,
|
|
7
7
|
backgroundColor: Colors.Gray2,
|
|
8
|
+
...Platform.select({
|
|
9
|
+
android: {
|
|
10
|
+
paddingTop: StatusBar.currentHeight,
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
8
13
|
},
|
|
9
14
|
textHeader: {
|
|
10
15
|
marginTop: 16,
|
|
@@ -59,7 +59,7 @@ const AllCamera = () => {
|
|
|
59
59
|
navigate(Routes.PlaybackCamera, { item, thumbnail });
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const CameraItem = ({ item }) => {
|
|
62
|
+
const CameraItem = ({ item, width, height }) => {
|
|
63
63
|
return (
|
|
64
64
|
<View style={styles.wrap}>
|
|
65
65
|
{!!item && (
|
|
@@ -74,6 +74,8 @@ const AllCamera = () => {
|
|
|
74
74
|
amount={amount}
|
|
75
75
|
handleFullScreen={handleFullScreen}
|
|
76
76
|
goToPlayBack={goToPlayBack(item, thumbnail)}
|
|
77
|
+
width={width}
|
|
78
|
+
height={height}
|
|
77
79
|
/>
|
|
78
80
|
)}
|
|
79
81
|
</View>
|
|
@@ -88,12 +90,32 @@ const AllCamera = () => {
|
|
|
88
90
|
) : amount === 4 ? (
|
|
89
91
|
<>
|
|
90
92
|
<View style={styles.row}>
|
|
91
|
-
<CameraItem
|
|
92
|
-
|
|
93
|
+
<CameraItem
|
|
94
|
+
key={item?.id}
|
|
95
|
+
item={item[0]}
|
|
96
|
+
width={188}
|
|
97
|
+
height={112}
|
|
98
|
+
/>
|
|
99
|
+
<CameraItem
|
|
100
|
+
key={item?.id}
|
|
101
|
+
item={item[1]}
|
|
102
|
+
width={188}
|
|
103
|
+
height={112}
|
|
104
|
+
/>
|
|
93
105
|
</View>
|
|
94
106
|
<View style={styles.row}>
|
|
95
|
-
<CameraItem
|
|
96
|
-
|
|
107
|
+
<CameraItem
|
|
108
|
+
key={item?.id}
|
|
109
|
+
item={item[2]}
|
|
110
|
+
width={188}
|
|
111
|
+
height={112}
|
|
112
|
+
/>
|
|
113
|
+
<CameraItem
|
|
114
|
+
key={item?.id}
|
|
115
|
+
item={item[3]}
|
|
116
|
+
width={188}
|
|
117
|
+
height={112}
|
|
118
|
+
/>
|
|
97
119
|
</View>
|
|
98
120
|
</>
|
|
99
121
|
) : (
|
|
@@ -23,7 +23,7 @@ const EditDevice = memo(() => {
|
|
|
23
23
|
const navigation = useNavigation();
|
|
24
24
|
const { params = {} } = useRoute();
|
|
25
25
|
const { sensor, setSensorNameDetail, sensorNameDetail } = params;
|
|
26
|
-
const [inputName, setInputName] = useState('');
|
|
26
|
+
const [inputName, setInputName] = useState(sensorNameDetail || '');
|
|
27
27
|
const [sensorName, setSensorName] = useState(sensorNameDetail || '');
|
|
28
28
|
const { stateAlertAction, hideAlertAction, onShowRename, onShowDelete } =
|
|
29
29
|
useEditDevice();
|
|
@@ -130,8 +130,8 @@ const EditDevice = memo(() => {
|
|
|
130
130
|
>
|
|
131
131
|
{!stateAlertAction.isDelete && (
|
|
132
132
|
<_TextInput
|
|
133
|
-
onChange={
|
|
134
|
-
|
|
133
|
+
onChange={setInputName}
|
|
134
|
+
value={inputName}
|
|
135
135
|
textInputStyle={styles.textInputStyle}
|
|
136
136
|
wrapStyle={styles.textInputWrapStyle}
|
|
137
137
|
selectionColor={Colors.Primary}
|
|
@@ -269,7 +269,12 @@ const ScriptDetail = ({ route }) => {
|
|
|
269
269
|
>
|
|
270
270
|
{item?.unit_name}
|
|
271
271
|
</Text>
|
|
272
|
-
<Text
|
|
272
|
+
<Text
|
|
273
|
+
numberOfLines={1}
|
|
274
|
+
type="Label"
|
|
275
|
+
color={Colors.Gray7}
|
|
276
|
+
style={styles.flex1}
|
|
277
|
+
>
|
|
273
278
|
{item?.station_name}
|
|
274
279
|
</Text>
|
|
275
280
|
</View>
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
SafeAreaView,
|
|
14
14
|
} from 'react-native';
|
|
15
15
|
import { useNavigation } from '@react-navigation/native';
|
|
16
|
-
import ImageResizer from 'react-native-image-resizer';
|
|
17
16
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
18
17
|
|
|
19
18
|
import { API, Colors } from '../../configs';
|
|
@@ -26,26 +25,6 @@ import { ToastBottomHelper } from '../../utils/Utils';
|
|
|
26
25
|
import { TESTID } from '../../configs/Constants';
|
|
27
26
|
import styles from './AddSubUnitStyles';
|
|
28
27
|
|
|
29
|
-
const MAX_FILE_SIZE_BYTES = 1.5 * 1024 * 1024; // 1.5mb
|
|
30
|
-
|
|
31
|
-
const prepareImageToUpload = async (image) => {
|
|
32
|
-
if (!image || image.size < MAX_FILE_SIZE_BYTES) {
|
|
33
|
-
return image;
|
|
34
|
-
}
|
|
35
|
-
const result = await ImageResizer.createResizedImage(
|
|
36
|
-
image.path,
|
|
37
|
-
1280,
|
|
38
|
-
1280,
|
|
39
|
-
'JPEG',
|
|
40
|
-
70
|
|
41
|
-
);
|
|
42
|
-
return {
|
|
43
|
-
fileName: result?.name,
|
|
44
|
-
type: 'image/jpeg',
|
|
45
|
-
uri: result?.uri,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
28
|
const AddSubUnit = ({ route }) => {
|
|
50
29
|
const t = useTranslations();
|
|
51
30
|
const { navigate, goBack } = useNavigation();
|
|
@@ -56,6 +35,13 @@ const AddSubUnit = ({ route }) => {
|
|
|
56
35
|
const [showImagePicker, setShowImagePicker] = useState(false);
|
|
57
36
|
let awaitCreate = useRef(false);
|
|
58
37
|
|
|
38
|
+
const cleanData = () => {
|
|
39
|
+
setRoomName('');
|
|
40
|
+
setWallpaper('');
|
|
41
|
+
setImageUrl('');
|
|
42
|
+
awaitCreate.current = false;
|
|
43
|
+
};
|
|
44
|
+
|
|
59
45
|
const goDone = useCallback(async () => {
|
|
60
46
|
if (isAddUnit) {
|
|
61
47
|
if (!awaitCreate.current) {
|
|
@@ -65,7 +51,6 @@ const AddSubUnit = ({ route }) => {
|
|
|
65
51
|
address: location,
|
|
66
52
|
background: wallpaper,
|
|
67
53
|
};
|
|
68
|
-
dataObj.background = await prepareImageToUpload(dataObj.background);
|
|
69
54
|
const formData = createFormData(dataObj, ['background']);
|
|
70
55
|
const { success, data } = await axiosPost(
|
|
71
56
|
API.UNIT.CREATE_UNIT(),
|
|
@@ -82,6 +67,7 @@ const AddSubUnit = ({ route }) => {
|
|
|
82
67
|
routeName: Routes.DashboardStack,
|
|
83
68
|
},
|
|
84
69
|
});
|
|
70
|
+
cleanData();
|
|
85
71
|
} else {
|
|
86
72
|
awaitCreate.current = false;
|
|
87
73
|
ToastBottomHelper.error(t('text_create_unit_fail'));
|
|
@@ -91,9 +77,8 @@ const AddSubUnit = ({ route }) => {
|
|
|
91
77
|
if (!awaitCreate.current) {
|
|
92
78
|
awaitCreate.current = true;
|
|
93
79
|
const dataObj = { name: roomName, background: wallpaper };
|
|
94
|
-
dataObj.background = await prepareImageToUpload(dataObj.background);
|
|
95
80
|
const formData = createFormData(dataObj, ['background']);
|
|
96
|
-
const { success
|
|
81
|
+
const { success } = await axiosPost(
|
|
97
82
|
API.SUB_UNIT.CREATE_SUB_UNIT(unit.id),
|
|
98
83
|
formData,
|
|
99
84
|
{
|
|
@@ -115,10 +100,12 @@ const AddSubUnit = ({ route }) => {
|
|
|
115
100
|
screen: Routes.UnitDetail,
|
|
116
101
|
params: {
|
|
117
102
|
unitId: unit.id,
|
|
118
|
-
unitData:
|
|
103
|
+
unitData: unit,
|
|
119
104
|
isAddSubUnit: true,
|
|
105
|
+
routeName: Routes.DashboardStack,
|
|
120
106
|
},
|
|
121
107
|
});
|
|
108
|
+
cleanData();
|
|
122
109
|
} else {
|
|
123
110
|
awaitCreate.current = false;
|
|
124
111
|
ToastBottomHelper.error(t('text_create_sub_unit_fail'));
|
|
@@ -188,6 +175,7 @@ const AddSubUnit = ({ route }) => {
|
|
|
188
175
|
textInputStyle={styles.roomName}
|
|
189
176
|
wrapStyle={styles.textInput}
|
|
190
177
|
selectionColor={Colors.Primary}
|
|
178
|
+
value={roomName}
|
|
191
179
|
/>
|
|
192
180
|
|
|
193
181
|
{isAddUnit && (
|
|
@@ -22,12 +22,12 @@ const TDSGuide = memo(() => {
|
|
|
22
22
|
>
|
|
23
23
|
{t('what_is_tds_title')}
|
|
24
24
|
</Text>
|
|
25
|
-
<Text
|
|
25
|
+
<Text style={styles.tdsText}>{t('what_is_tds_text')}</Text>
|
|
26
26
|
<Text type="H3" semibold style={styles.titlePadding}>
|
|
27
27
|
{t('tds_guidlines_title')}
|
|
28
28
|
</Text>
|
|
29
29
|
<>
|
|
30
|
-
<Text
|
|
30
|
+
<Text style={styles.tdsText}>
|
|
31
31
|
{t('tds_guidlines_text_1')}
|
|
32
32
|
{'\n'}
|
|
33
33
|
{'\n'}
|
|
@@ -56,4 +56,7 @@ const styles = StyleSheet.create({
|
|
|
56
56
|
paddingTop: 20,
|
|
57
57
|
paddingBottom: 10,
|
|
58
58
|
},
|
|
59
|
+
tdsText: {
|
|
60
|
+
fontSize: 15,
|
|
61
|
+
},
|
|
59
62
|
});
|
|
@@ -30,7 +30,9 @@ import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
|
30
30
|
|
|
31
31
|
const UnitDetail = ({ route }) => {
|
|
32
32
|
const t = useTranslations();
|
|
33
|
+
|
|
33
34
|
const { unitId, unitData, isOneTap, routeName, isAddSubUnit } = route.params;
|
|
35
|
+
|
|
34
36
|
const isFocused = useIsFocused();
|
|
35
37
|
const { stateData, setAction } = useContext(SCContext);
|
|
36
38
|
const { navigate } = useNavigation();
|
|
@@ -253,13 +255,14 @@ const UnitDetail = ({ route }) => {
|
|
|
253
255
|
};
|
|
254
256
|
|
|
255
257
|
const renderDetailSubUnit = () => {
|
|
256
|
-
if (station
|
|
258
|
+
if (station?.isFavorites) {
|
|
257
259
|
return (
|
|
258
260
|
<SubUnitFavorites
|
|
259
261
|
unit={unit}
|
|
260
262
|
isOwner={isOwner}
|
|
261
263
|
favorites={favorites}
|
|
262
264
|
wrapItemStyle={styles.wrapItemStyle}
|
|
265
|
+
isGGHomeConnected={isGGHomeConnected}
|
|
263
266
|
/>
|
|
264
267
|
);
|
|
265
268
|
}
|
package/src/utils/Apis/axios.js
CHANGED
|
@@ -2,7 +2,6 @@ import axios from 'axios';
|
|
|
2
2
|
import { deleteData, getData, storeData } from '../Storage';
|
|
3
3
|
import { ToastBottomHelper } from '../Utils';
|
|
4
4
|
import NetInfo from '@react-native-community/netinfo';
|
|
5
|
-
import { Platform } from 'react-native';
|
|
6
5
|
|
|
7
6
|
export const replaceParams = (apiURL, params) => {
|
|
8
7
|
let _result = apiURL;
|
|
@@ -166,9 +165,9 @@ export function createFormData(data, list_file_field) {
|
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
formData.append(key, {
|
|
169
|
-
uri: Platform.OS === 'ios' ? item.sourceURL : item.path,
|
|
170
|
-
type: item.mime,
|
|
171
168
|
name: item.filename || item.path?.split('/').pop(),
|
|
169
|
+
type: item.mime,
|
|
170
|
+
uri: item.path,
|
|
172
171
|
});
|
|
173
172
|
return;
|
|
174
173
|
}
|