This commit is contained in:
Ren Juan 2021-08-20 11:23:16 +00:00
parent 16b5d0d30d
commit afbcd3fba7
1 changed files with 5 additions and 40 deletions

View File

@ -2,18 +2,9 @@ import * as React from 'react';
import { Button, StyleSheet, Alert } from 'react-native'; import { Button, StyleSheet, Alert } from 'react-native';
import { Text, View } from '../components/Themed'; import { Text, View } from '../components/Themed';
import { ScreenInfo2 } from '../components/ScreenInfo'; import { ScreenInfo2 } from '../components/ScreenInfo';
import { thisTrip } from '../GT2'; import { GT2, thisTrip } from '../GT2';
import { TripStack } from '../navigation/BottomTabNavigator';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
tripText: {
marginHorizontal: -100,
marginVertical: 60,
textAlign: 'left',
width: "80%",
fontSize: 12,
fontWeight: 'bold',
},
container: { container: {
flex: 1, flex: 1,
alignItems: 'center', alignItems: 'center',
@ -44,6 +35,8 @@ function startTrip() {
} }
function pauseTrip() { function pauseTrip() {
thisTrip.pause();
Alert.alert('Trip Paused'); Alert.alert('Trip Paused');
} }
@ -57,8 +50,7 @@ function endTrip() {
export default function TripScreen() { export default function TripScreen() {
if (!thisTrip.inProgress) return (
return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.title}>Trip Control</Text> <Text style={styles.title}>Trip Control</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" /> <View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
@ -77,34 +69,7 @@ export default function TripScreen() {
onPress={() => endTrip() } onPress={() => endTrip() }
/> />
</View> </View>
</View> < thisTrip.TripDisplay />
); 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 - '}{thisTrip.elapsed}{' seconds\n'}
{'Geo: '}{'lat: '}{thisTrip.loc.mLatitude}{' long: '}{thisTrip.loc.mLatitude}{'\n'}
{'Vector: '}{'distance: '}{thisTrip.distance}{' velocity: '}{thisTrip.v}{'\n'}
</Text>
</View>
</View> </View>
); );