Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { AppRegistry, Text, View, TouchableHighlight, StyleSheet, Image } from 'react-native';
  3. import { Constants } from 'expo';
  4.  
  5. export default class App extends Component {
  6. state = {
  7. Login: 'Login'
  8. SignUp: 'SignUp'
  9.  
  10.  
  11. }
  12.  
  13. newState = () => {
  14. this.setState ({
  15. Login: 'Woohoo, you logged in'
  16.  
  17. })
  18. }
  19. newState2 = () => {
  20. this.setState ({
  21. SignUp: 'Yay you signed up'
  22.  
  23. })
  24. }
  25. render() {
  26. return (
  27. <View style={styles.container}>
  28.  
  29. <View style={styles.yellowBox}>
  30.  
  31. <Image
  32. source={{ uri: 'https://codehs.com/uploads/c799accde67e1fd3bbd699119b4e1c83' }}
  33. style={{ height: 50, width: 50 }}
  34. />
  35. </View>
  36.  
  37. <View style={styles.redBox}>
  38. <TouchableHighlight
  39. onPress = {this.newState}
  40.  
  41.  
  42. >
  43. <Text style={styles.paragraph}>
  44. {this.state.Login}
  45. </Text>
  46. </TouchableHighlight>
  47.  
  48.  
  49.  
  50. </View>
  51. <View style={styles.blueBox}>
  52. <TouchableHighlight
  53. onPress = {this.newState2}
  54.  
  55.  
  56. >
  57. <Text style={styles.paragraph}>
  58. {this.state.SignUp}
  59. </Text>
  60. </TouchableHighlight>
  61.  
  62.  
  63. </View>
  64. </View>
  65. );
  66. }
  67. }
  68.  
  69. const styles = StyleSheet.create({
  70. container: {
  71. flex: 1,
  72. },
  73. yellowBox: {
  74. flex: 7,
  75. backgroundColor: 'yellow',
  76. justifyContent: 'center',
  77. alignItems: 'center',
  78. },
  79. redBox: {
  80. flex: 1,
  81. backgroundColor: 'red',
  82. justifyContent: 'center',
  83. alignItems: 'center',
  84. color: 'white',
  85. },
  86. blueBox: {
  87. flex: 1,
  88. backgroundColor: 'blue',
  89. justifyContent: 'center',
  90. alignItems: 'center',
  91. color: 'white',
  92. },
  93. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement