This commit is contained in:
Ren Juan 2021-08-28 22:36:13 +00:00
parent fcb38c09b0
commit de380df8d6
4 changed files with 15 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import { Text, View } from './components/Themed';
import { StyleSheet } from 'react-native'; import { StyleSheet } from 'react-native';
import * as geolib from 'geolib'; import * as geolib from 'geolib';
export const ver:string = "2.06;"
var debug:number = 0; var debug:number = 0;
var endIsNigh:boolean = false; var endIsNigh:boolean = false;
var testCount = 0; var testCount = 0;
@ -153,6 +154,7 @@ export class GT2 {
startPoint:Coordinate = new Coordinate(0.0,0.0); startPoint:Coordinate = new Coordinate(0.0,0.0);
displayInterval:number = displayBeat * heartbeat; displayInterval:number = displayBeat * heartbeat;
arc:number = 0.0;
public distance:number = 0.0; public distance:number = 0.0;
co2Rate:number = 250.0; co2Rate:number = 250.0;
sensitivity:number = 3; sensitivity:number = 3;
@ -210,6 +212,7 @@ export class GT2 {
this.trip.stop(); this.trip.stop();
this.inProgress = false; this.inProgress = false;
this.arc = this.startPoint.distanceTo(this.trip.loc);
this.trip.CO2 = ( this.distance / 1000 ) * this.co2Rate; this.trip.CO2 = ( this.distance / 1000 ) * this.co2Rate;
this.nTrips++; this.nTrips++;
@ -225,7 +228,7 @@ export class GT2 {
this.co2Rate = last.co2Rate; this.co2Rate = last.co2Rate;
this.units = last.units; this.units = last.units;
this.sensitivity = last.sensitivity; this.sensitivity = last.sensitivity;
this.arc = last.arc;
} }
public setLocEnabled(value:boolean) { locEnabled = value} public setLocEnabled(value:boolean) { locEnabled = value}
@ -245,6 +248,7 @@ export class GT2 {
public reset() { public reset() {
this.distance = 0.0; this.distance = 0.0;
this.arc = 0.0;
this.endPoint = new Coordinate(0,0); this.endPoint = new Coordinate(0,0);
this.startPoint = new Coordinate(0,0); this.startPoint = new Coordinate(0,0);
this.v = 0; this.v = 0;
@ -269,6 +273,8 @@ export class GT2 {
var preferredUnits:number = ((this.units == 'km') ? (this.distance / 1000) var preferredUnits:number = ((this.units == 'km') ? (this.distance / 1000)
: (this.distance / 1609.34)); : (this.distance / 1609.34));
var preferredUnitsArc:number = ((this.units == 'km') ? (this.arc / 1000)
: (this.arc / 1609.34));
return ( return (
'Elapsed - ' + this.trip.elapsed + '\n' + 'Elapsed - ' + this.trip.elapsed + '\n' +
@ -278,7 +284,8 @@ export class GT2 {
' long: ' + this.trip.loc.mLongitude.toFixed(8) + '\n' + ' long: ' + this.trip.loc.mLongitude.toFixed(8) + '\n' +
'CO2: ' + this.trip.CO2.toFixed(1) + ' grams ' + this.CO2Effect + '\n\n' + 'CO2: ' + this.trip.CO2.toFixed(1) + ' grams ' + this.CO2Effect + '\n\n' +
'CO2 Rate / Sensitivity: ' + this.co2Rate + " / " + this.sensitivity + '\n' + 'CO2 Rate / Sensitivity: ' + this.co2Rate + " / " + this.sensitivity + '\n' +
'Distance covered while consuming fuel: ' + preferredUnits.toFixed(2) + ' ' + this.units ); 'Arc distance from origin to destination: ' + preferredUnitsArc.toFixed(2) + this.units + '\n' +
'Path distance while consuming fuel: ' + preferredUnits.toFixed(2) + ' ' + this.units );
} }

View File

@ -21,6 +21,7 @@
], ],
"ios": { "ios": {
"supportsTablet": true, "supportsTablet": true,
"bundleIdentifier": "app.greentravel.gt2",
"buildNumber": "2", "buildNumber": "2",
"infoPlist": { "infoPlist": {
"UIBackgroundModes": [ "UIBackgroundModes": [

View File

@ -2,7 +2,7 @@ import React from 'react';
import { StyleSheet, TouchableOpacity } from 'react-native'; import { StyleSheet, TouchableOpacity } from 'react-native';
import { Text, View } from './Themed'; import { Text, View } from './Themed';
import * as Device from 'expo-device'; import * as Device from 'expo-device';
import { withSafeAreaInsets } from 'react-native-safe-area-context'; import { ver } from '../GT2';
export default function ScreenInfo() { export default function ScreenInfo() {
return ( return (
@ -61,7 +61,7 @@ export function ScreenInfo3() {
style={styles.titleText} style={styles.titleText}
lightColor="rgba(0,0,0,0.8)" lightColor="rgba(0,0,0,0.8)"
darkColor="rgba(255,255,255,0.8)"> darkColor="rgba(255,255,255,0.8)">
Green Travel Calculator v. 2.0.6 {'Green Travel Calculator v. ' + ver }
</Text> </Text>
<Text <Text
style={styles.versionText} style={styles.versionText}

View File

@ -3,7 +3,7 @@ import { useState } from 'react';
import { Alert, BackHandler, Button, StyleSheet } from 'react-native'; import { Alert, BackHandler, Button, StyleSheet } 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 { locEnabled, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2'; import { ver, locEnabled, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2';
import { RootTabScreenProps } from '../types'; import { RootTabScreenProps } from '../types';
import { getAdvised, setAdvised } from './ModalScreen'; import { getAdvised, setAdvised } from './ModalScreen';
@ -72,7 +72,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
title={sButtonText} title={sButtonText}
onPress={() => { onPress={() => {
if (!getAdvised()) { if (!getAdvised()) {
Alert.alert("Note: GT2 2.0.n doesn't while run in background."); Alert.alert("Note: " + ver + " doesn't run while in background or sleeping.");
setAdvised(); setAdvised();
} }
if (!Trips.inProgress) {startTrip(); if (!Trips.inProgress) {startTrip();
@ -102,7 +102,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
title={sButtonText} title={sButtonText}
onPress={() => { onPress={() => {
if (!getAdvised()) { if (!getAdvised()) {
Alert.alert("Note: GT2 2.0.n doesn't run while in background."); Alert.alert("Note: GT2 2.0.6 doesn't run while in background or sleeping.");
setAdvised(); setAdvised();
} }
if (!Trips.inProgress) {startTrip(); if (!Trips.inProgress) {startTrip();