This commit is contained in:
parent
a763ef9d5f
commit
a8bd22c0a3
|
@ -4,7 +4,7 @@ import { Pressable } from 'react-native';
|
|||
import { Text, View } from './components/Themed.tsx';
|
||||
import * as TaskManager from 'expo-task-manager';
|
||||
import * as Location from 'expo-location';
|
||||
import { Trips, setBgOps } from './GT2';
|
||||
import { bgOps, Trips, setBgOps } from './GT2';
|
||||
|
||||
const LOCATION_TASK_NAME = 'background-location-task';
|
||||
|
||||
|
@ -26,12 +26,20 @@ const LOCATION_TASK_NAME = 'background-location-task';
|
|||
};
|
||||
|
||||
export default function PermissionsButton() {
|
||||
if (!bgOps)
|
||||
return(
|
||||
<View style={styles.container} lightColor="lime" darkColor="forestgreen">
|
||||
<Pressable style={styles.button} onPress={requestPermissions}>
|
||||
<Text style={styles.text}>{'Enable background operations'}</Text>
|
||||
<Text style={styles.text2}>{' (Only used during a trip)'}</Text>
|
||||
</Pressable>
|
||||
</View>);
|
||||
else
|
||||
return(
|
||||
<View style={styles.container} lightColor="lime" darkColor="forestgreen">
|
||||
<Text style={styles.text}>{'Trips can run in background.'}</Text>
|
||||
</View>);
|
||||
|
||||
}
|
||||
|
||||
TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
|
||||
|
@ -50,12 +58,20 @@ TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
|
|||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginVertical: 20,
|
||||
marginBottom: -30,
|
||||
marginVertical: 2,
|
||||
marginTop: -40,
|
||||
marginBottom: 25,
|
||||
alignItems: 'center',
|
||||
},
|
||||
button: {
|
||||
fontSize: 10,
|
||||
backgroundColor: 'lime',
|
||||
},
|
||||
text: {
|
||||
color: "blue",
|
||||
},
|
||||
text2: {
|
||||
fontSize: 8,
|
||||
color: "navy",
|
||||
}
|
||||
});
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
"permissions": [
|
||||
"ACCESS_COARSE_LOCATION",
|
||||
"ACCESS_FINE_LOCATION",
|
||||
"FOREGROUND_SERVICE"
|
||||
"FOREGROUND_SERVICE",
|
||||
"ACCESS_BACKGROUND_LOCATION"
|
||||
],
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/images/adaptive-icon.png",
|
||||
|
|
|
@ -2,8 +2,7 @@ import React from 'react';
|
|||
import { StyleSheet, TouchableOpacity } from 'react-native';
|
||||
import { Text, View } from './Themed';
|
||||
import * as Device from 'expo-device';
|
||||
import { bgOps, ver } from '../GT2';
|
||||
import PermissionsButton from '../BGEO';
|
||||
import { ver } from '../GT2';
|
||||
|
||||
export default function ScreenInfo() {
|
||||
return (
|
||||
|
@ -56,7 +55,6 @@ export function ScreenInfo5() {
|
|||
}
|
||||
|
||||
export function ScreenInfo3() {
|
||||
if (bgOps)
|
||||
return (
|
||||
<View style={styles.splashContainer}>
|
||||
<Text
|
||||
|
@ -79,30 +77,6 @@ export function ScreenInfo3() {
|
|||
</Text>
|
||||
</View>
|
||||
);
|
||||
else
|
||||
return (
|
||||
<View style={styles.splashContainer}>
|
||||
<Text
|
||||
style={styles.titleText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
{'Green Travel Calculator v. ' + ver }
|
||||
</Text>
|
||||
<Text
|
||||
style={styles.versionText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
expo {Device.osName == 'iOS' ? 'iOS ' : 'android '} version
|
||||
</Text>
|
||||
<PermissionsButton />
|
||||
<Text
|
||||
style={styles.cautionText}
|
||||
lightColor="rgba(0,0,0,0.8)"
|
||||
darkColor="rgba(255,255,255,0.8)">
|
||||
{'\nNote: accuracy depends on sensitivity setting, your device, and carrier.'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
|
|
@ -6,6 +6,7 @@ import { ScreenInfo2 } from '../components/ScreenInfo';
|
|||
import { bgOps, TripDisplay, LastTrip, Trips, setEndIsLast } from '../GT2';
|
||||
import { RootTabScreenProps } from '../types';
|
||||
import * as Device from 'expo-device';
|
||||
import PermissionsButton from '../BGEO';
|
||||
|
||||
var debug:number = 0;
|
||||
|
||||
|
@ -65,6 +66,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
|
|||
if (Trips.nTrips < 1)
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<PermissionsButton />
|
||||
<Text style={styles.title}>Trip Control</Text>
|
||||
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
|
||||
<ScreenInfo2 />
|
||||
|
@ -91,6 +93,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>)
|
|||
else
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<PermissionsButton />
|
||||
<Text style={styles.title}>Trip Control</Text>
|
||||
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
|
||||
<ScreenInfo2 />
|
||||
|
|
Loading…
Reference in New Issue