-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
112 lines (99 loc) · 2.99 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
import React, { Component } from 'react';
import { AppRegistry, Text, View, TouchableHighlight, StyleSheet, TextInput } from 'react-native';
import { Constants } from 'expo';
export default class App extends Component {
// define state here
state = {
bal:1.00,
newBal:0,
}
// write your usd conversion functions here
toEuro = () => {
this.setState({
newBal: this.state.bal *.85,
})
}
toPound = () => {
this.setState({
newBal: this.state.bal *.75,
})
}
toRupee = () => {
this.setState({
newBal: this.state.bal *67.60,
})
}
toAusDollar = () => {
this.setState({
newBal: this.state.bal *1.32,
})
}
render() {
return (
<View style={styles.container}>
<Text style={styles.paragraph}>
Currency Converter App
</Text>
<TouchableHighlight
style={styles.button}
onPress = {this.toEuro}
>
<Text style={styles.buttonText}>
USD to Euro
</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.button}
onPress = {this.toPound}
>
<Text style={styles.buttonText}>
USD to Pound
</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.button}
onPress = {this.toRupee}
>
<Text style={styles.buttonText}>
USD to Rupee
</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.button}
onPress = {this.toAusDollar}
>
<Text style={styles.buttonText}>
USD to Aussie
</Text>
</TouchableHighlight>
<Text style={styles.paragraph}>
Initial Balance: {this.state.bal}
</Text>
<Text style={styles.paragraph}>
My New Balance: {this.state.newBal}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#8aa9db',
},
button: {
marginBottom: 10,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white',
height: 40,
width: 100,
borderColor: 'black',
borderWidth: 1,
},
buttonText: {
color:'blue',
}
});