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
|
@@ -73,40 +73,13 @@ export const GPSButton = (props: any) => {
|
|
|
73
73
|
setLoading(false);
|
|
74
74
|
})
|
|
75
75
|
}
|
|
76
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
134
|
-
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (permissionStatus === 'denied') {
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
Geolocation.getCurrentPosition((pos) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}, (err) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}, {
|
|
176
|
-
|
|
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
|
-
}, [
|
|
155
|
+
}, [])
|
|
184
156
|
|
|
185
157
|
return (
|
|
186
158
|
<GpsButtonStyle
|