No Description

App.js 3.3KB

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