aboutsummaryrefslogtreecommitdiff
path: root/mobile/components/GreetingPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/components/GreetingPage.js')
-rw-r--r--mobile/components/GreetingPage.js58
1 files changed, 33 insertions, 25 deletions
diff --git a/mobile/components/GreetingPage.js b/mobile/components/GreetingPage.js
index 0bc61cf..0bfa63b 100644
--- a/mobile/components/GreetingPage.js
+++ b/mobile/components/GreetingPage.js
@@ -6,28 +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();
- }
-
- _getLocationAsync = async () => {
+ 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
}).catch((e) => {
+ this.setState({isLoading: false});
alert(e + ' Please make sure your location (GPS) is turned on.');
});
@@ -37,13 +40,13 @@ 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');
+ }
render() {
@@ -84,13 +87,13 @@ export default class GreetingPage extends Component {
<View style={styles.press_button}>
- <View>
+ <View padding={15}>
<Text style={styles.current_location_title}>
Use Current Location
</Text>
</View>
- <View marginTop = {20}>
+ <View marginTop = {5}>
<Ionicons name="md-locate" size={40} color="white"/>
</View>
@@ -98,16 +101,18 @@ export default class GreetingPage extends Component {
</TouchableHighlight>
- <TouchableHighlight disabled style={styles.second_button_container}>
+ <TouchableHighlight
+ style={styles.second_button_container}
+ onPress={() => { this.moveToMapPage() }}>
<View style={styles.press_button}>
- <View>
+ <View padding={15}>
<Text style={styles.current_location_title}>
Drop Pin
</Text>
</View>
- <View marginTop = {20}>
+ <View>
<Ionicons name="md-pin" size={40} color="white"/>
</View>
@@ -149,7 +154,6 @@ const styles = StyleSheet.create( {
},
current_location_title: {
color: '#FFF',
- marginTop: 15,
textAlign: 'center',
opacity: 0.9,
fontSize: 20
@@ -164,12 +168,16 @@ const styles = StyleSheet.create( {
alignItems: 'stretch'
},
press_button: {
- flexDirection: 'column',
- justifyContent: 'center',
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ // padding:5,
alignItems: 'center'
},
second_button_container: {
flex: 1,
- backgroundColor: '#535c68'
+ backgroundColor: '#535c68',
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'stretch'
}
})