diff --git a/Ejectable/GT2.tsx b/Ejectable/GT2.tsx index 346bc465..b443dd4b 100644 --- a/Ejectable/GT2.tsx +++ b/Ejectable/GT2.tsx @@ -5,6 +5,7 @@ import { StyleSheet } from 'react-native'; import * as geolib from 'geolib'; var debug:number = 0; + var endIsNigh:boolean = false; var testCount = 0; var bgEnabled:boolean = false; var expoGeoState:any = null; @@ -16,6 +17,9 @@ export var locEnabled:boolean = false; const geoLibAccuracy:number = 0.1; const minExpoAccuracy:number = 10; +export function getEndIsLast() : boolean { return endIsNigh; } +export function setEndIsLast(value:boolean) { endIsNigh = value; } + const styles = StyleSheet.create({ tripText: { marginHorizontal: -10, @@ -211,6 +215,19 @@ export class GT2 { } + public from(last:GT2) { + + this.startPoint = last.startPoint; + this.trip.loc = last.trip.loc; + this.elapsed = last.elapsed; + this.endPoint = last.endPoint; + this.CO2Effect = last.CO2Effect; + this.co2Rate = last.co2Rate; + this.units = last.units; + this.sensitivity = last.sensitivity; + + } + public setLocEnabled(value:boolean) { locEnabled = value} public pause() { @@ -255,8 +272,8 @@ export class GT2 { return ( 'Elapsed - ' + this.trip.elapsed + '\n' + - 'Origin: ' + 'lat: ' + this.trip.loc.mLatitude.toFixed(8) + - ' long: ' + this.trip.loc.mLongitude.toFixed(8) + '\n' + + 'Origin: ' + 'lat: ' + this.startPoint.mLatitude.toFixed(8) + + ' long: ' + this.startPoint.mLongitude.toFixed(8) + '\n' + 'Destination: ' + 'lat: ' + this.trip.loc.mLatitude.toFixed(8) + ' long: ' + this.trip.loc.mLongitude.toFixed(8) + '\n' + 'CO2: ' + this.trip.CO2.toFixed(1) + ' grams ' + this.CO2Effect + '\n\n' + @@ -338,7 +355,17 @@ export class TripSummary extends React.Component { }; render() { - + + if (endIsNigh) { + setEndIsLast(false); + return( + + + {LastTrip.getTripSummary() } + + ); + + } else return( @@ -350,4 +377,5 @@ export class TripSummary extends React.Component { } -export var Trips:GT2 = new GT2(); +export var Trips:GT2 = new GT2(); +export var LastTrip:GT2 = new GT2(); \ No newline at end of file diff --git a/Ejectable/app.json b/Ejectable/app.json index 3cb7c15a..dec38090 100644 --- a/Ejectable/app.json +++ b/Ejectable/app.json @@ -21,6 +21,7 @@ ], "ios": { "supportsTablet": true, + "buildNumber": "2", "infoPlist": { "UIBackgroundModes": [ "location", diff --git a/Ejectable/screens/TripScreen.tsx b/Ejectable/screens/TripScreen.tsx index 2bde6c2e..d3a9194c 100644 --- a/Ejectable/screens/TripScreen.tsx +++ b/Ejectable/screens/TripScreen.tsx @@ -3,7 +3,7 @@ import { useState } from 'react'; import { Alert, BackHandler, Button, StyleSheet } from 'react-native'; import { Text, View } from '../components/Themed'; import { ScreenInfo2 } from '../components/ScreenInfo'; -import { locEnabled, TripDisplay, Trips } from '../GT2'; +import { locEnabled, TripDisplay, LastTrip, Trips } from '../GT2'; import { RootTabScreenProps } from '../types'; import { getAdvised, setAdvised } from './ModalScreen'; @@ -61,6 +61,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) const [sButtonText, setSButtonText] = useState("Start"); const [pButtonText, setPButtonText] = useState("Pause"); + if (Trips.nTrips < 1) return ( Trip Control @@ -71,7 +72,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) title={sButtonText} onPress={() => { if (!getAdvised()) { - Alert.alert("Note: GT2 2.0.n doesn't run in background."); + Alert.alert("Note:GT2 2.0.n doesn't run in background."); setAdvised(); } if (!Trips.inProgress) {startTrip(); @@ -90,6 +91,39 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) ); + else; + return ( + + Trip Control + + + +