-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
122 lines (114 loc) · 2.72 KB
/
index.ios.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
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
'use-strict'
import Button from './components/Button.js'
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TextInput, TouchableOpacity, KeyboardAvoidingView
} from 'react-native';
import Login from './components/init/Login';
var root = require('./components/root');
export default class cool extends Component {
constructor(){
super();
this.state = {
height: 0,
weight: 0
};
}
calcBmi(e){
var {height, weight} = this.state;
var h = height.trim() / 100;
var bmi = (weight / (h*h)).toFixed(2);
var result;
if(bmi < 18){
result = '${bmi} Eat more because you are too thin and boney'
}else if(bmi < 25){
result = '${bmi} You good'
}else if(bmi < 30){
result = '${bmi} Eat less because you a bit overweight'
}else{
result = '${bmi} Holy moly eat less. You too fat'
}
}
render() {
return (
<KeyboardAvoidingView behavior='padding' style = {styles.wrapper}>
<Text style = {styles.textStyle}>Calculate Your BMI:</Text>
<View style = {styles.cont}>
<TextInput
placeholder = "Height"
onChangeText={(height) => this.setState({height})}
keyboardType='numeric'
value={this.state.height}
ref='height'
style={styles.input}
/>
<TextInput
placeholder = "Weight"
keyboardType='numeric'
onChangeText={(weight) => this.setState({weight})}
value={this.state.weight}
ref="weight"
style={styles.input}
/>
<TouchableOpacity
style = {styles.buttonContatiner}
onPress={this.calcBmi.bind(this)}>
<Text style = {styles.woah}>CALCULATE</Text>
</TouchableOpacity>
<Text style = {styles.result}>
Your BMI Is: {this.state.result}
</Text>
</View>
</KeyboardAvoidingView>
);
}
}
const styles = StyleSheet.create({
wrapper:{
backgroundColor: '#009688',
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
textStyle:{
color: '#FFFFFF',
fontSize: 20,
textAlign: 'center'
},
input:{
height: 40,
width: 250,
color: '#FFF',
marginTop: 20,
marginBottom: 20,
paddingHorizontal: 10,
backgroundColor: 'rgba(255,255,255,0.2)'
},
woah:{
textAlign: 'center',
color: '#FFFFFF',
padding: 10
},
buttonContatiner:{
backgroundColor: '#00897B',
width: 250
},
cont:{
alignItems: 'center'
},
result:{
textAlign: 'center',
color: '#FFFFFF',
marginTop: 20
}
});
AppRegistry.registerComponent('cool', () => cool);