No Description

App.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import { StatusBar } from 'expo-status-bar';
  2. import React from 'react';
  3. import { View, Image, StyleSheet, Text, Button, ScrollView } from 'react-native';
  4. import data from './transfer.json'
  5. var information = ""
  6. function loadDoc() {
  7. var xhttp = new XMLHttpRequest();
  8. xhttp.onreadystatechange = function() {
  9. if (this.readyState == 4 && this.status == 200) {
  10. information = this.responseText;
  11. App.setData()
  12. }
  13. };
  14. xhttp.open("GET", "https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72", true);
  15. xhttp.send();
  16. }
  17. //change this to an external css file later
  18. const styles = StyleSheet.create({
  19. buttons: {
  20. flexDirection: 'row',
  21. justifyContent: 'center',
  22. marginTop: 30,
  23. marginBottom: 30,
  24. margin: "4px",
  25. borderColor: "grey",
  26. },
  27. container: {
  28. flexDirection: 'column',
  29. justifyContent: 'center',
  30. backgroundColor: 'black',
  31. alignItems: 'center',
  32. justifyContent: 'center',
  33. marginTop: 20,
  34. marginBottom: 500
  35. },
  36. containerbackground:{
  37. backgroundColor: '#063970',
  38. padding: "40px"
  39. },
  40. intro: {
  41. fontWeight: "bold",
  42. color:"#beb2c8",
  43. fontSize: 30,
  44. },
  45. sub: {
  46. color:"#D7D6D6",
  47. fontSize: 20,
  48. },
  49. scrollView:{
  50. marginHorizontal: 20
  51. }
  52. });
  53. //default button press
  54. const handlePress = () => false
  55. //data parsing goes here
  56. function importJSON() {
  57. var stuff = JSON.stringify(data)
  58. return stuff
  59. }
  60. //states
  61. let states = {
  62. welcome:
  63. <View style = {styles.containerbackground}>
  64. <View style = {styles.container}>
  65. <Text style={styles.intro}>BIENVENIDO!!!!</Text>
  66. <Text style={styles.sub}>Aqui podra mantenerse al tanto con las
  67. ultimas noticias relacionadas al censo</Text>
  68. <Image source={require('./testimg.gif')} />
  69. </View>
  70. </View>,
  71. dataView:
  72. <View style = {styles.containerbackground}>
  73. <ScrollView style={styles.scrollView}>
  74. <View style = {styles.container}>
  75. <Text style={styles.intro}>DATADATADATADATADATA</Text>
  76. <Text style={styles.sub}>{information}</Text>
  77. <Image source={require('./testimg.gif')} />
  78. </View>
  79. </ScrollView></View>,
  80. newsView:
  81. <View style = {styles.containerbackground}>
  82. <ScrollView style={styles.scrollView}>
  83. <View style = {styles.container}>
  84. <Text style={styles.intro}>Noticias</Text>
  85. <Image source={require('./testimg.gif')} />
  86. </View>
  87. </ScrollView></View>
  88. }
  89. class App extends React.Component {
  90. //current state
  91. state = {current: states.welcome}
  92. //state changing functions
  93. setHome = () => this.setState({ current: states.welcome })
  94. setData = () => this.setState({ current: states.dataView })
  95. setNews = () => this.setState({ current: states.newsView })
  96. //render app
  97. render() {
  98. return (
  99. <View>
  100. <View style = {styles.containerbackground}>
  101. <View style = {styles.container}>
  102. <Text style={styles.sub}> Navegador</Text>
  103. <View style = {styles.buttons}>
  104. <Button
  105. onPress = {this.setNews}
  106. title = "Noticias"
  107. color = "blue"
  108. />
  109. <Button
  110. onPress = {this.setData}
  111. title = "Datos"
  112. color = "black"
  113. />
  114. </View>
  115. {this.state.current}
  116. </View>
  117. </View>
  118. </View>
  119. );
  120. }
  121. }
  122. export default App