Explorar el Código

Merge branch 'MocionesIUPI' of https://git.ccom.uprrp.edu/CCOM4030/JeLuOrRi into MocionesIUPI

Ricardo-gonzalez32 hace 2 años
padre
commit
33ab23f85e
Se han modificado 2 ficheros con 56 adiciones y 3 borrados
  1. 29
    3
      MocionesIUPI/screens/HomeScreen.js
  2. 27
    0
      MocionesIUPI/shared/card.js

+ 29
- 3
MocionesIUPI/screens/HomeScreen.js Ver fichero

@@ -1,13 +1,39 @@
1 1
 import { propertiesListToString } from "@expo/config-plugins/build/android/Properties";
2
-import React from "react";
2
+import React, { useEffect, useState }from "react";
3 3
 import { StyleSheet, View, Text, Button } from 'react-native';
4 4
 import { globalStyles } from "../styles/global";
5 5
 
6
-export default function HomeScreen({ navigation }) {
7
-    
6
+export default App = ({ navigation }) => {
7
+    const [isLoading, setLoading] = useState(true);
8
+    const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
9
+    const [Mocion, setMocion] = useState([]); // this is looking for 'Mocion' and it's content
10
+    const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
11
+  
12
+    // this connects us to the API and fetches the json file with the mociones
13
+    const getMociones = async () => {
14
+       try {
15
+        const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
16
+        const json = await response.json();
17
+  
18
+        // setting the content of each category 
19
+        setMocion(json.Mocion); 
20
+        setDescription(json.Description);
21
+        setPIN(json.PIN);
22
+  
23
+      } catch (error) {
24
+        console.error(error);
25
+      } finally {
26
+        setLoading(false); // once found the loading icon will be replaced with the content of the json
27
+      }
28
+    }
29
+
8 30
     const pressHandler = () => {
9 31
         navigation.navigate('Pinpage')
10 32
     }
33
+    
34
+    useEffect(() => {
35
+        getMociones();
36
+      }, []);
11 37
 
12 38
     return (
13 39
         <View style = {globalStyles.container}>

+ 27
- 0
MocionesIUPI/shared/card.js Ver fichero

@@ -0,0 +1,27 @@
1
+import React from "react";
2
+import { StyleSheet, View } from "react-native";
3
+
4
+export default function Card(props){
5
+    return (
6
+        <View style = {styles.card}>
7
+            <View style = {styles.cardContent}>
8
+                { props.childern }
9
+            </View>
10
+        </View>
11
+    )
12
+}
13
+
14
+const styles  = StyleSheet.create({
15
+  card: {
16
+    borderRadius: 6,
17
+    elevation: 3,
18
+    backgroundColor: '#fff', 
19
+    shadowOffset: { width: 1, height: 1},
20
+    shadowColor: '#333',
21
+    shadowOpacity: 0.3,
22
+  },
23
+
24
+  cardContent: {
25
+
26
+  },
27
+});