Advertisement
tamsenmckerley

when you go to a wedding in mexico but its not your wedding

Apr 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. assignment 4.1.4
  2.  
  3. import React, { Component } from 'react';
  4. import { AppRegistry, Text, View, TouchableHighlight, StyleSheet } from 'react-native';
  5. import { Constants } from 'expo';
  6.  
  7. export default class App extends Component {
  8. state = {
  9. oldCount: 123,
  10. newCount: 0
  11. }
  12.  
  13. euro = () => {
  14. this.setState({
  15. newCount: this.state.oldCount * 0.85,
  16. })
  17. }
  18. pound = () => {
  19. this.setState({
  20. newCount: this.state.oldCount * 0.75,
  21. })
  22. }
  23. rupee = () => {
  24. this.setState({
  25. newCount: this.state.oldCount * 67.6,
  26. })
  27. }
  28. yuan = () => {
  29. this.setState({
  30. newCount: this.state.oldCount * 6.4,
  31. })
  32. }
  33. render() {
  34. return (
  35. <View style={styles.container}>
  36. <Text style={styles.paragraph}>
  37. currency converter :)
  38. </Text>
  39. <Text style={styles.paragraph}>
  40. ​ ​
  41. </Text>
  42. <Text style={styles.paragraph}>
  43. old amount: ${this.state.oldCount}
  44. </Text>
  45. <Text style={styles.paragraph}>
  46. ​ ​
  47. </Text>
  48. <View style={styles.buttonContainer}>
  49. <TouchableHighlight
  50. style={styles.button}
  51. onPress={this.euro}
  52. >
  53. <Text style={styles.buttonText}>
  54. euro
  55. </Text>
  56. </TouchableHighlight>
  57. <TouchableHighlight
  58. style={styles.button}
  59. onPress={this.pound}
  60. >
  61. <Text style={styles.buttonText}>
  62. pound
  63. </Text>
  64. </TouchableHighlight>
  65. </View>
  66.  
  67. <View style={styles.buttonContainer}>
  68. <TouchableHighlight
  69. style={styles.button}
  70. onPress={this.rupee}
  71. >
  72. <Text style={styles.buttonText}>
  73. rupee
  74. </Text>
  75. </TouchableHighlight>
  76.  
  77. <TouchableHighlight
  78. style={styles.button}
  79. onPress={this.yuan}
  80. >
  81. <Text style={styles.buttonText}>
  82. yuan
  83. </Text>
  84. </TouchableHighlight>
  85. </View>
  86. <Text style={styles.paragraph}>
  87. ​ ​
  88. </Text>
  89. <Text style={styles.paragraph}>
  90. new amount: {this.state.newCount}
  91. </Text>
  92.  
  93. </View>
  94. );
  95. }
  96. }
  97.  
  98. const styles = StyleSheet.create({
  99. container: {
  100. flex: 1,
  101. alignItems: 'center',
  102. justifyContent: 'center',
  103. backgroundColor: '#A6808C',
  104. },
  105. paragraph: {
  106. color: 'white',
  107. fontSize: 20,
  108. textAlign: 'center',
  109. fontWeight: 'bold',
  110. },
  111. buttonContainer: {
  112. flexDirection: 'row',
  113.  
  114. },
  115. button: {
  116. height: 50,
  117. width: 80,
  118. backgroundColor: '#CCB7AE',
  119. borderColor: 'white',
  120. borderWidth: 1,
  121. alignItems: 'center',
  122. justifyContent: 'center',
  123. },
  124. buttonText: {
  125. color: 'white',
  126. fontSize: 15,
  127. },
  128. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement