Aucune description

App.js 3.5KB

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