Browse Source

Check option change, numbers dont match up

andrea.nieves7 1 year ago
parent
commit
f43557f310
1 changed files with 78 additions and 12 deletions
  1. 78
    12
      App.js

+ 78
- 12
App.js View File

2
 import React, {useState, useEffect} from 'react';
2
 import React, {useState, useEffect} from 'react';
3
 import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable} from 'react-native';
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
-import { Dropdown } from 'react-native-element-dropdown';
5
+import DropDownPicker from 'react-native-dropdown-picker';
6
 
6
 
7
 //where data will be put
7
 //where data will be put
8
 var organizedData
8
 var organizedData
18
 	
18
 	
19
 }
19
 }
20
 
20
 
21
+//fix
22
+
23
+DropDownPicker.setListMode("SCROLLVIEW")
24
+
21
 //calls data query
25
 //calls data query
22
 function loadDoc(query) {
26
 function loadDoc(query) {
23
   var xhttp = new XMLHttpRequest();
27
   var xhttp = new XMLHttpRequest();
120
 			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72")
124
 			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72")
121
 			break;
125
 			break;
122
 		case 2:
126
 		case 2:
123
-			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP03PR)&for=county:127&in=state:72")
127
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP03)&for=county:127&in=state:72")
124
 			break;
128
 			break;
125
 		case 3:
129
 		case 3:
126
-			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP04PR)&for=county:127&in=state:72")
130
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP04)&for=county:127&in=state:72")
127
 			break;
131
 			break;
128
 		case 4:
132
 		case 4:
129
-			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP05PR)&for=county:127&in=state:72")
133
+			loadDoc("https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP05)&for=county:127&in=state:72")
130
 			break;
134
 			break;
131
 		
135
 		
132
 	}
136
 	}
133
 }
137
 }
134
 
138
 
135
 
139
 
136
-function DataDisplay({parentOption}) {
137
-  const [option, setOption] = useState(0);
140
+
141
+
142
+//data display
143
+
144
+function DataDisplay({option}) {
145
+  const [tableValue, setTableValue] = useState(0);
146
+
138
 
147
 
139
   useEffect(() => {
148
   useEffect(() => {
140
-    setOption(parentOption);
141
-	console.log(option)
142
-    updateInfo(option);
143
-  }, [parentOption]); // 👈️ add props as dependencies
149
+    setTableValue(option * 1);
150
+	console.log(tableValue)
151
+    updateInfo(tableValue);
152
+  }, [option]); // add props as dependencies
144
 
153
 
145
 
154
 
146
   return (
155
   return (
148
   );
157
   );
149
 }
158
 }
150
 
159
 
160
+//data pick
161
+/*
151
 function Parent() {
162
 function Parent() {
152
   const [parentOption, setParentOption] = useState(0);
163
   const [parentOption, setParentOption] = useState(0);
153
 
164
 
173
     </View>
184
     </View>
174
   );
185
   );
175
 }
186
 }
187
+*/
188
+
189
+
190
+//picker test
191
+
192
+function Picker() {
193
+	
194
+	//table to pick from
195
+  
196
+  
197
+  const [open, setOpen] = useState(false);
198
+  const [option, setOption] = useState(0);
199
+  const [value, setValue] = useState(0);
200
+  const [table, setTable] = useState([
201
+    {label:'DP02PR', value: 1},
202
+    {label:'DP03', value: 2},
203
+	{label:'DP04', value: 3},
204
+    {label:'DP05', value: 4},
205
+  ]);
206
+    
207
+  //cambiar pueblo
208
+  
209
+  /*
210
+  //pueblo
211
+  const [open2, setOpen2] = useState(false);
212
+  const [value2, setValue2] = useState(null);
213
+  const [pueblo, setPueblo] = useState([
214
+    {label: 'Apple', value: 'apple'},
215
+    {label: 'Banana', value: 'banana'}
216
+  ]);
217
+  */
218
+
219
+  return (
220
+  <View>
221
+    <DropDownPicker
222
+      open={open}
223
+      value={value}
224
+      items={table}
225
+      setOpen={setOpen}
226
+      setValue={setValue}
227
+      setItems={setTable}
228
+	  onChangeValue={(value) => {
229
+		setOption(current => value);
230
+		}}
231
+
232
+    />
233
+	
234
+	<DataDisplay option={option} />
235
+	
236
+	</View>
237
+  );
238
+}
176
 
239
 
177
 
240
 
241
+
242
+//actual application
243
+
178
 class App extends React.Component {
244
 class App extends React.Component {
179
 
245
 
180
 
246
 
213
 		
279
 		
214
 		dataOp:
280
 		dataOp:
215
 		<View style = {styles.containerbackground}>
281
 		<View style = {styles.containerbackground}>
216
-		<ScrollView style={styles.scrollView}>
282
+		<ScrollView nestedScrollEnabled = {true} style={styles.scrollView}>
217
 		 <View style = {styles.container}>
283
 		 <View style = {styles.container}>
218
 			
284
 			
219
 		  
285
 		  
220
 			<Text style={styles.intro}>DATA VIEWING PROJECT</Text>		
286
 			<Text style={styles.intro}>DATA VIEWING PROJECT</Text>		
221
 			
287
 			
222
-			<Parent />
288
+			<Picker />
223
 			
289
 			
224
 			<Image source={require('./testimg.gif')} />
290
 			<Image source={require('./testimg.gif')} />
225
 			
291