El Impostor v0.1 — app Flutter completa
Juego de deducción social para 3-20 jugadores. Modo un solo móvil completamente funcional. 1000 palabras en 10 categorías. Notas privadas, votación, adivinanza, revancha. Material 3 dark theme. Package: es.freetimelab.elimpostor
This commit is contained in:
255
lib/pantallas/pantalla_resultado.dart
Normal file
255
lib/pantallas/pantalla_resultado.dart
Normal file
@@ -0,0 +1,255 @@
|
||||
import 'package:flutter/material.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 estado = context.read<EstadoJuego>();
|
||||
final partida = estado.partida;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Resultado'),
|
||||
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(
|
||||
'Revelando...',
|
||||
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
|
||||
? '¡Era IMPOSTOR! 🎉'
|
||||
: 'Era INOCENTE 😱',
|
||||
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('Votos de esta ronda',
|
||||
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 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: const Text('Ver resultado final'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 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: const Text('¿El impostor adivina la palabra?'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () => _siguienteRonda(context, estado),
|
||||
icon: const Icon(Icons.skip_next),
|
||||
label: const Text('Siguiente ronda'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () => _siguienteRonda(context, estado),
|
||||
icon: const Icon(Icons.skip_next),
|
||||
label: const Text('Siguiente ronda'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _siguienteRonda(BuildContext context, EstadoJuego estado) {
|
||||
estado.siguienteRonda();
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const PantallaDebate()),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user