feat: confirm before leaving a game, and fix untranslated strings
Build & Deploy Farolero / Análisis de código (push) Successful in 13s
Build & Deploy Farolero / Build APK + AAB release (push) Successful in 1m22s

Exit confirmation
- A dialog in the app's own style now guards every in-game screen. The safe
  action is the prominent one, so a stray tap keeps you in the game.
- Eleven screens covered, against both the system back gesture and the close
  buttons. The message adapts: a single-device game is lost, a host ends it
  for everyone, a client can rejoin.
- The two screens the host also opens from the manager take a flag so that
  back there just closes them instead of offering to quit.

Translations
- 21 keys were still holding the English text in Arabic, Basque, Hindi,
  Japanese, Korean, Dutch, Polish, Russian, Turkish and both Chinese
  variants: 231 strings, covering the whole multi-device flow, permissions
  and the mode picker. Nothing failed, the app just showed English.
- The permissions dialog was hardcoded in Spanish; it is localized now.
- Portuguese used Spanish gerunds where pt-PT takes "a + infinitive".

Checked what looked untranslated but is not: Animals and Notes are correct
Catalan, Configuration and Vibration correct French, Version correct German.
Those are whitelisted in the new test rather than silently rewritten.

l10n_cobertura_test guards all of it: no missing or orphan keys, no empty
values, no English left outside the whitelist, and placeholders preserved.
This commit is contained in:
2026-07-25 23:59:57 +02:00
parent d98ca66793
commit 56f07364c2
50 changed files with 2313 additions and 853 deletions
+29 -25
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:provider/provider.dart';
import '../estado/estado_juego.dart';
@@ -53,31 +54,34 @@ class _PantallaAdivinanzaState extends State<PantallaAdivinanza> {
final partida = estado.partida;
if (partida == null) return const SizedBox.shrink();
return Scaffold(
appBar: AppBar(
title: Text(l10n.impostorGuessTitle),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const ArteGameplayFarolero.fase(height: 132),
const SizedBox(height: 12),
TarjetaFaseFarolero(
icono: Icons.theater_comedy,
assetIconPath: 'assets/ui/generated/actions/action_impostor_mask.webp',
titulo: l10n.impostorCanGuess,
subtitulo: l10n.ifCorrectImpostorsWin,
color: TemaApp.colorAcento,
child: _buildContenido(context, l10n, estado, partida.palabraSecreta),
),
],
return GuardiaSalidaPartida(
contexto: ContextoSalida.unDispositivo,
child: Scaffold(
appBar: AppBar(
title: Text(l10n.impostorGuessTitle),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const ArteGameplayFarolero.fase(height: 132),
const SizedBox(height: 12),
TarjetaFaseFarolero(
icono: Icons.theater_comedy,
assetIconPath: 'assets/ui/generated/actions/action_impostor_mask.webp',
titulo: l10n.impostorCanGuess,
subtitulo: l10n.ifCorrectImpostorsWin,
color: TemaApp.colorAcento,
child: _buildContenido(context, l10n, estado, partida.palabraSecreta),
),
],
),
),
),
),
+76 -72
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import '../tema/dialogo_confirmacion.dart';
import 'package:flutter/material.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:provider/provider.dart';
@@ -67,85 +68,88 @@ class _PantallaDebateState extends State<PantallaDebate> {
final tieneTemporizador = partida.config.tiempoDebateSegundos != null;
return Scaffold(
appBar: AppBar(
title: Text(l10n.debateRound(partida.rondaActual)),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 110),
const SizedBox(height: 10),
if (tieneTemporizador) ...[
TemporizadorFarolero(
etiqueta: _tiempoAgotado ? l10n.timeUp : l10n.timeRemaining,
tiempo: _formatearTiempo(_segundosRestantes),
agotado: _tiempoAgotado,
),
const SizedBox(height: 16),
],
Expanded(
child: TarjetaFaseFarolero(
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
titulo: l10n.playersInDebate,
subtitulo: l10n.activePlayersInfo(
partida.jugadoresActivos.length,
partida.impostoresActivos.length,
return GuardiaSalidaPartida(
contexto: ContextoSalida.unDispositivo,
child: Scaffold(
appBar: AppBar(
title: Text(l10n.debateRound(partida.rondaActual)),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 110),
const SizedBox(height: 10),
if (tieneTemporizador) ...[
TemporizadorFarolero(
etiqueta: _tiempoAgotado ? l10n.timeUp : l10n.timeRemaining,
tiempo: _formatearTiempo(_segundosRestantes),
agotado: _tiempoAgotado,
),
child: Expanded(
child: ListView.separated(
itemCount: partida.jugadores.length,
separatorBuilder: (context, index) => const SizedBox(height: 8),
itemBuilder: (context, index) {
final jugador = partida.jugadores[index];
return EstadoJugadorFarolero(
nombre: '${index + 1}. ${jugador.nombre}',
subtitulo: jugador.eliminado ? l10n.eliminated : null,
icono: jugador.eliminado ? Icons.person_off : Icons.record_voice_over,
assetIconPath: jugador.eliminado ? null : 'assets/ui/generated/actions/action_players_group.webp',
destacado: !jugador.eliminado,
completado: !jugador.eliminado,
);
},
const SizedBox(height: 16),
],
Expanded(
child: TarjetaFaseFarolero(
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
titulo: l10n.playersInDebate,
subtitulo: l10n.activePlayersInfo(
partida.jugadoresActivos.length,
partida.impostoresActivos.length,
),
),
),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: BotonFarolero.oscuro(
texto: l10n.notes,
icono: Icons.edit_note,
assetIconPath: 'assets/ui/generated/actions/action_notes_quill.webp',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const PantallaNotas()),
child: Expanded(
child: ListView.separated(
itemCount: partida.jugadores.length,
separatorBuilder: (context, index) => const SizedBox(height: 8),
itemBuilder: (context, index) {
final jugador = partida.jugadores[index];
return EstadoJugadorFarolero(
nombre: '${index + 1}. ${jugador.nombre}',
subtitulo: jugador.eliminado ? l10n.eliminated : null,
icono: jugador.eliminado ? Icons.person_off : Icons.record_voice_over,
assetIconPath: jugador.eliminado ? null : 'assets/ui/generated/actions/action_players_group.webp',
destacado: !jugador.eliminado,
completado: !jugador.eliminado,
);
},
),
),
),
const SizedBox(width: 12),
Expanded(
flex: 2,
child: BotonFarolero(
texto: l10n.goToVoting,
icono: Icons.how_to_vote,
assetIconPath: 'assets/ui/generated/actions/action_vote_mask.webp',
onPressed: _irAVotacion,
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: BotonFarolero.oscuro(
texto: l10n.notes,
icono: Icons.edit_note,
assetIconPath: 'assets/ui/generated/actions/action_notes_quill.webp',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const PantallaNotas()),
);
},
),
),
),
],
),
],
const SizedBox(width: 12),
Expanded(
flex: 2,
child: BotonFarolero(
texto: l10n.goToVoting,
icono: Icons.how_to_vote,
assetIconPath: 'assets/ui/generated/actions/action_vote_mask.webp',
onPressed: _irAVotacion,
),
),
],
),
],
),
),
),
),
+103 -99
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import '../tema/dialogo_confirmacion.dart';
import 'package:flutter/material.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:farolero/modelos/inicio_partida_multijugador.dart';
@@ -117,110 +118,113 @@ class _PantallaDebateClienteState extends State<PantallaDebateCliente> {
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Scaffold(
backgroundColor: TemaApp.colorFondo,
appBar: AppBar(
title: Text(l10n.debate),
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
IconButton(
tooltip: l10n.seeYourWord,
icon: IconoFarolero(Icons.visibility),
onPressed: widget.jugadoresControlados.isEmpty
? null
: () => mostrarRevisionPalabraOnline(
context: context,
jugadoresControlados: widget.jugadoresControlados,
pistaImpostor: widget.pistaImpostor,
),
),
IconButton(
tooltip: l10n.notesTitle,
icon: IconoFarolero(Icons.edit_note),
onPressed: _puedeAbrirNotas
? () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => PantallaNotasOnline(
partidaId: widget.partidaId!,
jugadores: widget.jugadores,
autoresControlados: widget.jugadoresControlados,
),
return GuardiaSalidaPartida(
contexto: ContextoSalida.cliente,
child: Scaffold(
backgroundColor: TemaApp.colorFondo,
appBar: AppBar(
title: Text(l10n.debate),
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
IconButton(
tooltip: l10n.seeYourWord,
icon: IconoFarolero(Icons.visibility),
onPressed: widget.jugadoresControlados.isEmpty
? null
: () => mostrarRevisionPalabraOnline(
context: context,
jugadoresControlados: widget.jugadoresControlados,
pistaImpostor: widget.pistaImpostor,
),
)
: null,
),
],
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
top: false,
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 124),
const SizedBox(height: 12),
TarjetaFaseFarolero(
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
titulo: l10n.debate,
subtitulo: l10n.debateInstructions,
child: Column(
children: [
if (widget.tiempoDebateSegundos != null) ...[
TemporizadorFarolero(
etiqueta: _segundosRestantes == 0
? l10n.timeUp
: l10n.timeRemaining,
tiempo: _formatearTiempo(_segundosRestantes),
agotado: _segundosRestantes == 0,
),
const SizedBox(height: 16),
] else ...[
Text(
l10n.debatePhaseActive,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
],
if (widget.primerTurnoNombre != null) ...[
EstadoJugadorFarolero(
nombre: l10n.firstTurnInstruction(
widget.primerTurnoNombre!,
),
IconButton(
tooltip: l10n.notesTitle,
icon: IconoFarolero(Icons.edit_note),
onPressed: _puedeAbrirNotas
? () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => PantallaNotasOnline(
partidaId: widget.partidaId!,
jugadores: widget.jugadores,
autoresControlados: widget.jugadoresControlados,
),
destacado: true,
completado: true,
icono: Icons.record_voice_over,
assetIconPath: 'assets/ui/generated/actions/action_players_group.webp',
),
const SizedBox(height: 12),
)
: null,
),
],
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
top: false,
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 124),
const SizedBox(height: 12),
TarjetaFaseFarolero(
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
titulo: l10n.debate,
subtitulo: l10n.debateInstructions,
child: Column(
children: [
if (widget.tiempoDebateSegundos != null) ...[
TemporizadorFarolero(
etiqueta: _segundosRestantes == 0
? l10n.timeUp
: l10n.timeRemaining,
tiempo: _formatearTiempo(_segundosRestantes),
agotado: _segundosRestantes == 0,
),
const SizedBox(height: 16),
] else ...[
Text(
l10n.debatePhaseActive,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
],
if (widget.primerTurnoNombre != null) ...[
EstadoJugadorFarolero(
nombre: l10n.firstTurnInstruction(
widget.primerTurnoNombre!,
),
destacado: true,
completado: true,
icono: Icons.record_voice_over,
assetIconPath: 'assets/ui/generated/actions/action_players_group.webp',
),
const SizedBox(height: 12),
],
BotonFarolero.secundario(
texto: _votacionSolicitada
? l10n.votacionSolicitada
: l10n.solicitarVotacion,
icono: _votacionSolicitada
? Icons.hourglass_empty
: Icons.how_to_vote,
assetIconPath: _votacionSolicitada
? null
: 'assets/ui/generated/actions/action_vote_mask.webp',
onPressed: _votacionSolicitada
? null
: () {
setState(() => _votacionSolicitada = true);
widget.onSolicitarVotacion();
},
),
],
BotonFarolero.secundario(
texto: _votacionSolicitada
? l10n.votacionSolicitada
: l10n.solicitarVotacion,
icono: _votacionSolicitada
? Icons.hourglass_empty
: Icons.how_to_vote,
assetIconPath: _votacionSolicitada
? null
: 'assets/ui/generated/actions/action_vote_mask.webp',
onPressed: _votacionSolicitada
? null
: () {
setState(() => _votacionSolicitada = true);
widget.onSolicitarVotacion();
},
),
],
),
),
),
],
],
),
),
),
),
+14 -1
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import '../tema/dialogo_confirmacion.dart';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
@@ -257,7 +258,9 @@ class _PantallaGestorHostState extends State<PantallaGestorHost> {
clientesPendientes.every((id) => _clientesListos[id] == true);
final todosVotaron = estado.todosHanVotado();
return Scaffold(
return GuardiaSalidaPartida(
contexto: ContextoSalida.host,
child: Scaffold(
appBar: AppBar(
title: Text(l10n.hostGame),
automaticallyImplyLeading: false,
@@ -299,8 +302,15 @@ class _PantallaGestorHostState extends State<PantallaGestorHost> {
),
),
IconButton(
tooltip: l10n.leaveGame,
icon: IconoFarolero(Icons.close),
onPressed: () async {
if (!await confirmarSalirDePartida(
context,
ContextoSalida.host,
)) {
return;
}
await nearby.desconectar();
widget.onPartidaFin();
},
@@ -340,6 +350,7 @@ class _PantallaGestorHostState extends State<PantallaGestorHost> {
),
),
),
),
);
}
@@ -580,6 +591,7 @@ class _PantallaGestorHostState extends State<PantallaGestorHost> {
context,
MaterialPageRoute(
builder: (_) => PantallaPalabrasCliente(
protegerSalida: false,
jugadores: jugadoresHost,
pistaImpostor: partida.config.pistaImpostor
? partida.pistaImpostor
@@ -863,6 +875,7 @@ class _PantallaGestorHostState extends State<PantallaGestorHost> {
context,
MaterialPageRoute(
builder: (_) => PantallaVotacionCliente(
protegerSalida: false,
jugadores: partida.jugadoresActivos,
jugadoresControlados: jugadoresHost,
partidaId: context.read<ServicioNearby>().roomId,
+7
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
@@ -42,6 +43,12 @@ class _PantallaLobbyHostState extends State<PantallaLobbyHost> {
leading: IconButton(
icon: IconoFarolero(Icons.close),
onPressed: () async {
if (!await confirmarSalirDePartida(
context,
ContextoSalida.host,
)) {
return;
}
await nearby.desconectar();
if (context.mounted) Navigator.pop(context);
},
+11 -1
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:farolero/tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:farolero/modelos/inicio_partida_multijugador.dart';
import 'package:farolero/tema/componentes_farolero.dart';
@@ -10,11 +11,16 @@ class PantallaPalabrasCliente extends StatefulWidget {
final String? pistaImpostor;
final VoidCallback onTodosVistos;
/// El host abre esta pantalla desde el gestor: allí el atrás solo
/// debe cerrarla, no ofrecer abandonar la partida.
final bool protegerSalida;
const PantallaPalabrasCliente({
super.key,
required this.jugadores,
this.pistaImpostor,
required this.onTodosVistos,
this.protegerSalida = true,
});
@override
@@ -47,7 +53,10 @@ class _PantallaPalabrasClienteState extends State<PantallaPalabrasCliente> {
final l10n = AppLocalizations.of(context)!;
final actual = _actual;
return Scaffold(
return GuardiaSalidaPartida(
contexto: ContextoSalida.cliente,
activo: widget.protegerSalida,
child: Scaffold(
body: FondoFarolero(
intenso: true,
child: SafeArea(
@@ -147,6 +156,7 @@ class _PantallaPalabrasClienteState extends State<PantallaPalabrasCliente> {
),
),
),
),
);
}
}
+39 -35
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:provider/provider.dart';
import '../estado/estado_juego.dart';
@@ -59,43 +60,46 @@ class _PantallaResultadoState extends State<PantallaResultado>
final estado = context.read<EstadoJuego>();
final partida = estado.partida;
return Scaffold(
appBar: AppBar(
title: Text(l10n.result),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
respetarBarras: true,
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Animación de suspense
if (!_revelado) ...[
const ArteGameplayFarolero.resultado(height: 152),
const SizedBox(height: 16),
Text(
l10n.revealing,
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: 24),
const CircularProgressIndicator(color: TemaApp.colorAcento),
],
if (_revelado) ...[
FadeTransition(
opacity: _animOpacidad,
child: ResultadoRondaFarolero(
resultado: widget.resultado,
jugadores: partida?.jugadores ?? const [],
acciones: _construirBotones(context, estado),
return GuardiaSalidaPartida(
contexto: ContextoSalida.unDispositivo,
child: Scaffold(
appBar: AppBar(
title: Text(l10n.result),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
respetarBarras: true,
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Animación de suspense
if (!_revelado) ...[
const ArteGameplayFarolero.resultado(height: 152),
const SizedBox(height: 16),
Text(
l10n.revealing,
style: Theme.of(context).textTheme.headlineMedium,
),
),
const SizedBox(height: 24),
const CircularProgressIndicator(color: TemaApp.colorAcento),
],
if (_revelado) ...[
FadeTransition(
opacity: _animOpacidad,
child: ResultadoRondaFarolero(
resultado: widget.resultado,
jugadores: partida?.jugadores ?? const [],
acciones: _construirBotones(context, estado),
),
),
],
],
],
),
),
),
),
+28 -24
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import '../modelos/inicio_partida_multijugador.dart';
import '../modelos/snapshot_partida_online.dart';
@@ -158,30 +159,33 @@ class _PantallaResultadoOnlineState extends State<PantallaResultadoOnline> {
final l10n = AppLocalizations.of(context)!;
final resultado = _snapshot.resultadoActual;
return Scaffold(
backgroundColor: TemaApp.colorFondo,
appBar: AppBar(
title: Text(_snapshot.fase == 'adivinanza'
? l10n.impostorGuessTitle
: l10n.result),
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
elevation: 0,
actions: _acciones(context, l10n),
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
top: false,
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: resultado == null
? _buildEsperaAdivinanza(context, l10n)
: ResultadoRondaFarolero(
resultado: resultado,
jugadores: _snapshot.jugadores,
mensaje: _snapshot.mensaje,
),
return GuardiaSalidaPartida(
contexto: ContextoSalida.cliente,
child: Scaffold(
backgroundColor: TemaApp.colorFondo,
appBar: AppBar(
title: Text(_snapshot.fase == 'adivinanza'
? l10n.impostorGuessTitle
: l10n.result),
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
elevation: 0,
actions: _acciones(context, l10n),
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
top: false,
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: resultado == null
? _buildEsperaAdivinanza(context, l10n)
: ResultadoRondaFarolero(
resultado: resultado,
jugadores: _snapshot.jugadores,
mensaje: _snapshot.mensaje,
),
),
),
),
),
+61 -57
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:provider/provider.dart';
import '../estado/estado_juego.dart';
@@ -25,64 +26,67 @@ class _PantallaVerPalabraState extends State<PantallaVerPalabra> {
final todosHanVisto = partida.jugadores.every((j) => _hanVisto.contains(j.id));
return Scaffold(
appBar: AppBar(
title: Text(l10n.seeYourWord),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 110),
const SizedBox(height: 10),
TarjetaFaseFarolero(
icono: Icons.visibility,
assetIconPath: 'assets/ui/generated/actions/action_reveal_word.webp',
titulo: l10n.roundNumber(partida.rondaActual),
subtitulo: l10n.eachPlayerMustSee,
),
const SizedBox(height: 16),
Expanded(
child: ListView.separated(
itemCount: partida.jugadores.length,
separatorBuilder: (context, index) => const SizedBox(height: 10),
itemBuilder: (context, index) {
final jugador = partida.jugadores[index];
final haVisto = _hanVisto.contains(jugador.id);
return EstadoJugadorFarolero(
nombre: '${index + 1}. ${jugador.nombre}',
subtitulo: haVisto ? l10n.alreadySeen : l10n.tapToSee,
icono: haVisto ? Icons.check_circle : Icons.visibility,
assetIconPath: haVisto ? null : 'assets/ui/generated/actions/action_reveal_word.webp',
destacado: haVisto,
completado: haVisto,
onTap: haVisto ? null : () => _mostrarPalabra(context, jugador.id),
);
},
return GuardiaSalidaPartida(
contexto: ContextoSalida.unDispositivo,
child: Scaffold(
appBar: AppBar(
title: Text(l10n.seeYourWord),
automaticallyImplyLeading: false,
),
body: FondoFarolero(
intenso: true,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
const ArteGameplayFarolero.fase(height: 110),
const SizedBox(height: 10),
TarjetaFaseFarolero(
icono: Icons.visibility,
assetIconPath: 'assets/ui/generated/actions/action_reveal_word.webp',
titulo: l10n.roundNumber(partida.rondaActual),
subtitulo: l10n.eachPlayerMustSee,
),
),
const SizedBox(height: 16),
BotonFarolero(
texto: todosHanVisto
? l10n.allSeenStartDebate
: l10n.playersRemaining(partida.jugadores.length - _hanVisto.length),
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
onPressed: todosHanVisto
? () {
estado.iniciarDebate();
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const PantallaDebate()),
);
}
: null,
),
],
const SizedBox(height: 16),
Expanded(
child: ListView.separated(
itemCount: partida.jugadores.length,
separatorBuilder: (context, index) => const SizedBox(height: 10),
itemBuilder: (context, index) {
final jugador = partida.jugadores[index];
final haVisto = _hanVisto.contains(jugador.id);
return EstadoJugadorFarolero(
nombre: '${index + 1}. ${jugador.nombre}',
subtitulo: haVisto ? l10n.alreadySeen : l10n.tapToSee,
icono: haVisto ? Icons.check_circle : Icons.visibility,
assetIconPath: haVisto ? null : 'assets/ui/generated/actions/action_reveal_word.webp',
destacado: haVisto,
completado: haVisto,
onTap: haVisto ? null : () => _mostrarPalabra(context, jugador.id),
);
},
),
),
const SizedBox(height: 16),
BotonFarolero(
texto: todosHanVisto
? l10n.allSeenStartDebate
: l10n.playersRemaining(partida.jugadores.length - _hanVisto.length),
icono: Icons.forum,
assetIconPath: 'assets/ui/generated/actions/action_rules_book.webp',
onPressed: todosHanVisto
? () {
estado.iniciarDebate();
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const PantallaDebate()),
);
}
: null,
),
],
),
),
),
),
+7 -1
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:provider/provider.dart';
import '../estado/estado_juego.dart';
@@ -25,7 +26,12 @@ class _PantallaVotacionState extends State<PantallaVotacion> {
final activos = partida.jugadoresActivos;
final todosVotaron = estado.todosHanVotado();
return _construirVotacionUnMovil(context, estado, partida, activos, todosVotaron);
return GuardiaSalidaPartida(
contexto: ContextoSalida.unDispositivo,
child: _construirVotacionUnMovil(
context, estado, partida, activos, todosVotaron,
),
);
}
Widget _construirVotacionUnMovil(
+11 -1
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:farolero/tema/dialogo_confirmacion.dart';
import 'package:farolero/l10n/generated/app_localizations.dart';
import 'package:farolero/modelos/inicio_partida_multijugador.dart';
import 'package:farolero/modelos/jugador.dart';
@@ -17,6 +18,10 @@ class PantallaVotacionCliente extends StatefulWidget {
final String? pistaImpostor;
final Function(Map<String, String> votos) onVotos;
/// El host abre esta pantalla desde el gestor: allí el atrás solo
/// debe cerrarla, no ofrecer abandonar la partida.
final bool protegerSalida;
const PantallaVotacionCliente({
super.key,
required this.jugadores,
@@ -24,6 +29,7 @@ class PantallaVotacionCliente extends StatefulWidget {
this.partidaId,
this.pistaImpostor,
required this.onVotos,
this.protegerSalida = true,
});
@override
@@ -63,7 +69,10 @@ class _PantallaVotacionClienteState extends State<PantallaVotacionCliente> {
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Scaffold(
return GuardiaSalidaPartida(
contexto: ContextoSalida.cliente,
activo: widget.protegerSalida,
child: Scaffold(
backgroundColor: TemaApp.colorFondo,
appBar: AppBar(
title: Text(l10n.voting),
@@ -155,6 +164,7 @@ class _PantallaVotacionClienteState extends State<PantallaVotacionCliente> {
),
),
),
),
);
}