fazer a tela de status

This commit is contained in:
2026-01-13 10:39:37 +00:00
parent 10e4af9aa4
commit eeb9f0e760
3 changed files with 49 additions and 4 deletions

View File

@@ -40,5 +40,9 @@ class TeamController {
} catch (e) {
print("Erro ao eliminar: $e");
}
Future<int> getPlayerCount(String teamId) async {
var snapshot = await _teamsRef.doc(teamId).collection('players').get();
return snapshot.docs.length;
}
}
}

View File

@@ -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<String, dynamic> 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
);
}
}

View File

@@ -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(