This commit is contained in:
2026-02-03 17:33:40 +00:00
parent 2a9661978c
commit 74453f7cbc
22 changed files with 1082 additions and 639 deletions

View File

@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:playmaker/screens/team_stats_page.dart';
import '../models/team_model.dart';
import '../controllers/team_controller.dart';
import '../screens/team_stats_page.dart';
class TeamCard extends StatelessWidget {
final Team team;
final TeamController controller;
@@ -17,40 +18,37 @@ class TeamCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
color: Colors.white,
elevation: 3,
margin: const EdgeInsets.only(bottom: 12),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
leading: Stack(
clipBehavior: Clip.none, // Permite que a estrela flutue ligeiramente fora do círculo
// --- 1. IMAGEM + FAVORITO ---
leading: Stack(
clipBehavior: Clip.none,
children: [
// 1. IMAGEM DA EQUIPA
CircleAvatar(
radius: 28,
backgroundColor: Colors.grey[200],
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
? NetworkImage(team.imageUrl)
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
? NetworkImage(team.imageUrl)
: null,
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
? Text(
team.imageUrl.isEmpty ? "🏀" : team.imageUrl,
style: const TextStyle(fontSize: 24),
)
)
: null,
),
// 2. BOTÃO DA ESTRELA (Favorito)
Positioned(
left: -15, // Posiciona à esquerda da imagem
left: -15,
top: -10,
child: IconButton(
// O segredo está em colocar o shadow dentro do Icon:
icon: Icon(
team.isFavorite ? Icons.star : Icons.star_border,
color: team.isFavorite ? Colors.amber : Colors.black.withOpacity(0.1), // Transparente se não favorito
color: team.isFavorite ? Colors.amber : Colors.black.withOpacity(0.1),
size: 28,
shadows: [
Shadow(
@@ -65,13 +63,13 @@ class TeamCard extends StatelessWidget {
],
),
// --- NOME DA EQUIPA ---
// --- 2. TÍTULO ---
title: Text(
team.name,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
// --- SUBTÍTULO (CONTAGEM E TEMPORADA) ---
// --- 3. SUBTÍTULO (Contagem + Época) ---
subtitle: Padding(
padding: const EdgeInsets.only(top: 6.0),
child: Row(
@@ -102,9 +100,9 @@ class TeamCard extends StatelessWidget {
),
),
// --- BOTÕES DE ACÇÃO À DIREITA ---
// --- 4. BOTÕES (Estatísticas e Apagar) ---
trailing: SizedBox(
width: 80,
width: 96, // Aumentei um pouco para caberem bem os dois botões
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@@ -112,6 +110,7 @@ class TeamCard extends StatelessWidget {
tooltip: 'Ver Estatísticas',
icon: const Icon(Icons.bar_chart_rounded, color: Colors.blue),
onPressed: () {
// CORRIGIDO: Agora chama a classe TeamStatsPage corretamente
Navigator.push(
context,
MaterialPageRoute(
@@ -131,6 +130,8 @@ class TeamCard extends StatelessWidget {
),
);
}
// Função de confirmação de exclusão
void _confirmDelete(BuildContext context) {
showDialog(
context: context,
@@ -139,22 +140,23 @@ class TeamCard extends StatelessWidget {
content: Text('Tens a certeza que queres eliminar "${team.name}"?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancelar')
onPressed: () => Navigator.pop(context),
child: const Text('Cancelar'),
),
TextButton(
onPressed: () {
controller.deleteTeam(team.id);
controller.deleteTeam(team.id);
Navigator.pop(context);
},
child: const Text('Eliminar', style: TextStyle(color: Colors.red))
),
child: const Text('Eliminar', style: TextStyle(color: Colors.red)),
),
],
),
);
}
}
// --- DIALOG DE CRIAÇÃO ---
class CreateTeamDialog extends StatefulWidget {
final Function(String name, String season, String imageUrl) onConfirm;
@@ -206,16 +208,16 @@ class _CreateTeamDialogState extends State<CreateTeamDialog> {
TextButton(onPressed: () => Navigator.pop(context), child: const Text('Cancelar')),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C)),
onPressed: () {
if (_nameController.text.trim().isNotEmpty) {
widget.onConfirm(
_nameController.text.trim(),
_selectedSeason,
_imageController.text.trim()
);
Navigator.pop(context);
}
},
onPressed: () {
if (_nameController.text.trim().isNotEmpty) {
widget.onConfirm(
_nameController.text.trim(),
_selectedSeason,
_imageController.text.trim(),
);
Navigator.pop(context);
}
},
child: const Text('Criar', style: TextStyle(color: Colors.white)),
),
],