59 lines
2.3 KiB
Dart
59 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../servicios/servicio_historial_partidas.dart';
|
|
import '../tema/componentes_farolero.dart';
|
|
import '../tema/tema_app.dart';
|
|
|
|
class PantallaHistorial extends StatelessWidget {
|
|
const PantallaHistorial({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final historial = context.watch<ServicioHistorialPartidas>();
|
|
final partidas = historial.partidas;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Historial')),
|
|
body: FondoFarolero(
|
|
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';
|
|
return Card(
|
|
child: ListTile(
|
|
leading: CircleAvatar(
|
|
backgroundColor: ganaronJugadores
|
|
? TemaApp.colorVerde
|
|
: TemaApp.colorAcento,
|
|
child: Icon(
|
|
ganaronJugadores ? Icons.groups : Icons.theater_comedy,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
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(
|
|
'${partida.fecha.day.toString().padLeft(2, '0')}/${partida.fecha.month.toString().padLeft(2, '0')}',
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|