-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form.js
148 lines (137 loc) · 3.39 KB
/
Form.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import React from 'react';
import styled from 'styled-components/native';
import { View, Text, TextInput } from 'react-native';
import Icon from '@expo/vector-icons/Entypo';
import Container from './components/Container';
const ThreeColumn = styled.View`
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: #fff;
`;
const MenuItem = styled.TouchableOpacity`
flex: 1;
padding-top: 10px;
padding-bottom: 10px;
display: flex;
flex-direction: column;
`;
const ListItem = styled.TouchableOpacity`
padding-top: 5px;
padding-bottom: 5px;
`;
const Row = styled.View`
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding-bottom: 12px;
`;
const IconRow = styled.View`
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
`;
const Label = styled.Text`
font-weight: bold;
font-size: 18;
`;
const SelectorValue = styled.Text`font-size: 16;`;
const Options = styled.FlatList``;
const Form = ({
currName,
children,
size,
weight,
grade,
onSelect,
optionsData,
onListItemPressed,
onChangeText,
}) => {
const showChildren = !optionsData.length;
const color = 'rgb(67, 73, 46)';
return (
<Container>
<ThreeColumn>
<MenuItem onPress={() => onSelect(1)}>
<Row>
<Label>Casing Size</Label>
</Row>
<IconRow>
<SelectorValue>{size}</SelectorValue>
<Icon
name={currName !== 'size' || showChildren ? 'triangle-up' : 'triangle-down'}
size={25}
color={color}
/>
</IconRow>
</MenuItem>
<MenuItem onPress={() => onSelect(2)}>
<Row>
<Label>Weight</Label>
</Row>
<IconRow>
<SelectorValue>{weight}</SelectorValue>
<Icon
name={currName !== 'weight' || showChildren ? 'triangle-up' : 'triangle-down'}
size={25}
color={color}
/>
</IconRow>
</MenuItem>
<MenuItem onPress={() => onSelect(3)}>
<Row>
<Label>Grade</Label>
</Row>
<IconRow>
<SelectorValue>{grade}</SelectorValue>
<Icon
name={currName !== 'grade' || showChildren ? 'triangle-up' : 'triangle-down'}
size={25}
color={color}
/>
</IconRow>
</MenuItem>
</ThreeColumn>
<TextInput
name="length"
keyboardType="numeric"
style={{
fontSize: 20,
fontWeight: 'bold',
textAlign: 'right',
width: '100%',
padding: 5,
margin: 2,
}}
onChangeText={onChangeText}
placeholder="Casing Length (feet)"
/>
{showChildren ? (
children
) : (
<Options
ItemSeparatorComponent={() => (
<View
style={{
height: 1,
backgroundColor: '#d3d3d3',
}}
/>
)}
data={optionsData}
renderItem={({ item }) => (
<ListItem onPress={() => onListItemPressed(item)}>
<Text style={{ paddingLeft: 20, fontSize: 25 }}>{item}</Text>
</ListItem>
)}
keyExtractor={item => item}
/>
)}
</Container>
);
};
export default Form;