Orlando04 преди 2 години
родител
ревизия
09365cd198
променени са 4 файла, в които са добавени 24 реда и са изтрити 7 реда
  1. 3
    0
      MocionesIUPI/routes/homeStack.js
  2. 0
    5
      MocionesIUPI/screens/HomeScreen.js
  3. 20
    1
      MocionesIUPI/screens/MocionScreen.js
  4. 1
    1
      MocionesIUPI/screens/PincodeScreen.js

+ 3
- 0
MocionesIUPI/routes/homeStack.js Целия файл

@@ -28,6 +28,9 @@ const screens = {
28 28
 
29 29
     Mocion: {
30 30
         screen: MocionScreen,
31
+        navigationOptions: {
32
+            headerTitle: () => <Header />
33
+        }
31 34
     },
32 35
 }
33 36
 

+ 0
- 5
MocionesIUPI/screens/HomeScreen.js Целия файл

@@ -4,9 +4,6 @@ import { StyleSheet, View, Text, Button } from 'react-native';
4 4
 import { globalStyles } from "../styles/global";
5 5
 
6 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 7
     const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
11 8
   
12 9
     // this connects us to the API and fetches the json file with the mociones
@@ -16,8 +13,6 @@ export default App = ({ navigation }) => {
16 13
         const json = await response.json();
17 14
   
18 15
         // setting the content of each category 
19
-        setMocion(json.Mocion); 
20
-        setDescription(json.Description);
21 16
         setPIN(json.PIN);
22 17
   
23 18
       } catch (error) {

+ 20
- 1
MocionesIUPI/screens/MocionScreen.js Целия файл

@@ -7,7 +7,26 @@ export default App = () => {
7 7
   const [isLoading, setLoading] = useState(true);
8 8
   const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
9 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
10
+  
11
+      // this connects us to the API and fetches the json file with the mociones
12
+      const getMociones = async () => {
13
+        try {
14
+         const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
15
+         const json = await response.json();
16
+   
17
+         // setting the content of each category 
18
+         setMocion(json.Mocion); 
19
+         setDescription(json.Description);
20
+       } catch (error) {
21
+         console.error(error);
22
+       } finally {
23
+         setLoading(false); // once found the loading icon will be replaced with the content of the json
24
+       }
25
+     }
26
+
27
+     useEffect(() => {
28
+      getMociones();
29
+    }, []);
11 30
 
12 31
 
13 32
   // this is for displaying the mocion on the screen

+ 1
- 1
MocionesIUPI/screens/PincodeScreen.js Целия файл

@@ -9,7 +9,7 @@ export default class App extends React.Component {
9 9
     
10 10
     pressHandler = () => {
11 11
     {/*Dentro del parentesis va el path al screen para redirigir*/}
12
-      this.props.navigation.navigate('test')
12
+      this.props.navigation.navigate('Mocion')
13 13
     }
14 14
 
15 15
     state = {