ordering-ui-react-native 0.18.58-test3 → 0.18.58-test4

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.18.58-test3",
3
+ "version": "0.18.58-test4",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -73,40 +73,13 @@ export const GPSButton = (props: any) => {
73
73
  setLoading(false);
74
74
  })
75
75
  }
76
- const requestLocationPermission = async () => {
77
- try {
78
- const granted = await PermissionsAndroid.request(
79
- PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
80
- {
81
- title: 'Geolocation Permission',
82
- message: 'Can we access your location?',
83
- buttonNeutral: 'Ask Me Later',
84
- buttonNegative: 'Cancel',
85
- buttonPositive: 'OK',
86
- },
87
- );
88
- console.log('granted', granted);
89
- if (granted === 'granted') {
90
- console.log('You can use Geolocation');
91
- return true;
92
- } else {
93
- console.log('You cannot use Geolocation');
94
- return false;
95
- }
96
- } catch (err) {
97
- return false;
98
- }
99
- };
76
+
100
77
  const getCurrentPosition = async () => {
101
78
  let trackingStatus = await getTrackingStatus()
102
79
  if (trackingStatus === 'not-determined') {
103
80
  trackingStatus = await requestTrackingPermission()
104
81
  }
105
- setErrorState({
106
- ...errorState,
107
- trackingStatus: trackingStatus
108
- })
109
- if (trackingStatus === 'authorized') {
82
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
110
83
  setLoading(true)
111
84
  Geolocation.getCurrentPosition((pos) => {
112
85
  setErrorState({
@@ -122,65 +95,64 @@ export const GPSButton = (props: any) => {
122
95
  setLoading(false);
123
96
  console.log(`ERROR(${err.code}): ${err.message}`)
124
97
  }, {
125
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
98
+ enableHighAccuracy: false, timeout: 30000, maximumAge: 1000
126
99
  })
127
- return
128
100
  }
129
101
 
130
- let permissionStatus: PermissionStatus;
131
- setLoading(true)
132
- if (Platform.OS === 'ios') {
133
- permissionStatus = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
134
- } else {
135
- // permissionStatus = await request(
136
- // PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
137
- // );
138
- const result = requestLocationPermission();
139
- result.then(res => {
140
- if (res) {
141
- Geolocation.getCurrentPosition((pos) => {
142
- setErrorState({
143
- ...errorState,
144
- getCurrentPositionNew2: pos
145
- })
146
- geoCodePosition(pos.coords)
147
- }, (err) => {
148
- setErrorState({
149
- ...errorState,
150
- fallbackGetCurrentPositionNew2: err
151
- })
152
- setLoading(false);
153
- console.log(`ERROR(${err.code}): ${err.message}`)
154
- }, {
155
- enableHighAccuracy: true, timeout: 30000, maximumAge: 10000
156
- })
157
- }
158
- }); }
159
- if (permissionStatus === 'denied') {
160
- openSettings();
161
- }
162
- Geolocation.getCurrentPosition((pos) => {
163
- setErrorState({
164
- ...errorState,
165
- getCurrentPositionNew: pos
166
- })
167
- geoCodePosition(pos.coords)
168
- }, (err) => {
169
- setErrorState({
170
- ...errorState,
171
- fallbackGetCurrentPositionNew: err
172
- })
173
- setLoading(false);
174
- console.log(`ERROR(${err.code}): ${err.message}`)
175
- }, {
176
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
177
- })
102
+ // let permissionStatus: PermissionStatus;
103
+ // setLoading(true)
104
+ // if (Platform.OS === 'ios') {
105
+ // permissionStatus = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
106
+ // } else {
107
+ // // permissionStatus = await request(
108
+ // // PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
109
+ // // );
110
+ // const result = requestLocationPermission();
111
+ // result.then(res => {
112
+ // if (res) {
113
+ // Geolocation.getCurrentPosition((pos) => {
114
+ // setErrorState({
115
+ // ...errorState,
116
+ // getCurrentPositionNew2: pos
117
+ // })
118
+ // geoCodePosition(pos.coords)
119
+ // }, (err) => {
120
+ // setErrorState({
121
+ // ...errorState,
122
+ // fallbackGetCurrentPositionNew2: err
123
+ // })
124
+ // setLoading(false);
125
+ // console.log(`ERROR(${err.code}): ${err.message}`)
126
+ // }, {
127
+ // enableHighAccuracy: true, timeout: 30000, maximumAge: 10000
128
+ // })
129
+ // }
130
+ // }); }
131
+ // if (permissionStatus === 'denied') {
132
+ // openSettings();
133
+ // }
134
+ // Geolocation.getCurrentPosition((pos) => {
135
+ // setErrorState({
136
+ // ...errorState,
137
+ // getCurrentPositionNew: pos
138
+ // })
139
+ // geoCodePosition(pos.coords)
140
+ // }, (err) => {
141
+ // setErrorState({
142
+ // ...errorState,
143
+ // fallbackGetCurrentPositionNew: err
144
+ // })
145
+ // setLoading(false);
146
+ // console.log(`ERROR(${err.code}): ${err.message}`)
147
+ // }, {
148
+ // enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
149
+ // })
178
150
  }
179
151
 
180
152
  useEffect(() => {
181
153
  if (isIntGeoCoder) return
182
154
  Geocoder.init(apiKey);
183
- }, [isIntGeoCoder])
155
+ }, [])
184
156
 
185
157
  return (
186
158
  <GpsButtonStyle