|
@@ -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}>
|