refactorización de pantallas
This commit is contained in:
@@ -25,12 +25,6 @@ class _PantallaVotacionState extends State<PantallaVotacion> {
|
||||
final activos = partida.jugadoresActivos;
|
||||
final todosVotaron = estado.todosHanVotado();
|
||||
|
||||
// Modo un solo móvil
|
||||
if (!partida.config.modoMultimovil) {
|
||||
return _construirVotacionUnMovil(context, estado, partida, activos, todosVotaron);
|
||||
}
|
||||
|
||||
// Modo multimóvil sería similar pero controlado por Nearby
|
||||
return _construirVotacionUnMovil(context, estado, partida, activos, todosVotaron);
|
||||
}
|
||||
|
||||
@@ -41,10 +35,7 @@ class _PantallaVotacionState extends State<PantallaVotacion> {
|
||||
List activos,
|
||||
bool todosVotaron,
|
||||
) {
|
||||
// Encontrar el siguiente votante que no haya votado
|
||||
final sinVotar = activos
|
||||
.where((j) => !estado.votos.containsKey(j.id))
|
||||
.toList();
|
||||
final sinVotar = activos.where((j) => !estado.votos.containsKey(j.id)).toList();
|
||||
|
||||
if (todosVotaron) {
|
||||
return _construirTodosVotaron(context, estado);
|
||||
@@ -61,119 +52,65 @@ class _PantallaVotacionState extends State<PantallaVotacion> {
|
||||
),
|
||||
body: FondoFarolero(
|
||||
intenso: true,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
const ArteGameplayFarolero.fase(height: 108),
|
||||
const SizedBox(height: 10),
|
||||
// Progreso de votos
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: TemaApp.decoracionPanel(
|
||||
color: TemaApp.colorTarjeta.withValues(alpha: 0.90),
|
||||
borderColor: TemaApp.colorNaranja.withValues(alpha: 0.38),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
l10n.turnToVote,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
votanteActual.nombre,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
color: TemaApp.colorNaranja,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.votesProgress(estado.votos.length, activos.length),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ClipRRect(
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
const ArteGameplayFarolero.fase(height: 108),
|
||||
const SizedBox(height: 10),
|
||||
TarjetaFaseFarolero(
|
||||
icono: Icons.how_to_vote,
|
||||
titulo: l10n.voteOf(votanteActual.nombre),
|
||||
subtitulo: l10n.votesProgress(estado.votos.length, activos.length),
|
||||
color: TemaApp.colorAcento,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: LinearProgressIndicator(
|
||||
value: estado.votos.length / activos.length,
|
||||
backgroundColor: TemaApp.colorSuperficie,
|
||||
valueColor: const AlwaysStoppedAnimation(TemaApp.colorAcento),
|
||||
minHeight: 6,
|
||||
minHeight: 7,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
EncabezadoFarolero(
|
||||
icono: Icons.how_to_vote,
|
||||
titulo: l10n.whoIsImpostor,
|
||||
subtitulo: l10n.selectOnePlayer,
|
||||
color: TemaApp.colorAcento,
|
||||
trailing: Image.asset(
|
||||
'assets/ui/generated/meta/result_verdict_art.webp',
|
||||
width: 42,
|
||||
height: 42,
|
||||
opacity: const AlwaysStoppedAnimation(0.64),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Lista de candidatos
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: puedenRecibir.length,
|
||||
itemBuilder: (context, index) {
|
||||
final candidato = puedenRecibir[index];
|
||||
final seleccionado = _seleccionado == candidato.id;
|
||||
return Card(
|
||||
color: seleccionado
|
||||
? TemaApp.colorAcento.withValues(alpha: 0.3)
|
||||
: TemaApp.colorTarjeta,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: seleccionado
|
||||
? TemaApp.colorAcento
|
||||
: TemaApp.colorSuperficie,
|
||||
child: Text('${index + 1}',
|
||||
style: const TextStyle(color: Colors.white)),
|
||||
),
|
||||
title: Text(candidato.nombre),
|
||||
trailing: seleccionado
|
||||
? const Icon(Icons.check_circle,
|
||||
color: TemaApp.colorAcento)
|
||||
: const Icon(Icons.radio_button_unchecked),
|
||||
onTap: () {
|
||||
setState(() => _seleccionado = candidato.id);
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: TarjetaFaseFarolero(
|
||||
icono: Icons.person_search,
|
||||
titulo: l10n.whoIsImpostor,
|
||||
subtitulo: l10n.selectOnePlayer,
|
||||
color: TemaApp.colorNaranja,
|
||||
child: Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: puedenRecibir.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
final candidato = puedenRecibir[index];
|
||||
final seleccionado = _seleccionado == candidato.id;
|
||||
return SelectorVotoFarolero(
|
||||
nombre: '${index + 1}. ${candidato.nombre}',
|
||||
seleccionado: seleccionado,
|
||||
onTap: () => setState(() => _seleccionado = candidato.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BotonFarolero(
|
||||
texto: l10n.confirmVote,
|
||||
icono: Icons.how_to_vote,
|
||||
onPressed: _seleccionado != null
|
||||
? () {
|
||||
estado.registrarVoto(votanteActual.id, _seleccionado!);
|
||||
setState(() => _seleccionado = null);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _seleccionado != null
|
||||
? () {
|
||||
estado.registrarVoto(
|
||||
votanteActual.id, _seleccionado!);
|
||||
setState(() {
|
||||
_seleccionado = null;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: const Icon(Icons.how_to_vote),
|
||||
label: Text(l10n.confirmVote),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -190,45 +127,40 @@ class _PantallaVotacionState extends State<PantallaVotacion> {
|
||||
),
|
||||
body: FondoFarolero(
|
||||
intenso: true,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const ArteGameplayFarolero.fase(height: 132),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.allVoted,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
l10n.tapToReveal,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton.icon(
|
||||
child: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const ArteGameplayFarolero.fase(height: 132),
|
||||
const SizedBox(height: 24),
|
||||
TarjetaFaseFarolero(
|
||||
icono: Icons.check_circle,
|
||||
titulo: l10n.allVoted,
|
||||
subtitulo: l10n.tapToReveal,
|
||||
color: TemaApp.colorVerde,
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
BotonFarolero(
|
||||
texto: l10n.revealResult,
|
||||
icono: Icons.visibility,
|
||||
onPressed: () {
|
||||
final resultado = estado.procesarVotacion();
|
||||
if (resultado != null) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
PantallaResultado(resultado: resultado),
|
||||
builder: (_) => PantallaResultado(resultado: resultado),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.visibility),
|
||||
label: Text(l10n.revealResult),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user