diff options
| author | ivanshen <iwshen11@gmail.com> | 2019-03-28 20:51:20 +0000 |
|---|---|---|
| committer | ivanshen <iwshen11@gmail.com> | 2019-03-28 20:51:20 +0000 |
| commit | 3d8dcbc094e0061ffbab7ecc6e9085e188e78c7a (patch) | |
| tree | c5e40a08ebef11c36920974ff6710ce19d28d9e3 | |
| parent | 7e094b900e62600e346475d333fa0626b3672458 (diff) | |
| parent | 3dd46ef8b12b9cc58c8ebdb8bd8b058ffa42b3ae (diff) | |
fix conflicts
| -rw-r--r-- | mobile/components/GreetingPage.js | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/mobile/components/GreetingPage.js b/mobile/components/GreetingPage.js index 88c3de3..c826c51 100644 --- a/mobile/components/GreetingPage.js +++ b/mobile/components/GreetingPage.js @@ -6,34 +6,31 @@ import { Location, Permissions, Constants } from 'expo'; export default class GreetingPage extends Component { state = { - isLoading: true, + isLoading: false, errorMessage: null, locationResult: null, }; - // runs as soon as page is loaded - componentDidMount() { - // immediately attempt to get the location - // this._getLocationAsync(); - } - moveToFormPage = async () => { + this.setState({isLoading: true}); // ask location services to allow location access to THIS app. // Note: location services itself must still be enabled for this! const {status} = await Permissions.askAsync(Permissions.LOCATION); if (status === 'granted') { // try to actually get the location asynchronously - a Promise Location.getCurrentPositionAsync({enableHighAccuracy: true}).then((position) => { - this.setState({locationResult: position.coords}); + this.setState({locationResult: position.coords}, () => { + this.props.navigation.navigate('FormPage', + {coordinates : [ + this.state.locationResult.longitude, + this.state.locationResult.latitude] + }); + }); // since we are guaranteed to have the location here, its safe to load the full view this.setState({isLoading: false}); // move to form page - this.props.navigation.navigate('FormPage', - {coordinates : [ - this.state.locationResult.longitude, - this.state.locationResult.latitude] - }); }).catch((e) => { + this.setState({isLoading: false}); alert(e + ' Please make sure your location (GPS) is turned on.'); }); @@ -43,13 +40,9 @@ export default class GreetingPage extends Component { } }; - moveToFormPage = () => { - this.props.navigation.navigate('FormPage', - {coordinates : [ - this.state.locationResult.longitude, - this.state.locationResult.latitude] - }); - }; + moveToMapPage = () => { + this.props.navigation.navigate('MapPage'); + } moveToMapPage = () => { this.props.navigation.navigate('MapPage'); |
