1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Started fixing ReactNative app

This commit is contained in:
Laurent Cozic
2017-07-05 21:34:25 +01:00
parent 9d630ab0ca
commit f0a8cbe95d
50 changed files with 12 additions and 153 deletions

View File

@ -0,0 +1,39 @@
class GeolocationReact {
static currentPosition_testResponse() {
return {
mocked: false,
timestamp: (new Date()).getTime(),
coords: {
speed: 0,
heading: 0,
accuracy: 20,
longitude: -3.4596633911132812,
altitude: 0,
latitude: 48.73219093634444
}
}
}
static currentPosition(options = null) {
if (typeof navigator === 'undefined') {
// TODO
return Promise.resolve(this.currentPosition_testResponse());
}
if (!options) options = {};
if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true;
if (!('timeout' in options)) options.timeout = 10000;
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition((data) => {
resolve(data);
}, (error) => {
rejec(error);
}, options);
});
}
}
export { GeolocationReact };