Files
farolero/lib/pantallas/pantalla_resultado.dart
T
FreeTLab 56f07364c2
Build & Deploy Farolero / Análisis de código (push) Successful in 13s
Build & Deploy Farolero / Build APK + AAB release (push) Successful in 1m22s
feat: confirm before leaving a game, and fix untranslated strings
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.
2026-07-25 23:59:57 +02:00

170 lines
4.9 KiB
Dart

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';
import '../modelos/partida.dart';
import '../tema/componentes_farolero.dart';
import '../tema/componentes_resultado_farolero.dart';
import '../tema/tema_app.dart';
import 'pantalla_adivinanza.dart';
import 'pantalla_debate.dart';
import 'pantalla_fin_partida.dart';
class PantallaResultado extends StatefulWidget {
final ResultadoVotacion resultado;
const PantallaResultado({super.key, required this.resultado});
@override
State<PantallaResultado> createState() => _PantallaResultadoState();
}
class _PantallaResultadoState extends State<PantallaResultado>
with SingleTickerProviderStateMixin {
bool _revelado = false;
late AnimationController _animController;
late Animation<double> _animOpacidad;
@override
void initState() {
super.initState();
_animController = AnimationController(
duration: const Duration(milliseconds: 2500),
vsync: this,
);
_animOpacidad = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: _animController,
curve: const Interval(0.6, 1.0, curve: Curves.easeIn),
),
);
// Iniciar animación de suspense
Future.delayed(const Duration(milliseconds: 500), () {
_animController.forward().then((_) {
setState(() => _revelado = true);
});
});
}
@override
void dispose() {
_animController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final estado = context.read<EstadoJuego>();
final partida = estado.partida;
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),
),
),
],
],
),
),
),
),
),
);
}
Widget _construirBotones(BuildContext context, EstadoJuego estado) {
final l10n = AppLocalizations.of(context)!;
final partida = estado.partida;
if (partida == null) return const SizedBox.shrink();
final finPartida = estado.comprobarFinPartida();
if (finPartida) {
return BotonFarolero(
texto: l10n.seeEndResult,
icono: Icons.emoji_events,
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const PantallaFinPartida()),
);
},
);
}
if (widget.resultado.eraImpostor) {
return Column(
children: [
BotonFarolero.oscuro(
texto: l10n.impostorGuessWord,
icono: Icons.gps_fixed,
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const PantallaAdivinanza(),
),
);
},
),
const SizedBox(height: 12),
BotonFarolero(
texto: l10n.nextRound,
icono: Icons.skip_next,
onPressed: () => _siguienteRonda(context, estado),
),
],
);
}
return BotonFarolero(
texto: l10n.nextRound,
icono: Icons.skip_next,
onPressed: () => _siguienteRonda(context, estado),
);
}
void _siguienteRonda(BuildContext context, EstadoJuego estado) {
estado.siguienteRonda();
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const PantallaDebate()),
);
}
}