fazer a tela de status
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user