ordering-ui-react-native 0.12.52 → 0.12.53
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
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { Dimensions, StyleSheet, View, SafeAreaView } from 'react-native';
|
|
3
|
-
import MapView, { PROVIDER_GOOGLE, Marker, Region } from 'react-native-maps';
|
|
3
|
+
import MapView, { PROVIDER_GOOGLE, Marker, Region, Callout } from 'react-native-maps';
|
|
4
4
|
import Geocoder from 'react-native-geocoding';
|
|
5
5
|
import { useLanguage, useConfig, useUtils } from 'ordering-components/native';
|
|
6
6
|
import { GoogleMapsParams } from '../../types';
|
|
7
7
|
import Alert from '../../providers/AlertProvider';
|
|
8
|
-
import { OIconButton, OIcon } from '../shared';
|
|
8
|
+
import { OIconButton, OIcon, OText, OButton } from '../shared';
|
|
9
9
|
import { FloatingButton } from '../FloatingButton';
|
|
10
10
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
11
11
|
import { useTheme } from 'styled-components/native';
|
|
12
12
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
13
|
+
import { useLocation } from '../../hooks/useLocation';
|
|
14
|
+
import { showLocation } from 'react-native-map-link';
|
|
13
15
|
|
|
14
16
|
export const GoogleMap = (props: GoogleMapsParams) => {
|
|
15
17
|
const {
|
|
@@ -30,6 +32,15 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
30
32
|
navigation,
|
|
31
33
|
} = props;
|
|
32
34
|
|
|
35
|
+
const {
|
|
36
|
+
hasLocation,
|
|
37
|
+
initialPosition,
|
|
38
|
+
followUserLocation,
|
|
39
|
+
getCurrentLocation,
|
|
40
|
+
userLocation,
|
|
41
|
+
stopFollowUserLocation,
|
|
42
|
+
} = useLocation();
|
|
43
|
+
|
|
33
44
|
const { top } = useSafeAreaInsets();
|
|
34
45
|
const theme = useTheme();
|
|
35
46
|
const [, t] = useLanguage();
|
|
@@ -64,7 +75,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
64
75
|
ERROR_MAX_LIMIT_LOCATION_TO: 'Sorry, You can only set the position to',
|
|
65
76
|
};
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
let MARKERS =
|
|
68
79
|
locations &&
|
|
69
80
|
locations.map((location: { lat: number; lng: number; level: number }) => {
|
|
70
81
|
return location.level === 4 && driverLocation?.lat
|
|
@@ -221,6 +232,18 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
221
232
|
fitAllMarkers();
|
|
222
233
|
}
|
|
223
234
|
}, [isMapReady]);
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (!locations) return
|
|
237
|
+
MARKERS = locations.map((location: { lat: number; lng: number; level: number }) => {
|
|
238
|
+
return location.level === 4 && driverLocation?.lat
|
|
239
|
+
? {
|
|
240
|
+
latitude: driverLocation?.lat,
|
|
241
|
+
longitude: driverLocation?.lng,
|
|
242
|
+
}
|
|
243
|
+
: { latitude: location.lat, longitude: location.lng };
|
|
244
|
+
})
|
|
245
|
+
fitAllMarkers();
|
|
246
|
+
}, [driverLocation])
|
|
224
247
|
|
|
225
248
|
const styles = StyleSheet.create({
|
|
226
249
|
map: {
|
|
@@ -279,7 +302,13 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
279
302
|
i: number,
|
|
280
303
|
) => (
|
|
281
304
|
<React.Fragment key={i}>
|
|
282
|
-
<Marker
|
|
305
|
+
<Marker
|
|
306
|
+
coordinate={location}
|
|
307
|
+
onPress={() => {
|
|
308
|
+
mapRef.current?.animateCamera({
|
|
309
|
+
center: { latitude: location.latitude, longitude:location.longitude },
|
|
310
|
+
})}}
|
|
311
|
+
>
|
|
283
312
|
<Icon
|
|
284
313
|
name="map-marker"
|
|
285
314
|
size={50}
|
|
@@ -296,6 +325,51 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
296
325
|
height={25}
|
|
297
326
|
/>
|
|
298
327
|
</View>
|
|
328
|
+
<Callout
|
|
329
|
+
onPress={() => {
|
|
330
|
+
showLocation({
|
|
331
|
+
latitude: location.latitude,
|
|
332
|
+
longitude: location.longitude,
|
|
333
|
+
sourceLatitude: userLocation.latitude,
|
|
334
|
+
sourceLongitude: userLocation.longitude,
|
|
335
|
+
naverCallerName: 'com.businessapp',
|
|
336
|
+
dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
|
|
337
|
+
dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
|
|
338
|
+
cancelText: t('CANCEL', 'Cancel'),
|
|
339
|
+
})
|
|
340
|
+
}}
|
|
341
|
+
>
|
|
342
|
+
<View style={{flex: 1,width: 250, paddingRight: 10, paddingLeft: 10, justifyContent:'space-between' }}>
|
|
343
|
+
<View style={{flex: 1, marginBottom: 20}}>
|
|
344
|
+
<OText size={16} weight={'bold'} style={{paddingTop: 10, marginBottom: 10}}>{locations[i]?.title}</OText>
|
|
345
|
+
{ locations[i]?.address && (
|
|
346
|
+
<>
|
|
347
|
+
<OText size={16} >{locations[i]?.address.addressName}</OText>
|
|
348
|
+
<OText size={16} >{locations[i]?.address.zipcode}</OText>
|
|
349
|
+
</>
|
|
350
|
+
)}
|
|
351
|
+
</View>
|
|
352
|
+
<OButton
|
|
353
|
+
text={t('GO_TO_THIS_LOCATION', 'Go to this location')}
|
|
354
|
+
imgRightSrc={null}
|
|
355
|
+
textStyle={{
|
|
356
|
+
color: theme.colors.white,
|
|
357
|
+
fontFamily: 'Poppins',
|
|
358
|
+
fontStyle: 'normal',
|
|
359
|
+
fontWeight: 'normal',
|
|
360
|
+
fontSize: 16
|
|
361
|
+
}}
|
|
362
|
+
style={{
|
|
363
|
+
alignContent:'center',
|
|
364
|
+
borderRadius: 10,
|
|
365
|
+
height: 35,
|
|
366
|
+
bottom:10
|
|
367
|
+
}}
|
|
368
|
+
bgColor={theme.colors.primary}
|
|
369
|
+
borderColor={theme.colors.primary}
|
|
370
|
+
/>
|
|
371
|
+
</View>
|
|
372
|
+
</Callout>
|
|
299
373
|
</Marker>
|
|
300
374
|
</React.Fragment>
|
|
301
375
|
),
|
|
@@ -319,10 +319,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
319
319
|
}
|
|
320
320
|
}, [messagesReadList]);
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
let locations = [
|
|
323
323
|
{
|
|
324
324
|
...order?.driver?.location,
|
|
325
|
-
title: t('DRIVER', 'Driver'),
|
|
325
|
+
title: order?.driver?.name ?? t('DRIVER', 'Driver'),
|
|
326
326
|
icon:
|
|
327
327
|
order?.driver?.photo ||
|
|
328
328
|
'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://www.freeiconspng.com/thumbs/driver-icon/driver-icon-14.png',
|
|
@@ -331,12 +331,20 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
331
331
|
{
|
|
332
332
|
...order?.business?.location,
|
|
333
333
|
title: order?.business?.name,
|
|
334
|
+
address: {
|
|
335
|
+
addressName: order?.business?.address,
|
|
336
|
+
zipcode: order?.business?.zipcode
|
|
337
|
+
},
|
|
334
338
|
icon: order?.business?.logo || theme.images.dummies.businessLogo,
|
|
335
339
|
level: 2,
|
|
336
340
|
},
|
|
337
341
|
{
|
|
338
342
|
...order?.customer?.location,
|
|
339
|
-
title: t('CUSTOMER', 'Customer'),
|
|
343
|
+
title: order?.customer?.name ?? t('CUSTOMER', 'Customer'),
|
|
344
|
+
address: {
|
|
345
|
+
addressName: order?.customer?.address,
|
|
346
|
+
zipcode: order?.customer?.zipcode
|
|
347
|
+
},
|
|
340
348
|
icon:
|
|
341
349
|
order?.customer?.photo ||
|
|
342
350
|
'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
|