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