From f0b0f909dfb7658312c5df0a18591a203077282f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Mar 2019 16:15:37 -0500 Subject: Added A "Go Back" button to the form page. Fixed bug that would cause app to produce an error if location services are turned off. Please enter the commit message for your changes. Lines starting --- mobile/App.js | 2 +- mobile/components/GreetingPage.js | 18 ++++++------------ mobile/screens/Form1.js | 14 ++++++++++---- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'mobile') diff --git a/mobile/App.js b/mobile/App.js index c1b9eba..f36b696 100644 --- a/mobile/App.js +++ b/mobile/App.js @@ -4,7 +4,7 @@ import { Ionicons } from '@expo/vector-icons'; import { createStackNavigator, createAppContainer } from 'react-navigation'; import GreetingPage from './components/GreetingPage'; -import FormPage from './components/Form1'; +import FormPage from './screens/Form1'; const RootStack = createStackNavigator( {GreetingPage: GreetingPage, FormPage: FormPage,}, diff --git a/mobile/components/GreetingPage.js b/mobile/components/GreetingPage.js index 5e6d502..9d1d410 100644 --- a/mobile/components/GreetingPage.js +++ b/mobile/components/GreetingPage.js @@ -14,7 +14,7 @@ export default class GreetingPage extends Component { componentWillMount() { if (Platform.OS === 'android' && !Constants.isDevice) { this.setState({ - errorMessage: 'Oops, this will not work on Sketch in an Android emulator. Try it on your device!', + errorMessage: 'This will not work on an android device', }); } else { this._getLocationAsync(); @@ -33,19 +33,13 @@ export default class GreetingPage extends Component { this.setState({ location }); }; - getCurrentLocation = () => { - - navigator.geolocation.getCurrentPosition( - position => { - this.recorded_coordinates = JSON.stringify([position.coords.latitude, position.coords.longitude]); - }, - ); - } - moveToFormPage = () => { this._getLocationAsync; - const coordinates = [this.state.location.coords.longitude, this.state.location.coords.latitude] - // Alert.alert(JSON.stringify(coordinates)); + if (this.state.location === null) { + Alert.alert("There was a problem accessing your location"); + return; + } + const coordinates = [this.state.location.coords.longitude, this.state.location.coords.latitude]; this.props.navigation.navigate('FormPage', {coordinates : coordinates}); } diff --git a/mobile/screens/Form1.js b/mobile/screens/Form1.js index 92eec30..963bde2 100644 --- a/mobile/screens/Form1.js +++ b/mobile/screens/Form1.js @@ -3,10 +3,10 @@ import {Text, Alert, AppRegistry, Button, StyleSheet, View, TextInput } from 're export default class Form1 extends Component { _onPressButton1() { - //const {navigation} = this.props; - //const coordinates = navigation.getparam('coordinates'); - var coordinates = this.coordinates ? coordinates : []; - Alert.alert("Thank you for your response.") + const { navigation } = this.props; + const coordinates = navigation.getParam('coordinates'); + //var coordinates = this.coordinates ? coordinates : []; + Alert.alert("Thank you for your response."); fetch('https://helpthehome-qa.herokuapp.com/mobilerequest', { method: 'POST', headers: { @@ -69,6 +69,12 @@ export default class Form1 extends Component { title="Submit!" /> + +