diff --git a/lib/controllers/team_controllers.dart b/lib/controllers/team_controllers.dart index 828d090..9ad2289 100644 --- a/lib/controllers/team_controllers.dart +++ b/lib/controllers/team_controllers.dart @@ -40,5 +40,9 @@ class TeamController { } catch (e) { print("Erro ao eliminar: $e"); } + Future getPlayerCount(String teamId) async { + var snapshot = await _teamsRef.doc(teamId).collection('players').get(); + return snapshot.docs.length; } +} } \ No newline at end of file diff --git a/lib/models/team_model.dart b/lib/models/team_model.dart index 5494a79..9478df4 100644 --- a/lib/models/team_model.dart +++ b/lib/models/team_model.dart @@ -1,10 +1,17 @@ class Team { final String id; final String name; - final String season; // NOVO - final String imageUrl; // NOVO + final String season; + final String imageUrl; + final int playerCount; // NOVO: Campo para guardar o total - Team({required this.id, required this.name, required this.season, required this.imageUrl}); + Team({ + required this.id, + required this.name, + required this.season, + required this.imageUrl, + this.playerCount = 0, // Valor padrão + }); factory Team.fromFirestore(Map data, String id) { return Team( @@ -12,6 +19,7 @@ class Team { name: data['name'] ?? '', season: data['season'] ?? '', imageUrl: data['imageUrl'] ?? '', + playerCount: data['playerCount'] ?? 0, // Lê do Firebase ); } } \ No newline at end of file diff --git a/lib/widgets/team_widgets.dart b/lib/widgets/team_widgets.dart index 66ed64d..be7d9e7 100644 --- a/lib/widgets/team_widgets.dart +++ b/lib/widgets/team_widgets.dart @@ -10,6 +10,7 @@ class TeamCard extends StatelessWidget { super.key, required this.team, required this.controller, + }); @override @@ -40,7 +41,39 @@ class TeamCard extends StatelessWidget { team.name, style: const TextStyle(fontWeight: FontWeight.bold), ), - subtitle: Text("Temporada: ${team.season}"), + // Dentro do build do teu TeamCard, no subtitle: +subtitle: Padding( + padding: const EdgeInsets.only(top: 4.0), + child: Row( + children: [ + // 1. JOGADORES (À ESQUERDA) + const Icon(Icons.groups, size: 16, color: Colors.grey), + const SizedBox(width: 4), + Text( + "${team.playerCount} Jogadores", + style: TextStyle( + color: team.playerCount == 0 ? Colors.orange : Colors.green, + fontWeight: FontWeight.w500, + fontSize: 13, + ), + ), + + // SEPARADOR VISUAL + const Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Text("•", style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold)), + ), + + // 2. TEMPORADA (A SEGUIR) + Text("${team.season} Temporada", + style: const TextStyle( + color: Colors.grey, + fontSize: 13, + ), + ), + ], + ), +), // 3. TRAILING (Lado Direito): Botões de Status e Eliminar trailing: SizedBox(