vai te lixar github

This commit is contained in:
2026-03-16 22:09:01 +00:00
parent 1917b5fe10
commit cf0a9a9890
22 changed files with 1929 additions and 1290 deletions

View File

@@ -1,8 +1,10 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA!
import '../models/team_model.dart';
import '../models/person_model.dart';
import '../utils/size_extension.dart'; // 👇 SUPERPODER SF
// --- CABEÇALHO ---
class StatsHeader extends StatelessWidget {
@@ -13,22 +15,24 @@ class StatsHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20),
decoration: const BoxDecoration(
color: Color(0xFF2C3E50),
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(30), bottomRight: Radius.circular(30)),
padding: EdgeInsets.only(top: 50 * context.sf, left: 20 * context.sf, right: 20 * context.sf, bottom: 20 * context.sf),
decoration: BoxDecoration(
color: AppTheme.primaryRed, // 👇 Usando a cor oficial
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30 * context.sf),
bottomRight: Radius.circular(30 * context.sf)
),
),
child: Row(
children: [
IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.white),
icon: Icon(Icons.arrow_back, color: Colors.white, size: 24 * context.sf),
onPressed: () => Navigator.pop(context),
),
const SizedBox(width: 10),
SizedBox(width: 10 * context.sf),
// IMAGEM OU EMOJI DA EQUIPA AQUI!
CircleAvatar(
radius: 24,
radius: 24 * context.sf,
backgroundColor: Colors.white24,
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
? NetworkImage(team.imageUrl)
@@ -36,18 +40,25 @@ class StatsHeader extends StatelessWidget {
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
? Text(
team.imageUrl.isEmpty ? "🛡️" : team.imageUrl,
style: const TextStyle(fontSize: 20),
style: TextStyle(fontSize: 20 * context.sf),
)
: null,
),
const SizedBox(width: 15),
Expanded( // Expanded evita overflow se o nome for muito longo
SizedBox(width: 15 * context.sf),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(team.name, style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.ellipsis),
Text(team.season, style: const TextStyle(color: Colors.white70, fontSize: 14)),
Text(
team.name,
style: TextStyle(color: Colors.white, fontSize: 20 * context.sf, fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis
),
Text(
team.season,
style: TextStyle(color: Colors.white70, fontSize: 14 * context.sf)
),
],
),
),
@@ -65,20 +76,36 @@ class StatsSummaryCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 👇 Adapta-se ao Modo Claro/Escuro
final Color bgColor = Theme.of(context).brightness == Brightness.dark ? const Color(0xFF1E1E1E) : Colors.white;
return Card(
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
child: Container(
padding: const EdgeInsets.all(20),
padding: EdgeInsets.all(20 * context.sf),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: LinearGradient(colors: [Colors.blue.shade700, Colors.blue.shade400]),
color: bgColor,
borderRadius: BorderRadius.circular(20 * context.sf),
border: Border.all(color: Colors.grey.withOpacity(0.15)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("Total de Membros", style: TextStyle(color: Colors.white, fontSize: 16)),
Text("$total", style: const TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold)),
Row(
children: [
Icon(Icons.groups, color: AppTheme.primaryRed, size: 28 * context.sf), // 👇 Cor do tema
SizedBox(width: 10 * context.sf),
Text(
"Total de Membros",
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 16 * context.sf, fontWeight: FontWeight.w600)
),
],
),
Text(
"$total",
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 28 * context.sf, fontWeight: FontWeight.bold)
),
],
),
),
@@ -97,8 +124,11 @@ class StatsSectionTitle extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF2C3E50))),
const Divider(),
Text(
title,
style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onSurface)
),
Divider(color: Colors.grey.withOpacity(0.2)),
],
);
}
@@ -121,37 +151,50 @@ class PersonCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 👇 Adapta as cores do Card ao Modo Escuro e ao Tema
final Color defaultBg = Theme.of(context).brightness == Brightness.dark ? const Color(0xFF1E1E1E) : Colors.white;
final Color coachBg = Theme.of(context).brightness == Brightness.dark ? AppTheme.warningAmber.withOpacity(0.1) : const Color(0xFFFFF9C4);
return Card(
margin: const EdgeInsets.only(top: 12),
margin: EdgeInsets.only(top: 12 * context.sf),
elevation: 2,
color: isCoach ? const Color(0xFFFFF9C4) : Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
color: isCoach ? coachBg : defaultBg,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
child: ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 4 * context.sf),
leading: isCoach
? const CircleAvatar(backgroundColor: Colors.orange, child: Icon(Icons.person, color: Colors.white))
? CircleAvatar(
radius: 22 * context.sf,
backgroundColor: AppTheme.warningAmber, // 👇 Cor do tema
child: Icon(Icons.person, color: Colors.white, size: 24 * context.sf)
)
: Container(
width: 45,
height: 45,
width: 45 * context.sf,
height: 45 * context.sf,
alignment: Alignment.center,
decoration: BoxDecoration(color: Colors.blue.withOpacity(0.1), borderRadius: BorderRadius.circular(10)),
child: Text(person.number ?? "J", style: const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontSize: 16)),
decoration: BoxDecoration(
color: AppTheme.primaryRed.withOpacity(0.1), // 👇 Cor do tema
borderRadius: BorderRadius.circular(10 * context.sf)
),
child: Text(
person.number ?? "J",
style: TextStyle(color: AppTheme.primaryRed, fontWeight: FontWeight.bold, fontSize: 16 * context.sf)
),
),
title: Text(person.name, style: const TextStyle(fontWeight: FontWeight.bold)),
title: Text(
person.name,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * context.sf, color: Theme.of(context).colorScheme.onSurface)
),
// --- CANTO DIREITO (Trailing) ---
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
// IMAGEM DA EQUIPA NO CARD DO JOGADOR
const SizedBox(width: 5), // Espaço
IconButton(
icon: const Icon(Icons.edit_outlined, color: Colors.blue),
icon: Icon(Icons.edit_outlined, color: Colors.blue, size: 22 * context.sf),
onPressed: onEdit,
),
IconButton(
icon: const Icon(Icons.delete_outline, color: Colors.red),
icon: Icon(Icons.delete_outline, color: AppTheme.primaryRed, size: 22 * context.sf), // 👇 Cor do tema
onPressed: onDelete,
),
],
@@ -180,10 +223,9 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F7FA),
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // 👇 Adapta-se ao Modo Escuro
body: Column(
children: [
// Cabeçalho
StatsHeader(team: widget.team),
Expanded(
@@ -191,11 +233,11 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
stream: _controller.getMembers(widget.team.id),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
return Center(child: CircularProgressIndicator(color: AppTheme.primaryRed));
}
if (snapshot.hasError) {
return Center(child: Text("Erro ao carregar: ${snapshot.error}"));
return Center(child: Text("Erro ao carregar: ${snapshot.error}", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)));
}
final members = snapshot.data ?? [];
@@ -204,15 +246,16 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
final players = members.where((m) => m.type == 'Jogador').toList();
return RefreshIndicator(
color: AppTheme.primaryRed,
onRefresh: () async => setState(() {}),
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.all(16.0),
padding: EdgeInsets.all(16.0 * context.sf),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StatsSummaryCard(total: members.length),
const SizedBox(height: 30),
SizedBox(height: 30 * context.sf),
// TREINADORES
if (coaches.isNotEmpty) ...[
@@ -220,19 +263,18 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
...coaches.map((c) => PersonCard(
person: c,
isCoach: true,
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, c),
onDelete: () => _confirmDelete(context, c),
)),
const SizedBox(height: 30),
SizedBox(height: 30 * context.sf),
],
// JOGADORES
const StatsSectionTitle(title: "Jogadores"),
if (players.isEmpty)
const Padding(
padding: EdgeInsets.only(top: 20),
child: Text("Nenhum jogador nesta equipa.", style: TextStyle(color: Colors.grey, fontSize: 16)),
Padding(
padding: EdgeInsets.only(top: 20 * context.sf),
child: Text("Nenhum jogador nesta equipa.", style: TextStyle(color: Colors.grey, fontSize: 16 * context.sf)),
)
else
...players.map((p) => PersonCard(
@@ -241,7 +283,7 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, p),
onDelete: () => _confirmDelete(context, p),
)),
const SizedBox(height: 80),
SizedBox(height: 80 * context.sf),
],
),
),
@@ -254,8 +296,8 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
floatingActionButton: FloatingActionButton(
heroTag: 'fab_team_${widget.team.id}',
onPressed: () => _controller.showAddPersonDialog(context, widget.team.id),
backgroundColor: const Color(0xFF00C853),
child: const Icon(Icons.add, color: Colors.white),
backgroundColor: AppTheme.successGreen, // 👇 Cor de sucesso do tema
child: Icon(Icons.add, color: Colors.white, size: 24 * context.sf),
),
);
}
@@ -264,16 +306,20 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Text("Eliminar Membro?"),
content: Text("Tens a certeza que queres remover ${person.name}?"),
backgroundColor: Theme.of(context).colorScheme.surface,
title: Text("Eliminar Membro?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
content: Text("Tens a certeza que queres remover ${person.name}?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
actions: [
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text("Cancelar")),
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text("Cancelar", style: TextStyle(color: Colors.grey))
),
TextButton(
onPressed: () async {
await _controller.deletePerson(person.id);
if (ctx.mounted) Navigator.pop(ctx);
},
child: const Text("Eliminar", style: TextStyle(color: Colors.red)),
child: Text("Eliminar", style: TextStyle(color: AppTheme.primaryRed)), // 👇 Cor oficial
),
],
),
@@ -323,20 +369,27 @@ class StatsController {
context: context,
builder: (ctx) => StatefulBuilder(
builder: (ctx, setState) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
title: Text(isEdit ? "Editar Membro" : "Novo Membro"),
backgroundColor: Theme.of(context).colorScheme.surface,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
title: Text(
isEdit ? "Editar Membro" : "Novo Membro",
style: TextStyle(color: Theme.of(context).colorScheme.onSurface)
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: nameCtrl,
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
decoration: const InputDecoration(labelText: "Nome Completo"),
textCapitalization: TextCapitalization.words,
),
const SizedBox(height: 15),
SizedBox(height: 15 * context.sf),
DropdownButtonFormField<String>(
value: selectedType,
dropdownColor: Theme.of(context).colorScheme.surface,
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 16 * context.sf),
decoration: const InputDecoration(labelText: "Função"),
items: ["Jogador", "Treinador"]
.map((e) => DropdownMenuItem(value: e, child: Text(e)))
@@ -346,9 +399,10 @@ class StatsController {
},
),
if (selectedType == "Jogador") ...[
const SizedBox(height: 15),
SizedBox(height: 15 * context.sf),
TextField(
controller: numCtrl,
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
decoration: const InputDecoration(labelText: "Número da Camisola"),
keyboardType: TextInputType.number,
),
@@ -359,12 +413,13 @@ class StatsController {
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text("Cancelar")
child: const Text("Cancelar", style: TextStyle(color: Colors.grey))
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF00C853),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))
backgroundColor: AppTheme.successGreen, // 👇 Cor verde do tema
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8 * context.sf))
),
onPressed: () async {
if (nameCtrl.text.trim().isEmpty) return;
@@ -397,12 +452,12 @@ class StatsController {
errorMsg = "Já existe um membro com este numero na equipa.";
}
ScaffoldMessenger.of(ctx).showSnackBar(
SnackBar(content: Text(errorMsg), backgroundColor: Colors.red)
SnackBar(content: Text(errorMsg), backgroundColor: AppTheme.primaryRed) // 👇 Cor oficial para erro
);
}
}
},
child: const Text("Guardar", style: TextStyle(color: Colors.white)),
child: const Text("Guardar"),
)
],
),