Renombrado de 'El Impostor' a 'Farolero'. Package: es.freetimelab.farolero 18 idiomas: es, en, fr, pt, de, it, ru, ja, ko, zh, zh_TW, ar, hi, tr, pl, nl, ca, eu Bancos de palabras: es (1000), en (1000), fr (1000) Pantalla de ajustes con selector de idioma 13138 líneas Dart, 0 issues
259 lines
8.8 KiB
Dart
259 lines
8.8 KiB
Dart
import 'package:flutter/material.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/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 Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(l10n.result),
|
|
automaticallyImplyLeading: false,
|
|
),
|
|
body: Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(32),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// Animación de suspense
|
|
if (!_revelado) ...[
|
|
const Text('🥁', style: TextStyle(fontSize: 64)),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
l10n.revealing,
|
|
style: Theme.of(context).textTheme.headlineMedium,
|
|
),
|
|
const SizedBox(height: 24),
|
|
const CircularProgressIndicator(color: TemaApp.colorAcento),
|
|
],
|
|
|
|
if (_revelado) ...[
|
|
// Resultado revelado
|
|
FadeTransition(
|
|
opacity: _animOpacidad,
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
widget.resultado.eraImpostor ? '🎭' : '😇',
|
|
style: const TextStyle(fontSize: 72),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
widget.resultado.eliminadoNombre,
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.headlineLarge
|
|
?.copyWith(fontSize: 32),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 24, vertical: 12),
|
|
decoration: BoxDecoration(
|
|
color: widget.resultado.eraImpostor
|
|
? TemaApp.colorVerde.withValues(alpha: 0.3)
|
|
: TemaApp.colorAcento.withValues(alpha: 0.3),
|
|
borderRadius: BorderRadius.circular(30),
|
|
border: Border.all(
|
|
color: widget.resultado.eraImpostor
|
|
? TemaApp.colorVerde
|
|
: TemaApp.colorAcento,
|
|
),
|
|
),
|
|
child: Text(
|
|
widget.resultado.eraImpostor
|
|
? l10n.wasImpostor
|
|
: l10n.wasInnocent,
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: widget.resultado.eraImpostor
|
|
? TemaApp.colorVerde
|
|
: TemaApp.colorAcento,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// Detalle de votos
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(l10n.votesThisRound,
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.titleMedium),
|
|
const SizedBox(height: 8),
|
|
...widget.resultado.votos.entries.map((e) {
|
|
final votante = partida?.jugadores
|
|
.firstWhere((j) => j.id == e.key);
|
|
final votado = partida?.jugadores
|
|
.firstWhere((j) => j.id == e.value);
|
|
return Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(vertical: 2),
|
|
child: Text(
|
|
'${votante?.nombre ?? '?'} → ${votado?.nombre ?? '?'}',
|
|
style: TextStyle(
|
|
color: e.value ==
|
|
widget.resultado.eliminadoId
|
|
? TemaApp.colorAcento
|
|
: TemaApp.colorTextoSecundario,
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// 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();
|
|
|
|
// Comprobar si la partida terminó
|
|
final finPartida = estado.comprobarFinPartida();
|
|
|
|
if (finPartida) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: ElevatedButton.icon(
|
|
onPressed: () {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (_) => const PantallaFinPartida()),
|
|
);
|
|
},
|
|
icon: const Icon(Icons.emoji_events),
|
|
label: Text(l10n.seeEndResult),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Si era impostor, puede intentar adivinar
|
|
if (widget.resultado.eraImpostor) {
|
|
return Column(
|
|
children: [
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const PantallaAdivinanza(),
|
|
),
|
|
);
|
|
},
|
|
icon: const Text('🎯', style: TextStyle(fontSize: 18)),
|
|
label: Text(l10n.impostorGuessWord),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: ElevatedButton.icon(
|
|
onPressed: () => _siguienteRonda(context, estado),
|
|
icon: const Icon(Icons.skip_next),
|
|
label: Text(l10n.nextRound),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: ElevatedButton.icon(
|
|
onPressed: () => _siguienteRonda(context, estado),
|
|
icon: const Icon(Icons.skip_next),
|
|
label: Text(l10n.nextRound),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _siguienteRonda(BuildContext context, EstadoJuego estado) {
|
|
estado.siguienteRonda();
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (_) => const PantallaDebate()),
|
|
);
|
|
}
|
|
}
|