Cambio de icono y traducciones
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:farolero/l10n/generated/app_localizations.dart';
|
||||
|
||||
import '../servicios/servicio_historial_partidas.dart';
|
||||
import '../tema/componentes_farolero.dart';
|
||||
@@ -10,52 +11,98 @@ class PantallaHistorial extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final historial = context.watch<ServicioHistorialPartidas>();
|
||||
final partidas = historial.partidas;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Historial')),
|
||||
appBar: AppBar(title: Text(l10n.history)),
|
||||
body: FondoFarolero(
|
||||
intenso: true,
|
||||
child: partidas.isEmpty
|
||||
? const Center(child: Text('Todavía no hay partidas guardadas.'))
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: partidas.length,
|
||||
itemBuilder: (context, index) {
|
||||
final partida = partidas[index];
|
||||
final ganaronJugadores = partida.ganador == 'jugadores';
|
||||
final dia =
|
||||
partida.fecha.day.toString().padLeft(2, '0');
|
||||
final mes =
|
||||
partida.fecha.month.toString().padLeft(2, '0');
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: ganaronJugadores
|
||||
? TemaApp.colorVerde
|
||||
: TemaApp.colorAcento,
|
||||
child: Icon(
|
||||
ganaronJugadores ? Icons.groups : Icons.theater_comedy,
|
||||
color: Colors.white,
|
||||
),
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: EstadoVacioFarolero(
|
||||
icono: Icons.history_rounded,
|
||||
titulo: l10n.history,
|
||||
subtitulo: l10n.noSavedGames,
|
||||
),
|
||||
),
|
||||
)
|
||||
: SafeArea(
|
||||
top: false,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||
itemCount: partidas.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
final partida = partidas[index];
|
||||
final ganaronJugadores = partida.ganador == 'jugadores';
|
||||
final color = ganaronJugadores
|
||||
? TemaApp.colorVerde
|
||||
: TemaApp.colorAcento;
|
||||
final dia = partida.fecha.day.toString().padLeft(2, '0');
|
||||
final mes = partida.fecha.month.toString().padLeft(2, '0');
|
||||
return PanelFarolero(
|
||||
padding: const EdgeInsets.all(14),
|
||||
borderColor: color.withValues(alpha: 0.48),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 52,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: color.withValues(alpha: 0.18),
|
||||
border: Border.all(color: color),
|
||||
),
|
||||
child: Icon(
|
||||
ganaronJugadores
|
||||
? Icons.groups_rounded
|
||||
: Icons.theater_comedy_rounded,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
ganaronJugadores
|
||||
? l10n.playersWin
|
||||
: l10n.impostorsWin,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
l10n.historyGameSummary(
|
||||
partida.jugadores,
|
||||
partida.impostores,
|
||||
partida.rondas,
|
||||
partida.palabra,
|
||||
partida.categoria,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
'$dia/$mes',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(
|
||||
ganaronJugadores
|
||||
? 'Ganaron los jugadores'
|
||||
: 'Ganaron los impostores',
|
||||
),
|
||||
subtitle: Text(
|
||||
'${partida.jugadores} jugadores · ${partida.impostores} impostor(es) · ${partida.rondas} ronda(s)\n${partida.palabra} · ${partida.categoria}',
|
||||
),
|
||||
isThreeLine: true,
|
||||
trailing: Text(
|
||||
'$dia/$mes',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user