GT2/Ejectable/screens/TripScreen.tsx

124 lines
2.6 KiB
TypeScript
Raw Normal View History

2021-08-16 07:50:50 +00:00
import * as React from 'react';
2021-08-18 18:21:15 +00:00
import { Component } from 'react';
2021-08-16 22:39:34 +00:00
import { Button, StyleSheet, Alert } from 'react-native';
2021-08-16 07:50:50 +00:00
import { Text, View } from '../components/Themed';
2021-08-17 21:05:34 +00:00
import { ScreenInfo2 } from '../components/ScreenInfo';
2021-08-18 18:21:15 +00:00
import { geocodeAsync } from 'expo-location';
import * as GT2 from '../App';
import * as Nav from '../navigation/BottomTabNavigator';
import Navigation from '../navigation';
2021-08-16 07:50:50 +00:00
2021-08-18 18:21:15 +00:00
var elapsed:number, lat:number, long:number, ds:number, v:number;
2021-08-16 07:50:50 +00:00
const styles = StyleSheet.create({
2021-08-18 18:21:15 +00:00
tripText: {
marginHorizontal: -100,
marginVertical: 60,
textAlign: 'left',
width: "80%",
fontSize: 12,
fontWeight: 'bold',
},
2021-08-16 07:50:50 +00:00
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
2021-08-16 22:39:34 +00:00
controls: {
width: "80%",
flexDirection: 'row',
justifyContent: "space-between",
},
2021-08-16 07:50:50 +00:00
title: {
fontSize: 20,
fontWeight: 'bold',
},
separator: {
2021-08-17 21:05:34 +00:00
marginVertical: 10,
2021-08-16 07:50:50 +00:00
height: 1,
width: '80%',
},
});
2021-08-18 18:21:15 +00:00
function startTrip() {
GT2.toggleTripInProgress();
elapsed = 0.0;
lat = 0.0;
long = 0.0;
ds = 0.0;
v = 0.0;
Alert.alert('Trip Started');
}
function pauseTrip() {
Alert.alert('Trip Paused');
}
function endTrip() {
GT2.toggleTripInProgress();
Alert.alert('Trip Ended');
}
export default function TripScreen() {
if (!GT2.tripInProgress)
return (
<View style={styles.container}>
<Text style={styles.title}>Trip Control</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
<ScreenInfo2 />
<View style={styles.controls} >
<Button
title="Start"
onPress={() => startTrip() }
/>
<Button
title="Pause"
onPress={() => pauseTrip()}
/>
<Button
title="Stop"
onPress={() => endTrip() }
/>
</View>
</View>
); else
return (
<View style={styles.container}>
<Text style={styles.title}>Trip Control</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
<ScreenInfo2 />
<View style={styles.controls} >
<Button
title="Start"
onPress={() => startTrip() }
/>
<Button
title="Pause"
onPress={() => pauseTrip()}
/>
<Button
title="Stop"
onPress={() => endTrip() }
/>
</View>
<View>
<Text style={styles.tripText}>
{'Elapsed: '}{elapsed}{'\n'}
{'Geo: '}{lat}{long}{'\n'}
{'Vector: '}{ds}{v}{'\n'}
</Text>
</View>
</View>
);
}