ordering-ui-react-native 0.17.24-release → 0.17.24-test1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.24-release",
3
+ "version": "0.17.24-test1",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -351,6 +351,9 @@ const AddressFormUI = (props: AddressFormParams) => {
351
351
  map_data: { library: 'google', place_id: data.place_id },
352
352
  zip_code: data?.zip_code || null,
353
353
  };
354
+ if (googleInput?.current) {
355
+ googleInput?.current?.setAddressText(addressSelected.address);
356
+ }
354
357
  updateChanges(addressSelected);
355
358
  };
356
359
 
@@ -44,7 +44,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
44
44
  ERROR_MAX_LIMIT_LOCATION: `Sorry, You can only set the position to ${maxLimitLocation}m`
45
45
  }
46
46
 
47
- const geocodePosition = (pos: { latitude: number, longitude: number }) => {
47
+ const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion ?: boolean) => {
48
48
  Geocoder.from({
49
49
  latitude: pos.latitude,
50
50
  longitude: pos.longitude
@@ -69,7 +69,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
69
69
  }
70
70
  handleChangeAddressMap && handleChangeAddressMap(address, details)
71
71
  setSaveLocation && setSaveLocation(false)
72
- handleToggleMap && handleToggleMap()
72
+ if(!isMovingRegion){
73
+ handleToggleMap && handleToggleMap()
74
+ }
73
75
  } else {
74
76
  setMapErrors && setMapErrors('ERROR_NOT_FOUND_ADDRESS')
75
77
  }
@@ -93,6 +95,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
93
95
  const _maxLimitLocation = typeof maxLimitLocation === 'string' ? parseInt(maxLimitLocation, 10) : maxLimitLocation
94
96
 
95
97
  if (distance <= _maxLimitLocation) {
98
+ if (!aproxEqual(curPos.latitude, center.lat) || !aproxEqual(curPos.longitude, center.lng)){
99
+ geocodePosition(curPos, true)
100
+ }
96
101
  setMarkerPosition(curPos)
97
102
  setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
98
103
  } else {
@@ -101,6 +106,10 @@ export const GoogleMap = (props: GoogleMapsParams) => {
101
106
  }
102
107
  }
103
108
 
109
+ const aproxEqual = (n1 : number, n2 : number, epsilon = 0.000001) => {
110
+ return Math.abs(n1 - n2) < epsilon
111
+ }
112
+
104
113
  const calculateDistance = (pointA: { lat: number, lng: number }, pointB: { latitude: number, longitude: number }) => {
105
114
 
106
115
  const lat1 = pointA.lat;