GT2/Ejectable/screens/SettingsScreen.tsx

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-08-16 07:50:50 +00:00
import * as React from 'react';
2021-08-16 22:39:34 +00:00
import { 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';
import SettingsScreenInfo from '../components/SettingsScreenInfo';
2021-08-16 07:50:50 +00:00
export default function SettingsScreen() {
2021-08-16 22:39:34 +00:00
const [text, onChangeText] = React.useState("Useless Text");
const [number, onChangeNumber] = React.useState(null);
const [isKM, setIsKM] = useState(false);
const toggleUnits = () => setIsKM(previousState => !previousState);
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-16 22:39:34 +00:00
<SettingsScreenInfo />
<Switch
trackColor={{ false: "#767577", true: "#81b0ff" }}
thumbColor={true ? "#f5dd4b" : "#f4f3f4"}
ios_backgroundColor="#3e3e3e"
onValueChange={toggleUnits}
value={isKM}
/>
<TextInput
style={styles.input}
onChangeText={onChangeNumber}
value={number}
placeholder="CO2 Per km/mi"
keyboardType="numeric"
/>
2021-08-16 07:50:50 +00:00
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
title: {
fontSize: 20,
fontWeight: 'bold',
},
separator: {
marginVertical: 30,
height: 1,
width: '80%',
},
2021-08-16 22:39:34 +00:00
input: {
height: 40,
margin: 12,
borderWidth: 1,
padding: 10,
},
2021-08-16 07:50:50 +00:00
});