Commit 0cf6747e by Bianca Camargo Machado

Merge branch 'visualizarAndamento' into 'dev-sprint4'

Mostrando texto da alternativa

See merge request !49
2 parents 32adb93c 49a02f8d
{
"devToolsPort": 19002,
"expoServerPort": 19000,
"packagerPort": 19001,
"packagerPid": 9125,
"expoServerNgrokUrl": "https://cb-8vg.evote.rn-evote.exp.direct",
"packagerNgrokUrl": "https://packager.cb-8vg.evote.rn-evote.exp.direct",
"ngrokPid": 9179
"expoServerPort": null,
"packagerPort": null,
"packagerPid": null,
"expoServerNgrokUrl": null,
"packagerNgrokUrl": null,
"ngrokPid": null
}
\ No newline at end of file
import React, { Component } from 'react';
import { Text, View, FlatList, ScrollView, AsyncStorage } from 'react-native';
import { Text, View, FlatList, ScrollView, AsyncStorage, TouchableOpacity } from 'react-native';
import QuestaoCard from '../components/QuestaoCard';
import styles from '../styles/estilos';
import andamento from '../styles/andamento';
......@@ -66,20 +66,31 @@ export default class Andamento extends Component {
}
renderItem = ({ item, index }) => {
const { qtdVotantes } = this.state;
const { qtdVotantes, mostrarTitulo, indexMostrar, questaoMostrar } = this.state;
const alfabeto = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'];
const totalDeVotos = this.getQtdVotos(index);
return (
<View>
<QuestaoCard key={item.pergunta} text={`Q${index+1}. ${item.pergunta}`}/>
{
item.alternativas.map((alternativa, index) => {
item.alternativas.map((alternativa, indice) => {
let voto = this.confereVoto(alternativa);
return (
<View key={index + 1 } style={andamento.alternativas}>
<IndiceAlternativa destaque={voto} indice={`${alfabeto[index]})`} />
<BarraProgresso progresso={Number(((alternativa[1]/totalDeVotos)*100).toFixed(1)) || 0} />
<Text>{Number(((alternativa[1]/totalDeVotos)*100).toFixed(5)) || 0}%</Text>
<View>
<TouchableOpacity
key={indice + 1 + index}
style={andamento.alternativas}
onPress={() => this.setState({ mostrarTitulo: alternativa[0], indexMostrar: indice, questaoMostrar: index})}
>
<IndiceAlternativa destaque={voto} indice={`${alfabeto[indice]})`} />
<BarraProgresso progresso={Number(((alternativa[1]/totalDeVotos)*100).toFixed(1)) || 0} />
<Text>{Number(((alternativa[1]/totalDeVotos)*100).toFixed(5)) || 0}%</Text>
</TouchableOpacity>
{(indexMostrar == indice && questaoMostrar == index) ?
<View key={indice + 2 + index}>
<Text><Text style={{ color: "#8400C5" }}>Alternativa:</Text> {mostrarTitulo}</Text>
</View>:
null}
</View>
);
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!