diff --git a/Ejectable/GT2.tsx b/Ejectable/GT2.tsx
index b4fd2cdd..ccdef6ab 100644
--- a/Ejectable/GT2.tsx
+++ b/Ejectable/GT2.tsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import * as Location from 'expo-location';
import { Coordinate } from "./Coordinate";
import { Text, View } from './components/Themed';
-import { Button, StyleSheet } from 'react-native';
+import { StyleSheet } from 'react-native';
var debug:boolean = false;
export var endPending:boolean = false;
@@ -12,8 +12,8 @@ export var locEnabled:boolean = false;
const heartbeat:number = 500;
const displayBeat:number = 3;
-export function getEndPending() { return(endPending) }
-export function toggleEndPending() { endPending = !endPending;}
+export function getEndPending() { return(endPending); }
+export function setEndPending(value:boolean) { endPending = value; }
const styles = StyleSheet.create({
tripText: {
@@ -149,7 +149,7 @@ export class GT2 {
this.trip.stop();
this.inProgress = false;
this.nTrips++;
- toggleEndPending();
+ setEndPending(true);
}
@@ -265,10 +265,10 @@ export class TripDisplay extends React.Component {
export class TripSummary extends React.Component {
- constructor(props:any) {
- super(props);
- this.state = { slug: null };
- }
+ handleRefresh = () => {
+ // by calling this method react re-renders the component
+ this.setState({});
+ };
render() {
diff --git a/Ejectable/navigation/index.tsx b/Ejectable/navigation/index.tsx
index 7364d4d3..4b3a5c49 100644
--- a/Ejectable/navigation/index.tsx
+++ b/Ejectable/navigation/index.tsx
@@ -42,7 +42,7 @@ function RootNavigator() {
-
+
);
diff --git a/Ejectable/screens/HomeScreen.tsx b/Ejectable/screens/HomeScreen.tsx
index 90a74e2c..33a1f443 100644
--- a/Ejectable/screens/HomeScreen.tsx
+++ b/Ejectable/screens/HomeScreen.tsx
@@ -2,12 +2,13 @@ import * as React from 'react';
import { StyleSheet, ImageBackground } from 'react-native';
import { Text, View } from '../components/Themed';
import { ScreenInfo3 } from '../components/ScreenInfo';
+import { RootTabScreenProps } from '../types';
const image = { uri: "https://meansofproduction.biz/images/GREENT.jpg" };
export var nav:any = null;
-export default function HomeScreen(navigation:any) {
+export default function HomeScreen( { navigation }: RootTabScreenProps<'Home'>) {
nav = navigation;
return (
diff --git a/Ejectable/screens/ModalScreen.tsx b/Ejectable/screens/ModalScreen.tsx
index c8f79c55..921617cb 100644
--- a/Ejectable/screens/ModalScreen.tsx
+++ b/Ejectable/screens/ModalScreen.tsx
@@ -1,17 +1,20 @@
import { StatusBar } from 'expo-status-bar';
import * as React from 'react';
-import { Platform, StyleSheet } from 'react-native';
+import { Button, Platform, StyleSheet } from 'react-native';
import EndScreenInfo from '../components/EndScreenInfo';
import { Text, View } from '../components/Themed';
+import { RootTabScreenProps } from '../types';
-export default function ModalScreen() {
+export default function ModalScreen({ navigation }: RootTabScreenProps<'Settings'>) {
return (
- Modal
+ Carbon Impact
-
+
diff --git a/Ejectable/screens/SettingsScreen.tsx b/Ejectable/screens/SettingsScreen.tsx
index 795172a7..08a58d21 100644
--- a/Ejectable/screens/SettingsScreen.tsx
+++ b/Ejectable/screens/SettingsScreen.tsx
@@ -5,8 +5,9 @@ import { useState } from 'react';
import ScreenInfo from '../components/ScreenInfo';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Trips } from '../GT2';
+import { RootTabScreenProps } from '../types';
-export default function SettingsScreen() {
+export default function SettingsScreen( { navigation }: RootTabScreenProps<'Settings'>) {
const [number, onChangeNumber] = React.useState("");
const [isKM, setMiles] = useState(false);
const toggleUnits = () => setMiles(previousState => !previousState);
diff --git a/Ejectable/screens/TripScreen.tsx b/Ejectable/screens/TripScreen.tsx
index 563554b3..78a68c60 100644
--- a/Ejectable/screens/TripScreen.tsx
+++ b/Ejectable/screens/TripScreen.tsx
@@ -4,7 +4,10 @@ import { Alert, BackHandler, Button, StyleSheet } from 'react-native';
import { Text, View } from '../components/Themed';
import { ScreenInfo2 } from '../components/ScreenInfo';
import EndScreenInfo from '../components/EndScreenInfo';
-import { locEnabled, getEndPending, toggleEndPending, TripDisplay, Trips } from '../GT2';
+import { locEnabled, getEndPending, setEndPending, TripDisplay, Trips } from '../GT2';
+import { RootTabScreenProps } from '../types';
+
+ var debug:number = 10;
const styles = StyleSheet.create({
container: {
@@ -31,7 +34,7 @@ const styles = StyleSheet.create({
function startTrip() {
- if (!locEnabled ) {
+ if (!locEnabled && debug != 10) {
Alert.alert("You must enable both foreground\n and background location tracking.");
return;
}
@@ -55,12 +58,11 @@ function pauseTrip() {
function endTrip() { Trips.end(); }
-export default function TripScreen( ) {
+export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) {
const [sButtonText, setSButtonText] = useState("Start");
const [pButtonText, setPButtonText] = useState("Pause");
-
- if (!getEndPending())
+
return (
Trip Control
@@ -70,8 +72,13 @@ export default function TripScreen( ) {
);
- else
+
return (
Trip Control
- { toggleEndPending(); }}
- />
+ { setEndPending(false); navigation.jumpTo('Trip'); }}
+ />
);
diff --git a/Ejectable/tsconfig.json b/Ejectable/tsconfig.json
index 2058e5e5..67e95e4c 100644
--- a/Ejectable/tsconfig.json
+++ b/Ejectable/tsconfig.json
@@ -1,4 +1,4 @@
-{
+{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true