@eohjsc/react-native-smart-city 0.2.56 → 0.2.60
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/Map/MarkerGeolocation.svg +4 -0
- package/assets/images/SonosSpeaker/buttonpause-active.svg +3 -0
- package/assets/images/SonosSpeaker/buttonpause-notactive.svg +3 -0
- package/assets/images/SonosSpeaker/picture-main-notactive.svg +5 -0
- package/assets/images/SonosSpeaker/picture-main.svg +6 -0
- package/assets/images/SonosSpeaker/picture-volume.svg +3 -0
- package/package.json +4 -22
- package/src/Images/Common/buttonLeftCurtain.png +0 -0
- package/src/Images/Common/buttonPause-center-curtain.png +0 -0
- package/src/Images/Common/buttonRightCurtain.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +139 -0
- package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +58 -0
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +72 -0
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/Auth/__test__/AccountList.test.js +33 -0
- package/src/commons/CameraDevice/index.js +2 -0
- package/src/commons/CardShadow/index.js +1 -1
- package/src/commons/CardShadow/styles.js +1 -3
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +1 -1
- package/src/commons/DateTimeRangeChange/index.js +2 -2
- package/src/commons/Device/HistoryChart.js +21 -55
- package/src/commons/Device/HorizontalBarChart.js +46 -30
- package/src/commons/Device/LinearChart.js +0 -34
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +2 -1
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +57 -0
- package/src/commons/Device/SonosSpeaker/index.js +88 -0
- package/src/commons/Device/SonosSpeaker/styles.js +57 -0
- package/src/commons/Form/CurrencyInput.js +169 -0
- package/src/commons/Form/__test__/CurrencyInput.test.js +65 -0
- package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +48 -0
- package/src/commons/FourButtonFilterHistory/index.js +72 -0
- package/src/commons/FourButtonFilterHistory/styles.js +22 -0
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +14 -0
- package/src/commons/MediaPlayerDetail/index.js +204 -161
- package/src/commons/SearchLocation/index.js +0 -1
- package/src/commons/Sharing/RowMember.js +7 -2
- package/src/commons/Sharing/__test__/RowMember.test.js +42 -0
- package/src/commons/SubUnit/ShortDetail.js +12 -6
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -1
- package/src/commons/UnitSummary/ConfigHistoryChart.js +2 -1
- package/src/configs/API.js +13 -3
- package/src/configs/Constants.js +14 -4
- package/src/configs/Images.js +3 -0
- package/src/configs/SCConfig.js +8 -0
- package/src/context/actionType.ts +5 -0
- package/src/context/mockStore.ts +3 -0
- package/src/context/reducer.ts +14 -0
- package/src/iot/RemoteControl/Bluetooth.js +14 -0
- package/src/iot/RemoteControl/index.js +0 -1
- package/src/navigations/UnitStack.js +42 -4
- package/src/screens/ActivityLog/FilterPopup.js +1 -1
- package/src/screens/ActivityLog/ItemLog.js +11 -2
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +46 -0
- package/src/screens/ActivityLog/hooks/index.js +1 -0
- package/src/screens/ActivityLog/index.js +0 -1
- package/src/screens/AddCommon/SelectSubUnit.js +24 -2
- package/src/screens/AddCommon/SelectUnit.js +12 -0
- package/src/screens/AddLocationMaps/index.js +139 -44
- package/src/screens/AddLocationMaps/indexStyle.js +14 -12
- package/src/screens/AddNewAction/SelectAction.js +1 -0
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
- package/src/screens/Automate/__test__/index.test.js +2 -0
- package/src/screens/Automate/index.js +4 -2
- package/src/screens/Device/__test__/detail.test.js +3 -7
- package/src/screens/Device/components/SensorDisplayItem.js +10 -10
- package/src/screens/Device/detail.js +65 -15
- package/src/screens/Device/hooks/useDisconnectedDevice.js +32 -26
- package/src/screens/Device/styles.js +3 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +59 -0
- package/src/screens/EmergencySetting/__test__/index.test.js +27 -0
- package/src/screens/EmergencySetting/components/DropDownItem.js +54 -0
- package/src/screens/EmergencySetting/index.js +90 -0
- package/src/screens/EmergencySetting/styles/DropDownItem.js +38 -0
- package/src/screens/EmergencySetting/styles.js +19 -0
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +126 -0
- package/src/screens/MoveToAnotherSubUnit/index.js +88 -0
- package/src/screens/MoveToAnotherSubUnit/styles/MoveToAnotherSubUnitStyles.js +50 -0
- package/src/screens/Notification/__test__/Notification.test.js +3 -3
- package/src/screens/Notification/components/NotificationItem.js +3 -6
- package/src/screens/Notification/index.js +2 -2
- package/src/screens/ScriptDetail/Styles/indexStyles.js +0 -1
- package/src/screens/ScriptDetail/__test__/index.test.js +13 -0
- package/src/screens/ScriptDetail/index.js +20 -17
- package/src/screens/SelectUnit/index.js +2 -0
- package/src/screens/Sharing/MemberList.js +2 -9
- package/src/screens/SubUnit/AddSubUnit.js +79 -59
- package/src/screens/SubUnit/AddSubUnitStyles.js +0 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +4 -3
- package/src/screens/TDSGuide/index.js +6 -4
- package/src/screens/Unit/ChooseLocation.js +96 -0
- package/src/screens/Unit/ChooseLocationStyles.js +26 -0
- package/src/screens/Unit/Detail.js +14 -2
- package/src/screens/Unit/ManageUnit.js +4 -5
- package/src/screens/Unit/SelectAddress.js +240 -0
- package/src/screens/Unit/SelectAddressStyles.js +48 -0
- package/src/screens/Unit/SmartAccountItem.js +1 -1
- package/src/screens/Unit/Summaries.js +5 -1
- package/src/screens/Unit/__test__/ChooseLocation.test.js +112 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +216 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +21 -5
- package/src/screens/Unit/hook/useStateAlertRemove.js +3 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +3 -2
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +1 -3
- package/src/screens/UnitSummary/index.js +3 -2
- package/src/screens/WaterQualityGuide/index.js +1 -0
- package/src/utils/Apis/axios.js +17 -5
- package/src/utils/I18n/translations/en.json +19 -4
- package/src/utils/I18n/translations/vi.json +22 -7
- package/src/utils/Route/index.js +4 -1
- package/src/utils/Utils.js +22 -2
- package/assets/images/AddLocationMaps/PinLocation.svg +0 -3
- package/assets/images/AddLocationMaps/Point.svg +0 -3
- package/src/commons/ThreeButtonHistory/CalendarHeader.js +0 -35
- package/src/commons/ThreeButtonHistory/CalendarHeaderStyles.js +0 -17
- package/src/commons/ThreeButtonHistory/SelectMonth.js +0 -53
- package/src/commons/ThreeButtonHistory/SelectMonthStyles.js +0 -29
- package/src/commons/ThreeButtonHistory/__test__/SelectMonth.test.js +0 -37
- package/src/commons/ThreeButtonHistory/__test__/ThreeButtonHistory.test.js +0 -231
- package/src/commons/ThreeButtonHistory/index.js +0 -281
- package/src/commons/ThreeButtonHistory/styles.js +0 -65
- package/src/screens/Unit/ManageUnit/index.js +0 -286
- package/src/screens/Unit/SelectLocation.js +0 -161
- package/src/screens/Unit/SelectLocationStyles.js +0 -114
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
StyleSheet,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
Image,
|
|
7
|
-
Platform,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import Animated from 'react-native-reanimated';
|
|
10
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
11
|
-
|
|
12
|
-
import { Colors, API, Device } from '../../../configs';
|
|
13
|
-
import Routes from '../../../utils/Route';
|
|
14
|
-
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
15
|
-
import {
|
|
16
|
-
createFormData,
|
|
17
|
-
axiosPatch,
|
|
18
|
-
axiosDelete,
|
|
19
|
-
} from '../../../utils/Apis/axios';
|
|
20
|
-
import { navigate } from '../../../navigations/utils';
|
|
21
|
-
import useBoolean from '../../../hooks/Common/useBoolean';
|
|
22
|
-
import useKeyboardAnimated from '../../../hooks/Explore/useKeyboardAnimated';
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
AlertAction,
|
|
26
|
-
Section,
|
|
27
|
-
ViewButtonBottom,
|
|
28
|
-
ImagePicker,
|
|
29
|
-
} from '../../../commons';
|
|
30
|
-
|
|
31
|
-
import Text from '../../../commons/Text';
|
|
32
|
-
import _TextInput from '../../../commons/Form/TextInput';
|
|
33
|
-
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
34
|
-
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
35
|
-
import { useIsOwnerOfUnit } from '../../../hooks/Common';
|
|
36
|
-
import { TESTID } from '../../../configs/Constants';
|
|
37
|
-
import { ModalCustom } from '../../../commons/Modal';
|
|
38
|
-
|
|
39
|
-
const ManageUnit = ({ route }) => {
|
|
40
|
-
const t = useTranslations();
|
|
41
|
-
const { unit } = route.params;
|
|
42
|
-
const { isOwner } = useIsOwnerOfUnit(unit.user_id);
|
|
43
|
-
const [showEdit, setshowEdit, setHideEdit] = useBoolean();
|
|
44
|
-
const [unitName, setUnitName] = useState(unit.name);
|
|
45
|
-
const [imageUrl, setImageUrl] = useState('');
|
|
46
|
-
const [showImagePicker, setShowImagePicker] = useState(false);
|
|
47
|
-
|
|
48
|
-
const updateUnit = useCallback(
|
|
49
|
-
async (headers) => {
|
|
50
|
-
const formData = createFormData(imageUrl, ['background']);
|
|
51
|
-
|
|
52
|
-
const { success } = await axiosPatch(
|
|
53
|
-
API.UNIT.MANAGE_UNIT(unit.id),
|
|
54
|
-
formData,
|
|
55
|
-
headers
|
|
56
|
-
);
|
|
57
|
-
if (success) {
|
|
58
|
-
ToastBottomHelper.success(t('unit_updated_successfully'));
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
[imageUrl, unit.id, t]
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const goRename = useCallback(async () => {
|
|
65
|
-
await updateUnit({ name: unitName }, {});
|
|
66
|
-
setHideEdit(true);
|
|
67
|
-
}, [unitName, setHideEdit, updateUnit]);
|
|
68
|
-
|
|
69
|
-
const handleChoosePhoto = useCallback(() => {
|
|
70
|
-
setShowImagePicker(true);
|
|
71
|
-
}, [setShowImagePicker]);
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (imageUrl) {
|
|
75
|
-
updateUnit({
|
|
76
|
-
headers: { 'Content-Type': 'multipart/form-data' },
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}, [imageUrl, updateUnit]);
|
|
80
|
-
|
|
81
|
-
const [showRemove, setshowRemove, setHideRemove] = useBoolean();
|
|
82
|
-
const goRemove = useCallback(async () => {
|
|
83
|
-
const { success } = await axiosDelete(API.UNIT.MANAGE_UNIT(unit.id));
|
|
84
|
-
if (success) {
|
|
85
|
-
setHideEdit(true);
|
|
86
|
-
ToastBottomHelper.success(t('unit_deleted_successfully'));
|
|
87
|
-
navigate(Routes.Dashboard);
|
|
88
|
-
}
|
|
89
|
-
}, [unit.id, setHideEdit, t]);
|
|
90
|
-
|
|
91
|
-
const [transY] = useKeyboardAnimated(-16);
|
|
92
|
-
const animatedStyle = Platform.select({
|
|
93
|
-
ios: {
|
|
94
|
-
marginBottom: transY,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const options = {
|
|
99
|
-
mediaType: 'photo',
|
|
100
|
-
maxWidth: 1024,
|
|
101
|
-
quality: 0.8,
|
|
102
|
-
includeBase64: Device.isIOS,
|
|
103
|
-
saveToPhotos: true,
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<>
|
|
108
|
-
<WrapHeaderScrollable title={t('manage_unit')}>
|
|
109
|
-
<View style={styles.wraper}>
|
|
110
|
-
{isOwner && (
|
|
111
|
-
<Section type={'border'}>
|
|
112
|
-
<TouchableOpacity
|
|
113
|
-
onPress={setshowEdit}
|
|
114
|
-
testID={TESTID.TOUCH_UNIT_IN_MANAGE_UNIT}
|
|
115
|
-
>
|
|
116
|
-
<Text style={[styles.textWraper, styles.unitName]}>
|
|
117
|
-
{unit.name}
|
|
118
|
-
</Text>
|
|
119
|
-
</TouchableOpacity>
|
|
120
|
-
|
|
121
|
-
<TouchableOpacity style={[styles.textWraper]}>
|
|
122
|
-
<Text style={styles.unitName}>{t('geolocation')}</Text>
|
|
123
|
-
<Text style={styles.unitGeolocation}>{unit.address}</Text>
|
|
124
|
-
</TouchableOpacity>
|
|
125
|
-
<TouchableOpacity
|
|
126
|
-
style={[styles.backgroundContainer]}
|
|
127
|
-
onPress={handleChoosePhoto}
|
|
128
|
-
>
|
|
129
|
-
<Text style={[styles.unitName, styles.textBackground]}>
|
|
130
|
-
{t('background')}
|
|
131
|
-
</Text>
|
|
132
|
-
<Image
|
|
133
|
-
style={styles.image}
|
|
134
|
-
source={{ uri: unit.background }}
|
|
135
|
-
resizeMode="cover"
|
|
136
|
-
/>
|
|
137
|
-
</TouchableOpacity>
|
|
138
|
-
|
|
139
|
-
<ImagePicker
|
|
140
|
-
showImagePicker={showImagePicker}
|
|
141
|
-
setShowImagePicker={setShowImagePicker}
|
|
142
|
-
setImageUrl={setImageUrl}
|
|
143
|
-
optionsCapture={options}
|
|
144
|
-
/>
|
|
145
|
-
</Section>
|
|
146
|
-
)}
|
|
147
|
-
</View>
|
|
148
|
-
</WrapHeaderScrollable>
|
|
149
|
-
<TouchableOpacity style={styles.removeButton} onPress={setshowRemove}>
|
|
150
|
-
<Text type={'H4'} semibold color={Colors.Gray6}>
|
|
151
|
-
{t('remove_unit')}
|
|
152
|
-
</Text>
|
|
153
|
-
</TouchableOpacity>
|
|
154
|
-
<ModalCustom
|
|
155
|
-
isVisible={showEdit}
|
|
156
|
-
onBackButtonPress={setHideEdit}
|
|
157
|
-
onBackdropPress={setHideEdit}
|
|
158
|
-
style={styles.modalContainer}
|
|
159
|
-
>
|
|
160
|
-
<Animated.View style={[styles.popoverStyle, animatedStyle]}>
|
|
161
|
-
<View style={styles.modalWrapper}>
|
|
162
|
-
<View style={styles.modalHeader}>
|
|
163
|
-
<Text semibold style={styles.modalHeaderText}>
|
|
164
|
-
{t('rename_unit')}
|
|
165
|
-
</Text>
|
|
166
|
-
</View>
|
|
167
|
-
<_TextInput
|
|
168
|
-
defaultValue={unitName}
|
|
169
|
-
onChange={(value) => setUnitName(value)}
|
|
170
|
-
textInputStyle={styles.textInputStyle}
|
|
171
|
-
wrapStyle={styles.textInputWrapStyle}
|
|
172
|
-
selectionColor={Colors.Primary}
|
|
173
|
-
/>
|
|
174
|
-
|
|
175
|
-
<ViewButtonBottom
|
|
176
|
-
leftTitle={t('cancel')}
|
|
177
|
-
onLeftClick={setHideEdit}
|
|
178
|
-
rightTitle={t('rename')}
|
|
179
|
-
onRightClick={goRename}
|
|
180
|
-
/>
|
|
181
|
-
</View>
|
|
182
|
-
</Animated.View>
|
|
183
|
-
</ModalCustom>
|
|
184
|
-
<AlertAction
|
|
185
|
-
visible={showRemove}
|
|
186
|
-
hideModal={setHideRemove}
|
|
187
|
-
title={t('remove_unit_name', { name: unitName })}
|
|
188
|
-
message={t('remove_note')}
|
|
189
|
-
leftButtonTitle={t('cancel')}
|
|
190
|
-
leftButtonClick={setHideRemove}
|
|
191
|
-
rightButtonTitle={t('remove')}
|
|
192
|
-
rightButtonClick={goRemove}
|
|
193
|
-
/>
|
|
194
|
-
</>
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const styles = StyleSheet.create({
|
|
199
|
-
wraper: {
|
|
200
|
-
flex: 1,
|
|
201
|
-
},
|
|
202
|
-
textWraper: {
|
|
203
|
-
paddingTop: 16,
|
|
204
|
-
paddingBottom: 16,
|
|
205
|
-
borderBottomWidth: 0.5,
|
|
206
|
-
},
|
|
207
|
-
unitName: {
|
|
208
|
-
fontStyle: 'normal',
|
|
209
|
-
fontWeight: 'normal',
|
|
210
|
-
fontSize: 16,
|
|
211
|
-
lineHeight: 24,
|
|
212
|
-
color: Colors.Gray9,
|
|
213
|
-
},
|
|
214
|
-
unitGeolocation: {
|
|
215
|
-
fontSize: 14,
|
|
216
|
-
lineHeight: 22,
|
|
217
|
-
color: Colors.Primary,
|
|
218
|
-
},
|
|
219
|
-
removeButton: {
|
|
220
|
-
position: 'absolute',
|
|
221
|
-
bottom: 0,
|
|
222
|
-
borderWidth: 0,
|
|
223
|
-
alignSelf: 'center',
|
|
224
|
-
paddingBottom: 16 + getBottomSpace(),
|
|
225
|
-
},
|
|
226
|
-
backgroundContainer: {
|
|
227
|
-
alignItems: 'center',
|
|
228
|
-
flexDirection: 'row',
|
|
229
|
-
borderBottomWidth: 0.5,
|
|
230
|
-
},
|
|
231
|
-
image: {
|
|
232
|
-
width: 40,
|
|
233
|
-
height: 40,
|
|
234
|
-
borderRadius: 40 / 2,
|
|
235
|
-
},
|
|
236
|
-
textBackground: {
|
|
237
|
-
flex: 1,
|
|
238
|
-
paddingTop: 16,
|
|
239
|
-
paddingBottom: 16,
|
|
240
|
-
},
|
|
241
|
-
modalContainer: {
|
|
242
|
-
flex: 1,
|
|
243
|
-
margin: 0,
|
|
244
|
-
},
|
|
245
|
-
popoverStyle: {
|
|
246
|
-
width: '100%',
|
|
247
|
-
backgroundColor: Colors.White,
|
|
248
|
-
bottom: 0,
|
|
249
|
-
left: 0,
|
|
250
|
-
position: 'absolute',
|
|
251
|
-
borderRadius: 10,
|
|
252
|
-
},
|
|
253
|
-
modalWrapper: {
|
|
254
|
-
flex: 1,
|
|
255
|
-
flexDirection: 'column',
|
|
256
|
-
backgroundColor: Colors.White,
|
|
257
|
-
borderRadius: 10,
|
|
258
|
-
},
|
|
259
|
-
modalHeader: {
|
|
260
|
-
padding: 16,
|
|
261
|
-
backgroundColor: Colors.White,
|
|
262
|
-
borderBottomWidth: 1,
|
|
263
|
-
borderTopLeftRadius: 20,
|
|
264
|
-
borderTopRightRadius: 20,
|
|
265
|
-
borderColor: Colors.Gray4,
|
|
266
|
-
},
|
|
267
|
-
modalHeaderText: {
|
|
268
|
-
fontSize: 16,
|
|
269
|
-
lineHeight: 24,
|
|
270
|
-
color: Colors.Gray9,
|
|
271
|
-
},
|
|
272
|
-
textInputStyle: {
|
|
273
|
-
borderWidth: 0,
|
|
274
|
-
borderBottomWidth: 1,
|
|
275
|
-
borderBottomColor: Colors.Primary,
|
|
276
|
-
fontSize: 16,
|
|
277
|
-
marginLeft: 16,
|
|
278
|
-
marginRight: 16,
|
|
279
|
-
paddingHorizontal: 0,
|
|
280
|
-
},
|
|
281
|
-
textInputWrapStyle: {
|
|
282
|
-
marginTop: 0,
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
export default ManageUnit;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import React, { memo, useCallback, useRef, useState } from 'react';
|
|
3
|
-
import { View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import MapView, { Marker, PROVIDER_GOOGLE } from 'react-native-maps';
|
|
6
|
-
import BottomButtonView from '../../commons/BottomButtonView';
|
|
7
|
-
|
|
8
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
9
|
-
import { API } from '../../configs';
|
|
10
|
-
import styles from './SelectLocationStyles';
|
|
11
|
-
import SearchBarLocation from '../../commons/SearchLocation';
|
|
12
|
-
import RowLocation from '../../commons/SearchLocation/RowLocation';
|
|
13
|
-
import { axiosGet } from '../../utils/Apis/axios';
|
|
14
|
-
import { ScrollView } from 'react-native';
|
|
15
|
-
import { useNavigation } from '@react-navigation/native';
|
|
16
|
-
import { SCConfig } from '../../configs';
|
|
17
|
-
import Point from '../../../assets/images/AddLocationMaps/Point.svg';
|
|
18
|
-
|
|
19
|
-
const initialRegion = {
|
|
20
|
-
latitudeDelta: 0.0922,
|
|
21
|
-
longitudeDelta: 0.0421,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const DEFAULT_LATITUDE = 10.7974046; // EoH center
|
|
25
|
-
const DEFAULT_LONGITUDE = 106.7035663;
|
|
26
|
-
|
|
27
|
-
const SelectLocation = memo(({ route }) => {
|
|
28
|
-
const t = useTranslations();
|
|
29
|
-
const { updateLocation } = route.params;
|
|
30
|
-
const { goBack } = useNavigation();
|
|
31
|
-
const [input, setInput] = useState('');
|
|
32
|
-
const [searchData, setSearchData] = useState([]);
|
|
33
|
-
const [searchedLocation, setSearchedLocation] = useState(null);
|
|
34
|
-
const mapRef = useRef(null);
|
|
35
|
-
|
|
36
|
-
const onTextInput = useCallback(async (input) => {
|
|
37
|
-
setInput(input);
|
|
38
|
-
if (!input) {
|
|
39
|
-
setSearchData([]);
|
|
40
|
-
setSearchedLocation(null);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
const config = {
|
|
45
|
-
params: {
|
|
46
|
-
input: input,
|
|
47
|
-
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
48
|
-
sessiontoken: 123456324,
|
|
49
|
-
strictBounds: false,
|
|
50
|
-
types: ['establishment'],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const { success, data } = await axiosGet(
|
|
55
|
-
API.EXTERNAL.GOOGLE_MAP.AUTO_COMPLETE,
|
|
56
|
-
config
|
|
57
|
-
);
|
|
58
|
-
if (success) {
|
|
59
|
-
setSearchData(data.predictions);
|
|
60
|
-
}
|
|
61
|
-
} catch (error) {}
|
|
62
|
-
}, []);
|
|
63
|
-
|
|
64
|
-
const animateToRegion = useCallback((lat, lng) => {
|
|
65
|
-
if (!mapRef || !mapRef.current) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
mapRef.current.animateToRegion(
|
|
70
|
-
{
|
|
71
|
-
latitude: lat,
|
|
72
|
-
longitude: lng,
|
|
73
|
-
...initialRegion,
|
|
74
|
-
},
|
|
75
|
-
600
|
|
76
|
-
);
|
|
77
|
-
}, []);
|
|
78
|
-
|
|
79
|
-
const onPressRowLocation = useCallback(async (item) => {
|
|
80
|
-
setInput(item.description);
|
|
81
|
-
setSearchData([]);
|
|
82
|
-
const body = {
|
|
83
|
-
params: {
|
|
84
|
-
place_id: item.place_id,
|
|
85
|
-
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const { success, data } = await axiosGet(
|
|
90
|
-
API.EXTERNAL.GOOGLE_MAP.GET_LAT_LNG_BY_PLACE_ID,
|
|
91
|
-
body
|
|
92
|
-
);
|
|
93
|
-
if (success) {
|
|
94
|
-
const { location } = data.result.geometry;
|
|
95
|
-
animateToRegion(location.lat, location.lng);
|
|
96
|
-
setSearchedLocation({
|
|
97
|
-
description: item.description,
|
|
98
|
-
latitude: location.lat,
|
|
99
|
-
longitude: location.lng,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}, []);
|
|
103
|
-
|
|
104
|
-
const onDone = useCallback(() => {
|
|
105
|
-
if (!searchedLocation) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
updateLocation(searchedLocation.description);
|
|
110
|
-
goBack();
|
|
111
|
-
}, [goBack, updateLocation, searchedLocation]);
|
|
112
|
-
return (
|
|
113
|
-
<View style={styles.wrap}>
|
|
114
|
-
<View style={styles.searchLocation}>
|
|
115
|
-
<SearchBarLocation input={input} onTextInput={onTextInput} />
|
|
116
|
-
<ScrollView style={styles.searchData}>
|
|
117
|
-
{searchData.map((item) => (
|
|
118
|
-
<RowLocation item={item} onPress={onPressRowLocation} />
|
|
119
|
-
))}
|
|
120
|
-
</ScrollView>
|
|
121
|
-
</View>
|
|
122
|
-
<MapView
|
|
123
|
-
ref={mapRef}
|
|
124
|
-
provider={PROVIDER_GOOGLE}
|
|
125
|
-
style={styles.mapView}
|
|
126
|
-
initialRegion={{
|
|
127
|
-
...initialRegion,
|
|
128
|
-
latitude: DEFAULT_LATITUDE,
|
|
129
|
-
longitude: DEFAULT_LONGITUDE,
|
|
130
|
-
}}
|
|
131
|
-
followUserLocation={true}
|
|
132
|
-
>
|
|
133
|
-
{searchedLocation && (
|
|
134
|
-
<Marker
|
|
135
|
-
coordinate={{
|
|
136
|
-
latitude: searchedLocation.latitude,
|
|
137
|
-
longitude: searchedLocation.longitude,
|
|
138
|
-
}}
|
|
139
|
-
tracksViewChanges={false}
|
|
140
|
-
>
|
|
141
|
-
<View style={styles.pointCircle}>
|
|
142
|
-
<Point />
|
|
143
|
-
</View>
|
|
144
|
-
</Marker>
|
|
145
|
-
)}
|
|
146
|
-
</MapView>
|
|
147
|
-
<BottomButtonView
|
|
148
|
-
rowButton
|
|
149
|
-
style={styles.bottomButton}
|
|
150
|
-
mainTitle={t('done')}
|
|
151
|
-
onPressMain={onDone}
|
|
152
|
-
secondaryTitle={t('cancel')}
|
|
153
|
-
onPressSecondary={goBack}
|
|
154
|
-
typeMain="primaryText"
|
|
155
|
-
typeSecondary="primaryText"
|
|
156
|
-
/>
|
|
157
|
-
</View>
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
export default SelectLocation;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../configs';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
wrap: {
|
|
6
|
-
flex: 1,
|
|
7
|
-
},
|
|
8
|
-
mapView: {
|
|
9
|
-
position: 'absolute',
|
|
10
|
-
top: 0,
|
|
11
|
-
left: 0,
|
|
12
|
-
right: 0,
|
|
13
|
-
bottom: 0,
|
|
14
|
-
},
|
|
15
|
-
bottomButton: {
|
|
16
|
-
backgroundColor: Colors.White,
|
|
17
|
-
},
|
|
18
|
-
pointCircle: {
|
|
19
|
-
flex: 1,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
justifyContent: 'center',
|
|
22
|
-
width: 109,
|
|
23
|
-
height: 109,
|
|
24
|
-
borderRadius: 50,
|
|
25
|
-
backgroundColor: Colors.BlueTransparent5,
|
|
26
|
-
borderWidth: 1,
|
|
27
|
-
borderColor: Colors.Blue10,
|
|
28
|
-
},
|
|
29
|
-
searchLocation: {
|
|
30
|
-
paddingVertical: 8,
|
|
31
|
-
position: 'absolute',
|
|
32
|
-
zIndex: 1,
|
|
33
|
-
minHeight: 48,
|
|
34
|
-
top: 0,
|
|
35
|
-
left: 0,
|
|
36
|
-
right: 0,
|
|
37
|
-
flex: 1,
|
|
38
|
-
backgroundColor: Colors.White,
|
|
39
|
-
},
|
|
40
|
-
searchData: {
|
|
41
|
-
paddingHorizontal: 16,
|
|
42
|
-
position: 'relative',
|
|
43
|
-
width: '100%',
|
|
44
|
-
maxHeight: 100,
|
|
45
|
-
},
|
|
46
|
-
buttonShadow: {
|
|
47
|
-
shadowColor: Colors.Gray11,
|
|
48
|
-
shadowOffset: {
|
|
49
|
-
width: 0,
|
|
50
|
-
height: 8,
|
|
51
|
-
},
|
|
52
|
-
shadowOpacity: 1,
|
|
53
|
-
shadowRadius: 12,
|
|
54
|
-
elevation: 5,
|
|
55
|
-
marginBottom: 16,
|
|
56
|
-
marginRight: 16,
|
|
57
|
-
},
|
|
58
|
-
center: {
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
alignItems: 'center',
|
|
61
|
-
},
|
|
62
|
-
fullWidth: {
|
|
63
|
-
width: '100%',
|
|
64
|
-
},
|
|
65
|
-
button: {
|
|
66
|
-
paddingHorizontal: 30,
|
|
67
|
-
paddingVertical: 9,
|
|
68
|
-
backgroundColor: Colors.White,
|
|
69
|
-
borderColor: Colors.Gray4,
|
|
70
|
-
borderWidth: 1,
|
|
71
|
-
borderRadius: 30,
|
|
72
|
-
},
|
|
73
|
-
activeSessionView: {
|
|
74
|
-
marginHorizontal: 16,
|
|
75
|
-
},
|
|
76
|
-
popupIcon: {
|
|
77
|
-
marginLeft: '44%',
|
|
78
|
-
marginBottom: 15,
|
|
79
|
-
},
|
|
80
|
-
popupTitle: {
|
|
81
|
-
alignSelf: 'center',
|
|
82
|
-
marginBottom: 15,
|
|
83
|
-
},
|
|
84
|
-
popupDes: {
|
|
85
|
-
alignSelf: 'center',
|
|
86
|
-
textAlign: 'center',
|
|
87
|
-
width: '95%',
|
|
88
|
-
},
|
|
89
|
-
buttonAgree: {
|
|
90
|
-
flex: 1,
|
|
91
|
-
flexDirection: 'row',
|
|
92
|
-
paddingHorizontal: 16,
|
|
93
|
-
paddingTop: 16,
|
|
94
|
-
alignItems: 'center',
|
|
95
|
-
justifyContent: 'center',
|
|
96
|
-
},
|
|
97
|
-
titleContainer: {
|
|
98
|
-
justifyContent: 'center',
|
|
99
|
-
flexDirection: 'row',
|
|
100
|
-
alignItems: 'center',
|
|
101
|
-
flex: 1,
|
|
102
|
-
marginTop: 30,
|
|
103
|
-
},
|
|
104
|
-
childrenStyle: {
|
|
105
|
-
padding: 16,
|
|
106
|
-
},
|
|
107
|
-
scrollViewTerm: {
|
|
108
|
-
height: 300,
|
|
109
|
-
borderBottomWidth: 1,
|
|
110
|
-
borderTopWidth: 1,
|
|
111
|
-
borderTopColor: Colors.WrapGray,
|
|
112
|
-
borderBottomColor: Colors.WrapGray,
|
|
113
|
-
},
|
|
114
|
-
});
|