-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.js
99 lines (94 loc) · 2.47 KB
/
Settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { useState } from "react";
import { StyleSheet, View, Text, TextInput } from "react-native";
const Settings = ({ defaultPole, onDefaultPoleChange }) => {
const [width, setWidth] = useState(defaultPole.width.toString());
const [height, setHeight] = useState(defaultPole.height.toString());
const [length, setLength] = useState((defaultPole.length / 100).toString());
const onWidthChange = (text) => {
setWidth(text);
onDefaultPoleChange({
width: parseFloat(text) || 0,
height: parseFloat(height) || 0,
length: parseFloat(length) || 0,
});
};
const onHeightChange = (text) => {
setHeight(text);
onDefaultPoleChange({
width: parseFloat(width) || 0,
height: parseFloat(text) || 0,
length: parseFloat(length) || 0,
});
};
const onLengthChange = (text) => {
setLength(text);
onDefaultPoleChange({
width: parseFloat(width) || 0,
height: parseFloat(height) || 0,
length: parseFloat(text) * 100 || 0,
});
};
return (
<View style={styles.container}>
<Text style={styles.title}>Poste predeterminado</Text>
<View style={styles.inputContainer}>
<View>
<TextInput
style={styles.input}
keyboardType="numeric"
placeholder="Ancho"
value={width.toString()}
onChangeText={onWidthChange}
/>
<Text>Ancho (cm)</Text>
</View>
<View>
<TextInput
style={styles.input}
keyboardType="numeric"
placeholder="Alto"
value={height.toString()}
onChangeText={onHeightChange}
/>
<Text>Alto (cm)</Text>
</View>
<View>
<TextInput
style={styles.input}
keyboardType="numeric"
placeholder="Largo"
value={length.toString()}
onChangeText={onLengthChange}
/>
<Text>Largo (m)</Text>
</View>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
backgroundColor: "#FFF",
padding: 20,
},
title: {
fontSize: 18,
fontWeight: "bold",
color: "#FFA500",
marginBottom: 10,
},
inputContainer: {
flexDirection: "row",
justifyContent: "space-around",
alignItems: "center",
marginVertical: 20,
},
input: {
borderWidth: 1,
borderColor: "#999",
borderRadius: 5,
width: "100%",
padding: 10,
},
});
export default Settings;