aboutsummaryrefslogtreecommitdiff
path: root/mobile/components
diff options
context:
space:
mode:
authorIvan Shen <iwshen11@gmail.com>2019-03-28 19:38:29 +0000
committerGitHub <noreply@github.com>2019-03-28 19:38:29 +0000
commit7e094b900e62600e346475d333fa0626b3672458 (patch)
tree568e5fa7c38757ec64943aa4f37143728cba6eb7 /mobile/components
parent3dd064805b0c4930886a99dccc9d4d980e8c15e0 (diff)
parent143891d8467bf80209255fd55da1739625583858 (diff)
Merge pull request #58 from csc301-winter-2019/feat/2828
feat 28: get location when user selects use current location
Diffstat (limited to 'mobile/components')
-rw-r--r--mobile/components/GreetingPage.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/mobile/components/GreetingPage.js b/mobile/components/GreetingPage.js
index 035ee41..88c3de3 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.');
});
@@ -81,7 +87,7 @@ export default class GreetingPage extends Component {
<TouchableHighlight
style={styles.first_button_container}
- onPress={() => { this.moveToFormPage() }}>
+ onPress={() => { this.moveToFormPage(); }}>
<View style={styles.press_button}>