andrea.nieves7 2 years ago
parent
commit
89d2a57c82
4 changed files with 184 additions and 36 deletions
  1. 114
    33
      App.js
  2. 49
    0
      package-lock.json
  3. 3
    0
      package.json
  4. 18
    3
      yarn.lock

+ 114
- 33
App.js View File

1
 import { StatusBar } from 'expo-status-bar';
1
 import { StatusBar } from 'expo-status-bar';
2
-import React from 'react';
3
-import { View, Image, StyleSheet, Text, Button, ScrollView } from 'react-native';
2
+import React, {useState, useEffect} from 'react';
3
+import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable} from 'react-native';
4
 import data from './transfer.json' 
4
 import data from './transfer.json' 
5
-
5
+import { Dropdown } from 'react-native-element-dropdown';
6
 
6
 
7
 //where data will be put
7
 //where data will be put
8
 var organizedData
8
 var organizedData
9
 
9
 
10
 //where data will be stored
10
 //where data will be stored
11
-var information = "default text"
11
+var information = "data goes here"
12
 
12
 
13
 //organize data make it pretty
13
 //organize data make it pretty
14
 function organize(){
14
 function organize(){
18
 	
18
 	
19
 }
19
 }
20
 
20
 
21
-
22
 //calls data query
21
 //calls data query
23
-function loadDoc() {
22
+function loadDoc(query) {
24
   var xhttp = new XMLHttpRequest();
23
   var xhttp = new XMLHttpRequest();
25
   xhttp.onreadystatechange = function() {
24
   xhttp.onreadystatechange = function() {
26
     if (this.readyState == 4 && this.status == 200) {
25
     if (this.readyState == 4 && this.status == 200) {
27
          information = this.responseText;
26
          information = this.responseText;
27
+		 console.log(information[6])
28
 		 organize()
28
 		 organize()
29
   }
29
   }
30
   };
30
   };
31
-  xhttp.open("GET", "https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72", true);
31
+  xhttp.open("GET", query, true);
32
   xhttp.send();
32
   xhttp.send();
33
   
33
   
34
 }
34
 }
35
 
35
 
36
-loadDoc()
37
-
38
 
36
 
37
+//"https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72"
39
 
38
 
40
 
39
 
41
 
40
 
75
   },
74
   },
76
   scrollView:{
75
   scrollView:{
77
 	  marginHorizontal: 20
76
 	  marginHorizontal: 20
77
+  },
78
+  listItem:{
79
+	  fontSize: 30,
80
+	  color: "white",
81
+	  textDecorationLines: "underline"
82
+  },
83
+  listButtons:{
84
+	  fontSize: 15,
85
+	  color: "white",
86
+	  textDecorationLines: "underline"  
87
+  },
88
+  buttonsVer: {
89
+	  flexDirection: 'column',
90
+	  justifyContent: 'center',
91
+	  marginTop: 40,
92
+	  marginBottom: 30,
93
+	  margin: 30,
94
+	  borderColor: "grey",
78
   }
95
   }
79
 });
96
 });
80
 
97
 
98
+
81
 //default button press
99
 //default button press
82
 
100
 
83
 const handlePress = () => false
101
 const handlePress = () => false
90
 	return stuff
108
 	return stuff
91
 }
109
 }
92
 
110
 
93
-//states
111
+//calls update to data in data page
94
 
112
 
95
-let states = {
113
+function updateInfo(option){
114
+	
115
+	switch(option){
96
 	
116
 	
117
+		case 0:
118
+			break;
119
+		case 1:
120
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72")
121
+			break;
122
+		case 2:
123
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP03PR)&for=county:127&in=state:72")
124
+			break;
125
+		case 3:
126
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP04PR)&for=county:127&in=state:72")
127
+			break;
128
+		case 4:
129
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP05PR)&for=county:127&in=state:72")
130
+			break;
131
+		
132
+	}
133
+}
134
+
135
+
136
+function DataDisplay({parentOption}) {
137
+  const [option, setOption] = useState(0);
138
+
139
+  useEffect(() => {
140
+    setOption(parentOption);
141
+	console.log(option)
142
+    updateInfo(option);
143
+  }, [parentOption]); // 👈️ add props as dependencies
144
+
145
+
146
+  return (
147
+    <Text style={styles.sub}>{information}</Text>
148
+  );
149
+}
150
+
151
+function Parent() {
152
+  const [parentOption, setParentOption] = useState(0);
153
+
154
+  return (
155
+    <View>
156
+		<Pressable onPress = {() => setParentOption(current => 1)}>
157
+			<Text style = {styles.listItem}> DP02PR </Text>
158
+		</Pressable>
159
+			
160
+		<Pressable onPress = {() => setParentOption(current => 2)}>
161
+			<Text style = {styles.listItem}> DP03PR </Text>
162
+		</Pressable>
163
+			
164
+		<Pressable onPress = {() => setParentOption(current => 3)}>
165
+			<Text style = {styles.listItem}> DP04PR </Text>
166
+		</Pressable>
167
+			
168
+		<Pressable onPress = {() => setParentOption(current => 4)}>
169
+			<Text style = {styles.listItem}> DP05PR </Text>
170
+		</Pressable>
171
+
172
+		<DataDisplay parentOption={parentOption} />
173
+    </View>
174
+  );
175
+}
176
+
177
+
178
+class App extends React.Component {
179
+
180
+
181
+vars = {
97
 		welcome:
182
 		welcome:
98
 		  
183
 		  
99
 
184
 
124
 			<Image source={require('./testimg.gif')} />
209
 			<Image source={require('./testimg.gif')} />
125
 			
210
 			
126
 		 </View>
211
 		 </View>
127
-		</ScrollView></View>
128
-
212
+		</ScrollView></View>,
129
 		
213
 		
130
-	}
131
-
132
-function dataView(){	
133
-	return (
134
-	<View style = {styles.containerbackground}>
214
+		dataOp:
215
+		<View style = {styles.containerbackground}>
135
 		<ScrollView style={styles.scrollView}>
216
 		<ScrollView style={styles.scrollView}>
136
 		 <View style = {styles.container}>
217
 		 <View style = {styles.container}>
218
+			
137
 		  
219
 		  
138
-		  
139
-			<Text style={styles.intro}>DATADATADATADATADATA</Text>
140
-		
141
-			<Text style={styles.sub}>{information}</Text>
142
-			 
220
+			<Text style={styles.intro}>DATA VIEWING PROJECT</Text>		
221
+			
222
+			<Parent />
223
+			
143
 			<Image source={require('./testimg.gif')} />
224
 			<Image source={require('./testimg.gif')} />
144
 			
225
 			
145
 		 </View>
226
 		 </View>
146
 		</ScrollView></View>
227
 		</ScrollView></View>
147
-	)
148
-}
149
-
150
-
151
-class App extends React.Component {
228
+		
229
+		
152
 
230
 
231
+		
232
+	}
153
 //current state
233
 //current state
154
-state = {current: states.welcome}
234
+state = {current: this.vars.welcome}
155
 
235
 
156
 //state changing functions
236
 //state changing functions
157
-setHome = () => this.setState({ current: states.welcome })
237
+setHome = () => this.setState({ current: this.vars.welcome })
158
 
238
 
159
 
239
 
160
-setData = () => this.setState({current: dataView()})
240
+setData = () => this.setState({current: this.vars.dataOp})
161
 
241
 
162
 
242
 
163
-setNews = () => this.setState({ current: states.newsView })
164
-	
243
+setNews = () => this.setState({ current: this.vars.newsView })
244
+
165
 	
245
 	
246
+
166
 	//render app
247
 	//render app
167
    render() {
248
    render() {
168
       return (
249
       return (

+ 49
- 0
package-lock.json View File

9
       "version": "1.0.0",
9
       "version": "1.0.0",
10
       "dependencies": {
10
       "dependencies": {
11
         "@expo/webpack-config": "^0.17.2",
11
         "@expo/webpack-config": "^0.17.2",
12
+        "@react-native-picker/picker": "^2.4.8",
12
         "expo": "^47.0.6",
13
         "expo": "^47.0.6",
13
         "expo-font": "~11.0.1",
14
         "expo-font": "~11.0.1",
14
         "expo-splash-screen": "~0.17.5",
15
         "expo-splash-screen": "~0.17.5",
16
         "react": "18.1.0",
17
         "react": "18.1.0",
17
         "react-dom": "18.1.0",
18
         "react-dom": "18.1.0",
18
         "react-native": "0.70.5",
19
         "react-native": "0.70.5",
20
+        "react-native-dropdown-picker": "^5.4.3",
21
+        "react-native-element-dropdown": "^2.5.0",
19
         "react-native-web": "~0.18.9"
22
         "react-native-web": "~0.18.9"
20
       },
23
       },
21
       "devDependencies": {
24
       "devDependencies": {
3786
         "node": ">=8"
3789
         "node": ">=8"
3787
       }
3790
       }
3788
     },
3791
     },
3792
+    "node_modules/@react-native-picker/picker": {
3793
+      "version": "2.4.8",
3794
+      "resolved": "https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.4.8.tgz",
3795
+      "integrity": "sha512-5NQ5XPo1B03YNqKFrV6h9L3CQaHlB80wd4ETHUEABRP2iLh7FHLVObX2GfziD+K/VJb8G4KZcZ23NFBFP1f7bg==",
3796
+      "peerDependencies": {
3797
+        "react": ">=16",
3798
+        "react-native": ">=0.57"
3799
+      }
3800
+    },
3789
     "node_modules/@react-native/assets": {
3801
     "node_modules/@react-native/assets": {
3790
       "version": "1.0.0",
3802
       "version": "1.0.0",
3791
       "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
3803
       "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
14635
         "nullthrows": "^1.1.1"
14647
         "nullthrows": "^1.1.1"
14636
       }
14648
       }
14637
     },
14649
     },
14650
+    "node_modules/react-native-dropdown-picker": {
14651
+      "version": "5.4.3",
14652
+      "resolved": "https://registry.npmjs.org/react-native-dropdown-picker/-/react-native-dropdown-picker-5.4.3.tgz",
14653
+      "integrity": "sha512-cwZzFcpyx/Stw3lZH2bvXxcsgwkR8c3rRZtOnlvyuN5pAplzA/9AiAxYlnJuspP9VvyU1XMePKOpgcHce6iyhA==",
14654
+      "peerDependencies": {
14655
+        "react": "*",
14656
+        "react-native": "*"
14657
+      }
14658
+    },
14659
+    "node_modules/react-native-element-dropdown": {
14660
+      "version": "2.5.0",
14661
+      "resolved": "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.5.0.tgz",
14662
+      "integrity": "sha512-ZlatJ2X0/iR+rgZ9Mcp5KO9JvL9fAI/ZGnbdo07wY0CeqVMxAnAGyj2INEqtwkd81bEHVmWDlhpFgy0xhX6qNQ==",
14663
+      "peerDependencies": {
14664
+        "lodash": "*",
14665
+        "react": "*",
14666
+        "react-native": "*"
14667
+      }
14668
+    },
14638
     "node_modules/react-native-gradle-plugin": {
14669
     "node_modules/react-native-gradle-plugin": {
14639
       "version": "0.70.3",
14670
       "version": "0.70.3",
14640
       "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz",
14671
       "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz",
21916
         "joi": "^17.2.1"
21947
         "joi": "^17.2.1"
21917
       }
21948
       }
21918
     },
21949
     },
21950
+    "@react-native-picker/picker": {
21951
+      "version": "2.4.8",
21952
+      "resolved": "https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.4.8.tgz",
21953
+      "integrity": "sha512-5NQ5XPo1B03YNqKFrV6h9L3CQaHlB80wd4ETHUEABRP2iLh7FHLVObX2GfziD+K/VJb8G4KZcZ23NFBFP1f7bg==",
21954
+      "requires": {}
21955
+    },
21919
     "@react-native/assets": {
21956
     "@react-native/assets": {
21920
       "version": "1.0.0",
21957
       "version": "1.0.0",
21921
       "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
21958
       "resolved": "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz",
30173
         "nullthrows": "^1.1.1"
30210
         "nullthrows": "^1.1.1"
30174
       }
30211
       }
30175
     },
30212
     },
30213
+    "react-native-dropdown-picker": {
30214
+      "version": "5.4.3",
30215
+      "resolved": "https://registry.npmjs.org/react-native-dropdown-picker/-/react-native-dropdown-picker-5.4.3.tgz",
30216
+      "integrity": "sha512-cwZzFcpyx/Stw3lZH2bvXxcsgwkR8c3rRZtOnlvyuN5pAplzA/9AiAxYlnJuspP9VvyU1XMePKOpgcHce6iyhA==",
30217
+      "requires": {}
30218
+    },
30219
+    "react-native-element-dropdown": {
30220
+      "version": "2.5.0",
30221
+      "resolved": "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.5.0.tgz",
30222
+      "integrity": "sha512-ZlatJ2X0/iR+rgZ9Mcp5KO9JvL9fAI/ZGnbdo07wY0CeqVMxAnAGyj2INEqtwkd81bEHVmWDlhpFgy0xhX6qNQ==",
30223
+      "requires": {}
30224
+    },
30176
     "react-native-gradle-plugin": {
30225
     "react-native-gradle-plugin": {
30177
       "version": "0.70.3",
30226
       "version": "0.70.3",
30178
       "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz",
30227
       "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz",

+ 3
- 0
package.json View File

10
   },
10
   },
11
   "dependencies": {
11
   "dependencies": {
12
     "@expo/webpack-config": "^0.17.2",
12
     "@expo/webpack-config": "^0.17.2",
13
+    "@react-native-picker/picker": "^2.4.8",
13
     "expo": "^47.0.6",
14
     "expo": "^47.0.6",
14
     "expo-font": "~11.0.1",
15
     "expo-font": "~11.0.1",
15
     "expo-splash-screen": "~0.17.5",
16
     "expo-splash-screen": "~0.17.5",
17
     "react": "18.1.0",
18
     "react": "18.1.0",
18
     "react-dom": "18.1.0",
19
     "react-dom": "18.1.0",
19
     "react-native": "0.70.5",
20
     "react-native": "0.70.5",
21
+    "react-native-dropdown-picker": "^5.4.3",
22
+    "react-native-element-dropdown": "^2.5.0",
20
     "react-native-web": "~0.18.9"
23
     "react-native-web": "~0.18.9"
21
   },
24
   },
22
   "devDependencies": {
25
   "devDependencies": {

+ 18
- 3
yarn.lock View File

1783
     "prompts" "^2.4.0"
1783
     "prompts" "^2.4.0"
1784
     "semver" "^6.3.0"
1784
     "semver" "^6.3.0"
1785
 
1785
 
1786
+"@react-native-picker/picker@^2.4.8":
1787
+  "integrity" "sha512-5NQ5XPo1B03YNqKFrV6h9L3CQaHlB80wd4ETHUEABRP2iLh7FHLVObX2GfziD+K/VJb8G4KZcZ23NFBFP1f7bg=="
1788
+  "resolved" "https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.4.8.tgz"
1789
+  "version" "2.4.8"
1790
+
1786
 "@react-native/assets@1.0.0":
1791
 "@react-native/assets@1.0.0":
1787
   "integrity" "sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ=="
1792
   "integrity" "sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ=="
1788
   "resolved" "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz"
1793
   "resolved" "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz"
6481
   "resolved" "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz"
6486
   "resolved" "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz"
6482
   "version" "4.5.0"
6487
   "version" "4.5.0"
6483
 
6488
 
6484
-"lodash@^4.17.11", "lodash@^4.17.13", "lodash@^4.17.14", "lodash@^4.17.15", "lodash@^4.17.20", "lodash@^4.17.21", "lodash@^4.17.4", "lodash@^4.17.5", "lodash@>=3.5 <5":
6489
+"lodash@*", "lodash@^4.17.11", "lodash@^4.17.13", "lodash@^4.17.14", "lodash@^4.17.15", "lodash@^4.17.20", "lodash@^4.17.21", "lodash@^4.17.4", "lodash@^4.17.5", "lodash@>=3.5 <5":
6485
   "integrity" "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
6490
   "integrity" "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
6486
   "resolved" "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
6491
   "resolved" "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
6487
   "version" "4.17.21"
6492
   "version" "4.17.21"
8560
     "jscodeshift" "^0.13.1"
8565
     "jscodeshift" "^0.13.1"
8561
     "nullthrows" "^1.1.1"
8566
     "nullthrows" "^1.1.1"
8562
 
8567
 
8568
+"react-native-dropdown-picker@^5.4.3":
8569
+  "integrity" "sha512-cwZzFcpyx/Stw3lZH2bvXxcsgwkR8c3rRZtOnlvyuN5pAplzA/9AiAxYlnJuspP9VvyU1XMePKOpgcHce6iyhA=="
8570
+  "resolved" "https://registry.npmjs.org/react-native-dropdown-picker/-/react-native-dropdown-picker-5.4.3.tgz"
8571
+  "version" "5.4.3"
8572
+
8573
+"react-native-element-dropdown@^2.5.0":
8574
+  "integrity" "sha512-ZlatJ2X0/iR+rgZ9Mcp5KO9JvL9fAI/ZGnbdo07wY0CeqVMxAnAGyj2INEqtwkd81bEHVmWDlhpFgy0xhX6qNQ=="
8575
+  "resolved" "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.5.0.tgz"
8576
+  "version" "2.5.0"
8577
+
8563
 "react-native-gradle-plugin@^0.70.3":
8578
 "react-native-gradle-plugin@^0.70.3":
8564
   "integrity" "sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A=="
8579
   "integrity" "sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A=="
8565
   "resolved" "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz"
8580
   "resolved" "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz"
8578
     "postcss-value-parser" "^4.2.0"
8593
     "postcss-value-parser" "^4.2.0"
8579
     "styleq" "^0.1.2"
8594
     "styleq" "^0.1.2"
8580
 
8595
 
8581
-"react-native@0.70.5":
8596
+"react-native@*", "react-native@>=0.57", "react-native@0.70.5":
8582
   "integrity" "sha512-5NZM80LC3L+TIgQX/09yiyy48S73wMgpIgN5cCv3XTMR394+KpDI3rBZGH4aIgWWuwijz31YYVF5504+9n2Zfw=="
8597
   "integrity" "sha512-5NZM80LC3L+TIgQX/09yiyy48S73wMgpIgN5cCv3XTMR394+KpDI3rBZGH4aIgWWuwijz31YYVF5504+9n2Zfw=="
8583
   "resolved" "https://registry.npmjs.org/react-native/-/react-native-0.70.5.tgz"
8598
   "resolved" "https://registry.npmjs.org/react-native/-/react-native-0.70.5.tgz"
8584
   "version" "0.70.5"
8599
   "version" "0.70.5"
8629
     "object-assign" "^4.1.1"
8644
     "object-assign" "^4.1.1"
8630
     "react-is" "^16.12.0 || ^17.0.0 || ^18.0.0"
8645
     "react-is" "^16.12.0 || ^17.0.0 || ^18.0.0"
8631
 
8646
 
8632
-"react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18.0.0", "react@^18.1.0", "react@18.1.0":
8647
+"react@*", "react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18.0.0", "react@^18.1.0", "react@>=16", "react@18.1.0":
8633
   "integrity" "sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ=="
8648
   "integrity" "sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ=="
8634
   "resolved" "https://registry.npmjs.org/react/-/react-18.1.0.tgz"
8649
   "resolved" "https://registry.npmjs.org/react/-/react-18.1.0.tgz"
8635
   "version" "18.1.0"
8650
   "version" "18.1.0"