Переглянути джерело

fixed things with buttons

Orlando04 2 роки тому
джерело
коміт
ca38aa9371

+ 30
- 6
MocionesIUPI/screens/HomeScreen.js Переглянути файл

@@ -1,19 +1,43 @@
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 [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
8
+  
9
+    // this connects us to the API and fetches the json file with the mociones
10
+    const getMociones = async () => {
11
+       try {
12
+        const response = await fetch('http://192.168.1.200:5000/send?PIN=121071'); // connection to the website 
13
+        const json = await response.json();
14
+  
15
+        // setting the content of each category 
16
+        setPIN(json.PIN);
17
+  
18
+      } catch (error) {
19
+        console.error(error);
20
+      } finally {
21
+        setLoading(false); // once found the loading icon will be replaced with the content of the json
22
+      }
23
+    }
24
+
8 25
     const pressHandler = () => {
9
-        navigation.navigate('Mocion');
26
+        navigation.navigate('Pinpage', {Pin:PIN},) // with this we send parameters to other screens
10 27
     }
11 28
     
12
-    
29
+    useEffect(() => {
30
+        getMociones();
31
+      }, []);
32
+
13 33
     return (
14 34
         <View style = {globalStyles.container}>
15 35
             <Text style = {globalStyles.tittleText}>Home Screen</Text>
16
-            <Button title="go to pin page" onPress={pressHandler}/>
36
+            <Button title='Ir a pagina de pin' onPress={pressHandler} />
17 37
         </View>
38
+
39
+        
40
+        
41
+
18 42
     )
19 43
 }

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

@@ -1,5 +1,5 @@
1 1
 import React, { useEffect, useState } from 'react';
2
-import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
2
+import { ActivityIndicator, Button, FlatList, Text, TouchableOpacity, View } from 'react-native';
3 3
 import { globalStyles } from '../styles/global';
4 4
 
5 5
 export default App = () => {
@@ -9,10 +9,11 @@ export default App = () => {
9 9
   const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
10 10
   const [Votos, setVotos] = useState(0); // this is looking for 'Votos' and it's content
11 11
 
12
+
12 13
   // this connects us to the API and fetches the json file with the mociones
13 14
   const getMociones = async () => {
14 15
      try {
15
-      const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
16
+      const response = await fetch('http://192.168.1.200:5000/send?PIN=2'); // connection to the website 
16 17
       const json = await response.json();
17 18
 
18 19
       // setting the content of each category 
@@ -28,7 +29,10 @@ export default App = () => {
28 29
     }
29 30
   }
30 31
 
31
-  function getVotosNums() {
32
+  function sendVotos() {
33
+    
34
+  }
35
+  {/*function getVotoFavorNums() {
32 36
     const [countFavor, setCountFavor] = useState(0);
33 37
     const [countContra, setCountContra] = useState(0);
34 38
     const [countAbstenid, setCountAbstenid] = useState(0);
@@ -41,16 +45,31 @@ export default App = () => {
41 45
         <button onClick={() => setCountContra(countContra + 1)}>
42 46
           En contra
43 47
         </button>
48
+      </div>
49
+    );
50
+  }
51
+
52
+  function getVotoAbstenidNums() {
53
+    const [countAbstenid, setCountAbstenid] = useState(0);
54
+
55
+    return (
56
+      <div>
44 57
         <button onClick={() => setCountAbstenid(countAbstenid + 1)}>
45
-          Abstenido
58
+        Abstenida/o
46 59
         </button>
47 60
       </div>
48 61
     );
49 62
   }
50 63
 
64
+  function getVotoNums() {
65
+    getVotoFavorNums();
66
+    getVotoContraNums();
67
+    getVotoAbstenidNums();
68
+  }
69
+
51 70
   const getVotos = async () => {
52 71
     try {
53
-      const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
72
+      const response = await fetch('http://192.168.1.200:5000/send?PIN=121071'); // connection to the website 
54 73
       const json = await response.json();
55 74
 
56 75
       // Getting votes count
@@ -62,10 +81,10 @@ export default App = () => {
62 81
     } finally {
63 82
       setLoading(false); // once found the loading icon will be replaced with the content of the json
64 83
     }
65
-  }
84
+  } */}
66 85
   useEffect(() => {
67 86
     getMociones();
68
-    getVotos();
87
+    //getVotos();
69 88
   }, []);
70 89
 
71 90
   // this is for displaying the mocion, its description, and votes' options on the screen
@@ -73,18 +92,9 @@ export default App = () => {
73 92
     <View style={{ flex: 1, padding: 24 }}>
74 93
       <Text>{Mocion}</Text>
75 94
       <Text>{Description}</Text>
76
-      <Button>
77
-        title = "A favor"
78
-        onPress={() => Alert.alert('Voto a favor')}
79
-      </Button>
80
-      <Button>
81
-        title = "En contra"
82
-        onPress={() => Alert.alert('Voto en contra')}
83
-      </Button>
84
-      <Button>
85
-        title = "Abstenido"
86
-        onPress={() => Alert.alert('Se abstuvo al voto')}
87
-      </Button>
95
+      <Button title = "A favor "  color={'#e81b39'} />
96
+      <Button title = "En Contra" color={'#e81b39'} />
97
+      <Button title = "Abstenido" color={'#e81b39'} />
88 98
     </View>
89 99
   );
90 100
 };

+ 10
- 0
MocionesIUPI/styles/global.js Переглянути файл

@@ -14,6 +14,16 @@ export const globalStyles = StyleSheet.create({
14 14
   paragraph: {
15 15
     marginVertical: 8,
16 16
     lineHeight: 20,
17
+  },
18
+
19
+  button: {
20
+    alignItems: 'center',
21
+    justifyContent: 'center',
22
+    paddingVertical: 12,
23
+    paddingHorizontal: 32,
24
+    borderRadius: 4,
25
+    elevation: 3,
26
+    backgroundColor: '#e81b39',
17 27
   }
18 28
 });
19 29