aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivanshen <iwshen11@gmail.com>2019-03-28 17:22:37 +0000
committerivanshen <iwshen11@gmail.com>2019-03-28 17:22:37 +0000
commita4de620727d4e7d294ced1d1e1c956c0be8c0cd2 (patch)
treec8600158be65ea88c9931d6e09947354cf628371
parent92ccea2772af9682151c178ead406d10b453ee34 (diff)
feat 28: get location when user selects use current location
-rw-r--r--mobile/components/GreetingPage.js20
1 files changed, 9 insertions, 11 deletions
diff --git a/mobile/components/GreetingPage.js b/mobile/components/GreetingPage.js
index 9301fbc..84c20e7 100644
--- a/mobile/components/GreetingPage.js
+++ b/mobile/components/GreetingPage.js
@@ -14,10 +14,10 @@ export default class GreetingPage extends Component {
// runs as soon as page is loaded
componentDidMount() {
// immediately attempt to get the location
- this._getLocationAsync();
+ // this._getLocationAsync();
}
- _getLocationAsync = async () => {
+ moveToFormPage = async () => {
// 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);
@@ -27,6 +27,12 @@ export default class GreetingPage extends Component {
this.setState({locationResult: position.coords});
// 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) => {
alert(e + ' Please make sure your location (GPS) is turned on.');
});
@@ -37,14 +43,6 @@ export default class GreetingPage extends Component {
}
};
- moveToFormPage = () => {
- this.props.navigation.navigate('FormPage',
- {coordinates : [
- this.state.locationResult.longitude,
- this.state.locationResult.latitude]
- });
- };
-
render() {
//<View> acts like the way <div> does in JavaScript
@@ -77,7 +75,7 @@ export default class GreetingPage extends Component {
<TouchableHighlight
style={styles.first_button_container}
- onPress={() => { this.moveToFormPage() }}>
+ onPress={() => { this.moveToFormPage(); }}>
<View style={styles.press_button}>