diff --git a/Ejectable/App.tsx b/Ejectable/App.tsx
index cf33a65d..8b17bbfa 100644
--- a/Ejectable/App.tsx
+++ b/Ejectable/App.tsx
@@ -1,27 +1,64 @@
import 'react-native-gesture-handler';
import { StatusBar } from 'expo-status-bar';
-import React, { useState } from 'react';
-import Switch from 'react-native';
+import React, { useState, useEffect } from 'react';
+import { Platform, Text, View, Switch, StyleSheet } from 'react-native';
+import * as Location from 'expo-location';
import { SafeAreaProvider } from 'react-native-safe-area-context';
-
import useCachedResources from './hooks/useCachedResources';
import useColorScheme from './hooks/useColorScheme';
import Navigation from './navigation';
+export var debug:boolean = false;
+export var expoGeoState:any;
+export var tripInProgress:boolean = true;
+
export default function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
const [isKM, setIsKM] = useState(false);
const toggleUnits = () => setIsKM(previousState => !previousState);
+ const [location, setLocation] = useState(Object);
+ const [errorMsg, setErrorMsg] = useState("");
+
+ useEffect(() => {
+ (async () => {
+ let { status } = await Location.requestForegroundPermissionsAsync();
+ if (status !== 'granted') {
+ setErrorMsg('Permission to access location was denied');
+ return;
+ }
+
+ let location = await Location.getCurrentPositionAsync({});
+ setLocation(location);
+ })();
+ }, []);
+
+ expoGeoState = 'Waiting..';
+ if (errorMsg) {
+ expoGeoState = errorMsg;
+ } else if (location) {
+ expoGeoState = JSON.stringify(location);
+ }
if (!isLoadingComplete) {
return null;
} else {
+ if (!debug)
return (
);
+ else
+ return (
+
+
+ {expoGeoState}
+
+
+ );
}
}
+
+export function toggleTripInProgress() {tripInProgress = !tripInProgress;}
\ No newline at end of file
diff --git a/Ejectable/GT2Service.js b/Ejectable/GT2Service.js
deleted file mode 100644
index 8d8dd547..00000000
--- a/Ejectable/GT2Service.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import { Platform, Text, View, StyleSheet } from 'react-native';
-import * as Location from 'expo-location';
-
-export class GT2Service {
-
- constructor () {
- const [location, setLocation] = useState(null);
- const [errorMsg, setErrorMsg] = useState(null);
-
- }
-
- start() {
-
- useEffect(() => {
- (async () => {
- let { status } = await Location.requestForegroundPermissionsAsync();
- if (status !== 'granted') {
- setErrorMsg('Permission to access location was denied');
- return;
- }
-
- let location = await Location.getCurrentPositionAsync({});
- setLocation(location);
- })();
- }, []);
-
- let text = 'Waiting..';
- if (errorMsg) {
- text = errorMsg;
- } else if (location) {
- text = JSON.stringify(location);
- }
-
- return (
-
- {text}
-
- );
- }
-
-}
diff --git a/Ejectable/components/ScreenInfo.tsx b/Ejectable/components/ScreenInfo.tsx
index 4154b13f..2d0b4839 100644
--- a/Ejectable/components/ScreenInfo.tsx
+++ b/Ejectable/components/ScreenInfo.tsx
@@ -38,7 +38,13 @@ export function ScreenInfo3() {
style={styles.settingsText}
lightColor="rgba(0,0,0,0.8)"
darkColor="rgba(255,255,255,0.8)">
- Green Travel Carbon Calculator v. 2
+ Green Travel Carbon Calculator v. 2
+
+
+ expo version
);
@@ -54,5 +60,8 @@ const styles = StyleSheet.create({
lineHeight: 24,
textAlign: 'center',
},
-
+ versionText: {
+ fontSize: 8,
+ textAlign: 'center',
+ },
});
diff --git a/Ejectable/navigation/BottomTabNavigator.tsx b/Ejectable/navigation/BottomTabNavigator.tsx
index 83b9e690..a8b748be 100644
--- a/Ejectable/navigation/BottomTabNavigator.tsx
+++ b/Ejectable/navigation/BottomTabNavigator.tsx
@@ -7,15 +7,14 @@ import { Ionicons } from '@expo/vector-icons';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import * as React from 'react';
-
import Colors from '../constants/Colors';
import useColorScheme from '../hooks/useColorScheme';
import SplashScreen from '../screens/SplashScreen';
-import TripScreen from '../screens/TripScreen';
import SettingsScreen from '../screens/SettingsScreen';
+import TripScreen from '../screens/TripScreen';
import { SplashParamList, BottomTabParamList, TripParamList, SettingsParamList } from '../types';
-const BottomTab = createBottomTabNavigator();
+export const BottomTab = createBottomTabNavigator();
export default function BottomTabNavigator() {
const colorScheme = useColorScheme();
@@ -25,7 +24,7 @@ export default function BottomTabNavigator() {
initialRouteName="Splash"
tabBarOptions={{ activeTintColor: Colors[colorScheme].tint }}>
,
@@ -57,8 +56,7 @@ function TabBarIcon(props: { name: React.ComponentProps['name']
// Each tab has its own navigation stack, you can read more about this pattern here:
// https://reactnavigation.org/docs/tab-based-navigation#a-stack-navigator-for-each-tab
-const SplashStack = createStackNavigator();
-const TripStack = createStackNavigator();
+const SplashStack = createStackNavigator();
function SplashNavigator() {
return (
@@ -72,6 +70,8 @@ function SplashNavigator() {
);
}
+const TripStack = createStackNavigator();
+
function TripNavigator() {
return (
diff --git a/Ejectable/screens/TripScreen.tsx b/Ejectable/screens/TripScreen.tsx
index 91147b71..04437e00 100644
--- a/Ejectable/screens/TripScreen.tsx
+++ b/Ejectable/screens/TripScreen.tsx
@@ -1,34 +1,24 @@
import * as React from 'react';
+import { Component } from 'react';
import { Button, StyleSheet, Alert } from 'react-native';
import { Text, View } from '../components/Themed';
-import { GT2Service } from '../GT2Service.js';
import { ScreenInfo2 } from '../components/ScreenInfo';
+import { geocodeAsync } from 'expo-location';
+import * as GT2 from '../App';
+import * as Nav from '../navigation/BottomTabNavigator';
+import Navigation from '../navigation';
-export default function TripScreen() {
- return (
-
- Trip Control
-
-
-
-
-
- );
-}
+var elapsed:number, lat:number, long:number, ds:number, v:number;
const styles = StyleSheet.create({
+ tripText: {
+ marginHorizontal: -100,
+ marginVertical: 60,
+ textAlign: 'left',
+ width: "80%",
+ fontSize: 12,
+ fontWeight: 'bold',
+ },
container: {
flex: 1,
alignItems: 'center',
@@ -49,3 +39,85 @@ const styles = StyleSheet.create({
width: '80%',
},
});
+
+
+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 (
+
+ Trip Control
+
+
+
+ startTrip() }
+ />
+ pauseTrip()}
+ />
+ endTrip() }
+ />
+
+
+ ); else
+ return (
+
+ Trip Control
+
+
+
+ startTrip() }
+ />
+ pauseTrip()}
+ />
+ endTrip() }
+ />
+
+
+
+ {'Elapsed: '}{elapsed}{'\n'}
+ {'Geo: '}{lat}{long}{'\n'}
+ {'Vector: '}{ds}{v}{'\n'}
+
+
+
+ );
+
+}
diff --git a/Ejectable/types.tsx b/Ejectable/types.tsx
index a310d605..8628aae1 100644
--- a/Ejectable/types.tsx
+++ b/Ejectable/types.tsx
@@ -9,6 +9,7 @@ export type RootStackParamList = {
};
export type BottomTabParamList = {
+ Splash: undefined;
Trip: undefined;
Settings: undefined;
};
diff --git a/README.md b/README.md
index 8d07b80e..358e5d0a 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,9 @@
The expo client will remain standalone, not support backend function and other enhancements.
+ Note: the initial expo app on App Store/Play will be replaced by the full react native version
+ and a binaries for the expo client will be downloadable from greentravel.app .
+
There will be several iterations of it before
...