2021-08-16 07:50:50 +00:00
|
|
|
import * as React from 'react';
|
2021-08-17 21:05:34 +00:00
|
|
|
import { Alert, Button, StyleSheet, Switch, TextInput } from 'react-native';
|
2021-08-16 07:50:50 +00:00
|
|
|
import { Text, View } from '../components/Themed';
|
2021-08-16 22:39:34 +00:00
|
|
|
import { useState } from 'react';
|
2021-08-17 21:05:34 +00:00
|
|
|
import ScreenInfo from '../components/ScreenInfo';
|
2021-08-24 00:02:21 +00:00
|
|
|
import { Trips } from '../GT2';
|
2021-08-24 15:43:25 +00:00
|
|
|
import { RootTabScreenProps } from '../types';
|
2021-08-16 07:50:50 +00:00
|
|
|
|
2021-08-24 15:43:25 +00:00
|
|
|
export default function SettingsScreen( { navigation }: RootTabScreenProps<'Settings'>) {
|
2021-08-17 21:05:34 +00:00
|
|
|
const [number, onChangeNumber] = React.useState("");
|
|
|
|
const [isKM, setMiles] = useState(false);
|
2021-08-25 02:25:04 +00:00
|
|
|
const toggleUnits = () => { setMiles(previousState => !previousState)
|
|
|
|
Trips.units = isKM ? "km" : "mi";
|
|
|
|
};
|
2021-08-16 22:39:34 +00:00
|
|
|
|
2021-08-16 07:50:50 +00:00
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<Text style={styles.title}>Model Settings</Text>
|
|
|
|
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
|
2021-08-17 21:05:34 +00:00
|
|
|
<ScreenInfo />
|
2021-08-17 15:38:51 +00:00
|
|
|
<Switch
|
2021-08-17 21:05:34 +00:00
|
|
|
style={styles.switch}
|
2021-08-16 22:39:34 +00:00
|
|
|
trackColor={{ false: "#767577", true: "#81b0ff" }}
|
|
|
|
thumbColor={true ? "#f5dd4b" : "#f4f3f4"}
|
|
|
|
ios_backgroundColor="#3e3e3e"
|
|
|
|
onValueChange={toggleUnits}
|
|
|
|
value={isKM}
|
2021-08-17 15:38:51 +00:00
|
|
|
/>
|
2021-08-17 21:05:34 +00:00
|
|
|
<View style={styles.controls} >
|
|
|
|
<Button
|
|
|
|
title="Jet"
|
2021-08-24 00:02:21 +00:00
|
|
|
onPress={() => {
|
|
|
|
Trips.co2Rate = 285.0;
|
|
|
|
Trips.CO2Effect = "carbon burden";
|
|
|
|
Alert.alert('Jet Fuel Selected \n 285 g / passenger / km')}
|
|
|
|
}
|
2021-08-17 21:05:34 +00:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
title="Gasoline"
|
2021-08-24 00:02:21 +00:00
|
|
|
onPress={() => {
|
2021-08-24 07:57:21 +00:00
|
|
|
Trips.co2Rate = 255.0;
|
2021-08-24 00:02:21 +00:00
|
|
|
Trips.CO2Effect = "carbon burden";
|
|
|
|
Alert.alert('Gasoline Selected \n 255 g for driver \n only passenger / km')}
|
|
|
|
}
|
2021-08-17 21:05:34 +00:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
title="Food"
|
2021-08-24 00:02:21 +00:00
|
|
|
onPress={() => {
|
2021-08-24 07:57:21 +00:00
|
|
|
Trips.co2Rate = -255.0;
|
2021-08-24 00:02:21 +00:00
|
|
|
Trips.CO2Effect = "carbon relief";
|
|
|
|
Alert.alert('Savings vs Gasoline Selected')}
|
|
|
|
}
|
2021-08-17 21:05:34 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<TextInput
|
2021-08-16 22:39:34 +00:00
|
|
|
style={styles.input}
|
2021-08-17 21:05:34 +00:00
|
|
|
returnKeyType={'done'}
|
2021-08-16 22:39:34 +00:00
|
|
|
onChangeText={onChangeNumber}
|
|
|
|
value={number}
|
2021-08-24 00:02:21 +00:00
|
|
|
placeholder={Trips.co2Rate.toString()}
|
2021-08-16 22:39:34 +00:00
|
|
|
keyboardType="numeric"
|
2021-08-17 21:05:34 +00:00
|
|
|
/>
|
2021-08-16 07:50:50 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-17 21:05:34 +00:00
|
|
|
|
2021-08-16 07:50:50 +00:00
|
|
|
const styles = StyleSheet.create({
|
2021-08-17 21:05:34 +00:00
|
|
|
switch: {
|
|
|
|
marginVertical: 20,
|
|
|
|
},
|
2021-08-16 07:50:50 +00:00
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
2021-08-17 21:05:34 +00:00
|
|
|
controls: {
|
|
|
|
marginVertical: 20,
|
|
|
|
width: "80%",
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: "space-between",
|
|
|
|
},
|
2021-08-16 07:50:50 +00:00
|
|
|
title: {
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
},
|
|
|
|
separator: {
|
2021-08-17 21:05:34 +00:00
|
|
|
marginVertical: 10,
|
2021-08-16 07:50:50 +00:00
|
|
|
height: 1,
|
|
|
|
width: '80%',
|
|
|
|
},
|
2021-08-16 22:39:34 +00:00
|
|
|
input: {
|
|
|
|
height: 40,
|
2021-08-17 21:05:34 +00:00
|
|
|
margin: 30,
|
2021-08-16 22:39:34 +00:00
|
|
|
borderWidth: 1,
|
|
|
|
padding: 10,
|
|
|
|
},
|
2021-08-16 07:50:50 +00:00
|
|
|
});
|