-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
201 lines (195 loc) · 5.58 KB
/
Copy pathApp.js
File metadata and controls
201 lines (195 loc) · 5.58 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import { Button, Image, StyleSheet, Text, TextInput, View } from "react-native";
import React, { useEffect } from "react";
export default function App() {
const [ww, onChangeww] = React.useState(0);
const [hh, onChangehh] = React.useState(0);
const [ag, onChangeag] = React.useState(0);
const [gender, onChangegender] = React.useState("");
const [res, onChangeres] = React.useState(0);
const [res1, onChangeres1] = React.useState(0);
const [res2, onChangeres2] = React.useState(0);
const [res3, onChangeres3] = React.useState(0);
const [res4, onChangeres4] = React.useState(0);
const [res5, onChangeres5] = React.useState(0);
const [res6, onChangeres6] = React.useState(0);
const [res7, onChangeres7] = React.useState(0);
const [click1, onChangeclick1] = React.useState(false);
useEffect(() => {
CUL();
});
const CUL = () => {
const BMI = (w, h) => {
w = ww;
h = hh;
onChangeres(ww / hh / hh);
const IBW = (g) => {
g = gender;
if (gender === "male") {
onChangeres3(hh * hh * 24);
} else if (gender === "female") {
onChangeres3(hh * hh * 22.5);
}
};
IBW();
const KCAL = (g) => {
g = gender;
if (res < 30) {
return onChangeres1(ww * 25) + onChangeres2(ww * 30);
} else if (res > 30 && res < 50) {
return onChangeres1(ww * 11) + onChangeres2(ww * 14);
} else if (res > 50 && gender === "male") {
return (
onChangeres1(hh * hh * 24 * 22) + onChangeres2(hh * hh * 24 * 25)
);
} else if (res > 50 && gender === "female") {
return (
onChangeres1(hh * hh * 22.5 * 22) +
onChangeres2(hh * hh * 22.5 * 25)
);
}
};
KCAL();
const FLUID = (age) => {
age = ag;
if (age > 18 && res > 30 && gender === "male")
return onChangeres6(hh * hh * 24 * 25);
else if (age > 18 && res > 30 && gender === "female")
return onChangeres6(hh * hh * 25 * 22.5);
else if (age > 18 && res < 30) return onChangeres6(ww * 30);
};
FLUID();
const PROTEIN = () => {
if (res < 30) {
return onChangeres4(ww * 1.2) + onChangeres5(ww * 2);
} else if (res > 30) {
return onChangeres4(res3 * 2) + onChangeres5(res3 * 2.5);
}
};
PROTEIN();
const ADW = () => {
onChangeres7(0.25 * (ww - res3) + res3);
};
ADW();
};
BMI();
};
return (
<View style={styles.container}>
<Image
source={{
uri: "https://upload.wikimedia.org/wikipedia/commons/b/b0/ICU_Medical_Logo_at_6.49.04_PM.png",
}}
style={{ width: 120, height: 100, marginBottom: 55 }}
/>
<Text style={[styles.bigBlue]}>ICU Calculator</Text>
<View style={styles.flex}>
<TextInput
onChangeText={onChangeww}
style={styles.input}
placeholder="Width"
inlineImageLeft="search_icon"
accessibilityLabelledBy="formLabel"
/>
<TextInput
style={styles.input}
onChangeText={onChangehh}
placeholder="Height"
accessibilityLabel="input"
accessibilityLabelledBy="formLabel"
/>
</View>
<View style={styles.flex}>
<TextInput
style={styles.input}
onChangeText={onChangegender}
placeholder="Gender"
accessibilityLabel="select"
accessibilityLabelledBy="formLabel"
/>
<TextInput
style={styles.input}
onChangeText={onChangeag}
placeholder="Age"
accessibilityLabel="input"
accessibilityLabelledBy="formLabel"
/>
</View>
<View style={styles.separator}>
<Button onPress={onChangeclick1} title="Calculate" />
</View>
{!click1 ? (
<></>
) : (
<>
<View style={styles.flex}>
<Text style={[styles.red]}>Fluid: {Math.round(res6)}</Text>
<Text style={[styles.red]}>BMI: {res.toFixed(1)}</Text>
<Text style={[styles.red]}>IBW: {Math.round(res3)}</Text>
</View>
<View style={styles.flex}>
<Text style={[styles.red]}>ADW: {Math.round(res7)}</Text>
<Text style={[styles.red]}>
KCAL: {res1.toFixed()} - {res2.toFixed()}
</Text>
<Text style={[styles.red]}>
Protien: {Math.round(res4)} - {Math.round(res5)}
</Text>
</View>
</>
)}
<View style={[styles.footer]}>
<Text>By Sultan Alharbi - p04x@hotmail.com</Text>
<Text>All results tested by Nutrition team</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "silver",
alignItems: "center",
justifyContent: "center",
},
footer: {
marginTop: 190,
color: "black",
fontWeight: "bold",
alignItems: "center",
justifyContent: "center",
},
separator: {
marginVertical: 8,
borderBottomColor: "black",
borderWidth: 1,
borderColor: "black",
color: "black",
},
flex: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
},
bigBlue: {
color: "black",
fontWeight: "bold",
fontSize: 30,
marginBottom: 50,
},
red: {
color: "black",
fontWeight: "bold",
fontSize: 12,
marginBottom: 5,
margin: 6,
},
input: {
borderWidth: 1,
borderColor: "black",
padding: 8,
margin: 4,
borderRadius: 6,
width: 100,
height: 40,
},
});