refactorización de pantallas
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:farolero/l10n/generated/app_localizations.dart';
|
||||
import 'package:farolero/modelos/inicio_partida_multijugador.dart';
|
||||
@@ -11,8 +11,6 @@ import 'package:farolero/tema/componentes_farolero.dart';
|
||||
import 'package:farolero/tema/tema_app.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// Pantalla que ve el jugador durante la fase de debate (multidispositivo).
|
||||
/// El cliente recibe el cambio de fase via Nearby y se navega aquí.
|
||||
class PantallaDebateCliente extends StatefulWidget {
|
||||
final int? tiempoDebateSegundos;
|
||||
final String? primerTurnoNombre;
|
||||
@@ -87,9 +85,7 @@ class _PantallaDebateClienteState extends State<PantallaDebateCliente> {
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
final listener = _listener;
|
||||
if (listener != null) {
|
||||
_nearby?.removeMensajeListener(listener);
|
||||
}
|
||||
if (listener != null) _nearby?.removeMensajeListener(listener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -160,138 +156,67 @@ class _PantallaDebateClienteState extends State<PantallaDebateCliente> {
|
||||
),
|
||||
body: FondoFarolero(
|
||||
intenso: true,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
children: [
|
||||
const ArteGameplayFarolero.fase(height: 124),
|
||||
const SizedBox(height: 10),
|
||||
const Spacer(),
|
||||
|
||||
// Timer
|
||||
if (widget.tiempoDebateSegundos != null) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(32),
|
||||
decoration: BoxDecoration(
|
||||
color: _segundosRestantes == 0
|
||||
? TemaApp.colorAcento.withValues(alpha: 0.3)
|
||||
: TemaApp.colorTarjeta,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/ui/generated/gameplay/gameplay_phase_emblem.webp',
|
||||
fit: BoxFit.contain,
|
||||
opacity: const AlwaysStoppedAnimation(0.42),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_segundosRestantes == 0
|
||||
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,
|
||||
titulo: l10n.debate,
|
||||
subtitulo: l10n.debateInstructions,
|
||||
child: Column(
|
||||
children: [
|
||||
if (widget.tiempoDebateSegundos != null) ...[
|
||||
TemporizadorFarolero(
|
||||
etiqueta: _segundosRestantes == 0
|
||||
? l10n.timeUp
|
||||
: l10n.timeRemaining,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
tiempo: _formatearTiempo(_segundosRestantes),
|
||||
agotado: _segundosRestantes == 0,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 16),
|
||||
] else ...[
|
||||
Text(
|
||||
_formatearTiempo(_segundosRestantes),
|
||||
style:
|
||||
Theme.of(context).textTheme.displayMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _segundosRestantes == 0
|
||||
? TemaApp.colorAcento
|
||||
: TemaApp.colorTexto,
|
||||
),
|
||||
l10n.debatePhaseActive,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
] else ...[
|
||||
Text(
|
||||
l10n.debatePhaseActive,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
|
||||
// Instrucciones
|
||||
if (widget.primerTurnoNombre != null) ...[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: TemaApp.colorNaranja.withValues(alpha: 0.18),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: TemaApp.colorNaranja.withValues(alpha: 0.65),
|
||||
if (widget.primerTurnoNombre != null) ...[
|
||||
EstadoJugadorFarolero(
|
||||
nombre: l10n.firstTurnInstruction(
|
||||
widget.primerTurnoNombre!,
|
||||
),
|
||||
destacado: true,
|
||||
completado: true,
|
||||
icono: Icons.record_voice_over,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
BotonFarolero.secundario(
|
||||
texto: _votacionSolicitada
|
||||
? l10n.votacionSolicitada
|
||||
: l10n.solicitarVotacion,
|
||||
icono: _votacionSolicitada
|
||||
? Icons.hourglass_empty
|
||||
: Icons.how_to_vote,
|
||||
onPressed: _votacionSolicitada
|
||||
? null
|
||||
: () {
|
||||
setState(() => _votacionSolicitada = true);
|
||||
widget.onSolicitarVotacion();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.record_voice_over,
|
||||
color: TemaApp.colorNaranja,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.primerTurnoNombre!,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
|
||||
Text(
|
||||
l10n.debateInstructions,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: TemaApp.colorTextoSecundario,
|
||||
fontSize: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Botón solicitar votación
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _votacionSolicitada
|
||||
? null
|
||||
: () {
|
||||
setState(() => _votacionSolicitada = true);
|
||||
widget.onSolicitarVotacion();
|
||||
},
|
||||
icon: Icon(_votacionSolicitada ? Icons.hourglass_empty : Icons.how_to_vote),
|
||||
label: Text(
|
||||
_votacionSolicitada
|
||||
? l10n.votacionSolicitada
|
||||
: l10n.solicitarVotacion,
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _votacionSolicitada
|
||||
? TemaApp.colorTarjeta
|
||||
: TemaApp.colorAcento,
|
||||
foregroundColor: Colors.white,
|
||||
textStyle: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user