-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
196 lines (182 loc) · 4.84 KB
/
App.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
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
import { StatusBar } from "expo-status-bar";
import React, { useState } from "react";
import { StyleSheet, Text, View, Button } from "react-native";
class Age extends React.Component {
constructor() {
super();
this.state = {
age: 25,
};
}
render() {
return (
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
width: "60%",
marginBottom: 20,
}}
>
<Text style={ageStyles.text}>Age: </Text>
<Button
title=" - "
onPress={() => {
this.setState({ age: this.state.age - 1 });
}}
/>
<Text style={ageStyles.text}>{this.state.age}</Text>
<Button
title=" + "
onPress={() => {
this.setState({ age: this.state.age + 1 });
}}
/>
</View>
);
}
}
function Keypad() {
const [getText, setText] = useState("");
const buttonPress = (mesg) => {
setText(getText + mesg);
};
return (
<View>
<View style={styless.getTextStyle}>
<Text style={{fontSize: 40, color: 'white'}}>{getText}</Text>
</View>
<View style={{ flexDirection: "row" }}>
<View style={styless.buttonStyle}>
<Button title="7" onPress={buttonPress.bind(this, 7)} />
</View>
<View style={styless.buttonStyle}>
<Button title="8" onPress={buttonPress.bind(this, 8)} />
</View>
<View style={styless.buttonStyle}>
<Button title="9" onPress={buttonPress.bind(this, 9)} />
</View>
<View style={styless.buttonStyle}>
<Button title="-" onPress={buttonPress.bind(this, "-")} />
</View>
</View>
<View style={{ flexDirection: "row" }}>
<View style={styless.buttonStyle}>
<Button title="4" onPress={buttonPress.bind(this, 4)} />
</View>
<View style={styless.buttonStyle}>
<Button title="5" onPress={buttonPress.bind(this, 5)} />
</View>
<View style={styless.buttonStyle}>
<Button title="6" onPress={buttonPress.bind(this, 6)} />
</View>
<View style={styless.buttonStyle}>
<Button title="+" onPress={buttonPress.bind(this, "+")} />
</View>
</View>
<View style={{ flexDirection: "row" }}>
<View style={styless.buttonStyle}>
<Button title="1" onPress={buttonPress.bind(this, 1)} />
</View>
<View style={styless.buttonStyle}>
<Button title="2" onPress={buttonPress.bind(this, 2)} />
</View>
<View style={styless.buttonStyle}>
<Button title="3" onPress={buttonPress.bind(this, 3)} />
</View>
<View style={styless.buttonStyle}>
<Button title="/" onPress={buttonPress.bind(this, "/")} />
</View>
</View>
</View>
);
}
function App() {
// const [getFirstName, setFirstName] = useState("First Name Here!");
// const [getLastName, setLastName] = useState("Last Name Here!");
const [getName, setName] = useState({
fName: "FirstName",
lName: "LastName",
});
const buttonPress = (msg) => {
setText(getText + msg);
};
const updateFirstName = (firstname) => {
setName({ fName: firstname, lName: getName.lName });
};
return (
<View style={styles.container}>
<StatusBar style="auto" />
<View style={styles.innerView}>
<Text style={styles.text}>{getName.fName}</Text>
</View>
<View style={styles.innerView}>
<Text style={styles.text}>{getName.lName}</Text>
</View>
<View style={styles.buttonContainer}>
<View style={{ padding: 10 }}>
<Button
title="UPDATE FIRSTNAME"
onPress={updateFirstName.bind(this, "John")}
/>
</View>
<View style={{ padding: 10 }}>
<Button
title="UPDATE LASTNAME"
onPress={() => {
setName({ fName: getName.fName, lName: "Bengston" });
}}
/>
</View>
</View>
<Age />
<Keypad />
</View>
);
}
const ageStyles = StyleSheet.create({
text: {
fontSize: 24,
},
});
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
innerView: {
padding: 10,
},
text: {
fontSize: 24,
},
buttonContainer: {
flexDirection: "row",
},
});
const styless = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
buttonStyle: {
// padding: 10,
width: "25%",
},
bottomButtonStyle: {
padding: 10,
width: "45%",
},
getTextStyle: {
backgroundColor: '#808080',
marginBottom: 1,
alignItems: 'flex-end',
height: 70,
justifyContent: "center"
},
});
export default App;