4 Коміти

Автор SHA1 Повідомлення Дата
  Orlando04 dda1f8df97 Merge branch 'API-Connection' into MocionesIUPI 2 роки тому
  Orlando04 c51876b8fa Create MocionScreen.js 2 роки тому
  Orlando04 924947454b working json 2 роки тому
  Orlando04 9a642d5d6c trying to connect to API 2 роки тому

+ 2
- 1
MocionesIUPI/App.js Переглянути файл

@@ -5,7 +5,8 @@ import { StyleSheet, Text, View } from 'react-native';
5 5
 import Navigator from './routes/homeStack';
6 6
 
7 7
 
8
-export default function App() {
8
+  // here we want to display each mocion in a flatlist 
9
+  // it's supposed to be like buttons. Once clicked it would let you vote inside
9 10
   return (
10 11
       <Navigator />
11 12
   );

+ 1294
- 281
MocionesIUPI/package-lock.json
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 9
- 3
MocionesIUPI/package.json Переглянути файл

@@ -9,14 +9,15 @@
9 9
     "web": "expo start --web"
10 10
   },
11 11
   "dependencies": {
12
+    "@apollo/client": "^3.7.2",
12 13
     "@expo/webpack-config": "^0.17.2",
13
-    "@react-native-community/hooks": "^2.8.1",
14
-    "@react-navigation/material-bottom-tabs": "^6.2.8",
15
-    "@react-navigation/native-stack": "^6.9.4",
16 14
     "expo": "~47.0.6",
17 15
     "expo-status-bar": "~1.4.2",
16
+    "graphql": "^15.8.0",
17
+    "native-base": "^3.4.25",
18 18
     "react": "18.1.0",
19 19
     "react-dom": "18.1.0",
20
+    "react-dom": "18.1.0",
20 21
     "react-native": "0.70.5",
21 22
     "react-native-paper": "^3.12.0",
22 23
     "react-native-safe-area-context": "4.4.1",
@@ -26,6 +27,11 @@
26 27
     "react-navigation-material-bottom-tabs": "^2.3.5",
27 28
     "react-navigation-stack": "^2.10.4",
28 29
     "yarn": "^1.22.19"
30
+    "react-native-web": "~0.18.9",
31
+    "styled-components": "^5.3.6",
32
+    "styled-system": "^5.1.5",
33
+    "react-native-svg": "13.4.0",
34
+    "react-native-safe-area-context": "4.4.1"
29 35
   },
30 36
   "devDependencies": {
31 37
     "@babel/core": "^7.12.9"

+ 41
- 0
MocionesIUPI/screens/MocionScreen.js Переглянути файл

@@ -0,0 +1,41 @@
1
+import React, { useEffect, useState } from 'react';
2
+import { ActivityIndicator, FlatList, Text, View } from 'react-native';
3
+
4
+export default App = () => {
5
+  const [isLoading, setLoading] = useState(true);
6
+  const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
7
+  const [Mocion, setMocion] = useState([]); // this is looking for 'Mocion' and it's content
8
+  const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
9
+
10
+  // this connects us to the API and fetches the json file with the mociones
11
+  const getMociones = async () => {
12
+     try {
13
+      const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
14
+      const json = await response.json();
15
+
16
+      // setting the content of each category 
17
+      setMocion(json.Mocion); 
18
+      setDescription(json.Description);
19
+      setPIN(json.PIN);
20
+
21
+    } catch (error) {
22
+      console.error(error);
23
+    } finally {
24
+      setLoading(false); // once found the loading icon will be replaced with the content of the json
25
+    }
26
+  }
27
+
28
+  useEffect(() => {
29
+    getMociones();
30
+  }, []);
31
+
32
+  // here we want to display each mocion in a flatlist 
33
+  // it's supposed to be like buttons. Once clicked it would let you vote inside
34
+  return (
35
+    <View style={{ flex: 1, padding: 24 }}>
36
+      <Text>{Mocion}</Text>
37
+      <Text>{Description}</Text>
38
+      <Text>{PIN}</Text>
39
+    </View>
40
+  );
41
+};