vai te lixar github
This commit is contained in:
@@ -1,325 +1,362 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:playmaker/controllers/placar_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:playmaker/controllers/placar_controller.dart';
|
||||
import 'package:playmaker/utils/size_extension.dart';
|
||||
import 'package:playmaker/widgets/placar_widgets.dart';
|
||||
import 'dart:math' as math;
|
||||
import 'package:playmaker/widgets/placar_widgets.dart'; // 👇 As tuas classes extra vivem aqui!
|
||||
import 'dart:math' as math;
|
||||
|
||||
class PlacarPage extends StatefulWidget {
|
||||
final String gameId, myTeam, opponentTeam;
|
||||
const PlacarPage({super.key, required this.gameId, required this.myTeam, required this.opponentTeam});
|
||||
import 'package:playmaker/zone_map_dialog.dart';
|
||||
|
||||
@override
|
||||
State<PlacarPage> createState() => _PlacarPageState();
|
||||
class PlacarPage extends StatefulWidget {
|
||||
final String gameId, myTeam, opponentTeam;
|
||||
|
||||
const PlacarPage({
|
||||
super.key,
|
||||
required this.gameId,
|
||||
required this.myTeam,
|
||||
required this.opponentTeam
|
||||
});
|
||||
|
||||
@override
|
||||
State<PlacarPage> createState() => _PlacarPageState();
|
||||
}
|
||||
|
||||
class _PlacarPageState extends State<PlacarPage> {
|
||||
late PlacarController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Obriga o telemóvel a ficar deitado
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeRight,
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
|
||||
_controller = PlacarController(
|
||||
gameId: widget.gameId,
|
||||
myTeam: widget.myTeam,
|
||||
opponentTeam: widget.opponentTeam,
|
||||
onUpdate: () {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
);
|
||||
_controller.loadPlayers();
|
||||
}
|
||||
|
||||
class _PlacarPageState extends State<PlacarPage> {
|
||||
late PlacarController _controller;
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
// Volta a deixar o telemóvel ao alto quando sais
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeRight,
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
|
||||
_controller = PlacarController(
|
||||
gameId: widget.gameId,
|
||||
myTeam: widget.myTeam,
|
||||
opponentTeam: widget.opponentTeam,
|
||||
onUpdate: () {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
);
|
||||
_controller.loadPlayers();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// --- BOTÕES FLUTUANTES DE FALTA ---
|
||||
Widget _buildFloatingFoulBtn(String label, Color color, String action, IconData icon, double left, double right, double top, double sf) {
|
||||
return Positioned(
|
||||
top: top,
|
||||
left: left > 0 ? left : null,
|
||||
right: right > 0 ? right : null,
|
||||
child: Draggable<String>(
|
||||
data: action,
|
||||
feedback: Material(
|
||||
color: Colors.transparent,
|
||||
child: CircleAvatar(
|
||||
radius: 30 * sf,
|
||||
backgroundColor: color.withOpacity(0.8),
|
||||
child: Icon(icon, color: Colors.white, size: 30 * sf)
|
||||
),
|
||||
// --- BOTÕES FLUTUANTES DE FALTA ---
|
||||
Widget _buildFloatingFoulBtn(String label, Color color, String action, IconData icon, double left, double right, double top, double sf) {
|
||||
return Positioned(
|
||||
top: top,
|
||||
left: left > 0 ? left : null,
|
||||
right: right > 0 ? right : null,
|
||||
child: Draggable<String>(
|
||||
data: action,
|
||||
feedback: Material(
|
||||
color: Colors.transparent,
|
||||
child: CircleAvatar(
|
||||
radius: 30 * sf,
|
||||
backgroundColor: color.withOpacity(0.8),
|
||||
child: Icon(icon, color: Colors.white, size: 30 * sf)
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 27 * sf,
|
||||
backgroundColor: color,
|
||||
child: Icon(icon, color: Colors.white, size: 28 * sf),
|
||||
),
|
||||
SizedBox(height: 5 * sf),
|
||||
Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12 * sf)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- BOTÕES LATERAIS QUADRADOS ---
|
||||
Widget _buildCornerBtn({required String heroTag, required IconData icon, required Color color, required VoidCallback onTap, required double size, bool isLoading = false}) {
|
||||
return SizedBox(
|
||||
width: size,
|
||||
height: size,
|
||||
child: FloatingActionButton(
|
||||
heroTag: heroTag,
|
||||
backgroundColor: color,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * (size / 50))),
|
||||
elevation: 5,
|
||||
onPressed: isLoading ? null : onTap,
|
||||
child: isLoading
|
||||
? SizedBox(width: size * 0.45, height: size * 0.45, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5))
|
||||
: Icon(icon, color: Colors.white, size: size * 0.55),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double hScreen = MediaQuery.of(context).size.height;
|
||||
|
||||
// 👇 CÁLCULO MANUAL DO SF 👇
|
||||
final double sf = math.min(wScreen / 1150, hScreen / 720);
|
||||
final double cornerBtnSize = 48 * sf; // Tamanho ideal
|
||||
|
||||
// ==========================================
|
||||
// ECRÃ DE CARREGAMENTO (LOADING)
|
||||
// ==========================================
|
||||
if (_controller.isLoading) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF16202C),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 27 * sf,
|
||||
backgroundColor: color,
|
||||
child: Icon(icon, color: Colors.white, size: 28 * sf),
|
||||
Text("PREPARANDO O PAVILHÃO", style: TextStyle(color: Colors.white24, fontSize: 45 * sf, fontWeight: FontWeight.bold, letterSpacing: 2)),
|
||||
SizedBox(height: 35 * sf),
|
||||
StreamBuilder(
|
||||
stream: Stream.periodic(const Duration(seconds: 3)),
|
||||
builder: (context, snapshot) {
|
||||
List<String> frases = [
|
||||
"O Treinador está a desenhar a tática...",
|
||||
"A encher as bolas com ar de campeão...",
|
||||
"O árbitro está a testar o apito...",
|
||||
"A verificar se o cesto está nivelado...",
|
||||
"Os jogadores estão a terminar o aquecimento..."
|
||||
];
|
||||
String frase = frases[DateTime.now().second % frases.length];
|
||||
return Text(frase, style: TextStyle(color: Colors.orange.withOpacity(0.7), fontSize: 26 * sf, fontStyle: FontStyle.italic));
|
||||
},
|
||||
),
|
||||
SizedBox(height: 5 * sf),
|
||||
Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12 * sf)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- BOTÕES LATERAIS QUADRADOS ---
|
||||
Widget _buildCornerBtn({required String heroTag, required IconData icon, required Color color, required VoidCallback onTap, required double size, bool isLoading = false}) {
|
||||
return SizedBox(
|
||||
width: size,
|
||||
height: size,
|
||||
child: FloatingActionButton(
|
||||
heroTag: heroTag,
|
||||
backgroundColor: color,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * (size / 50))),
|
||||
elevation: 5,
|
||||
onPressed: isLoading ? null : onTap,
|
||||
child: isLoading
|
||||
? SizedBox(width: size*0.45, height: size*0.45, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5))
|
||||
: Icon(icon, color: Colors.white, size: size * 0.55),
|
||||
),
|
||||
);
|
||||
}
|
||||
// ==========================================
|
||||
// ECRÃ PRINCIPAL (O JOGO)
|
||||
// ==========================================
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF266174),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
// 👇 IGNORE POINTER BLOQUEIA CLIQUES ENQUANTO GUARDA 👇
|
||||
child: IgnorePointer(
|
||||
ignoring: _controller.isSaving,
|
||||
child: Stack(
|
||||
children: [
|
||||
// --- 1. O CAMPO ---
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.5)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final w = constraints.maxWidth;
|
||||
final h = constraints.maxHeight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double hScreen = MediaQuery.of(context).size.height;
|
||||
|
||||
// 👇 CÁLCULO MANUAL DO SF 👇
|
||||
final double sf = math.min(wScreen / 1150, hScreen / 720);
|
||||
return Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTapDown: (details) {
|
||||
if (_controller.isSelectingShotLocation) {
|
||||
_controller.registerShotLocation(context, details.localPosition, Size(w, h));
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/campo.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: _controller.matchShots.map((shot) => Positioned(
|
||||
// Posição calculada matematicamente pelo click anterior
|
||||
left: (shot.relativeX * w) - (9 * context.sf),
|
||||
top: (shot.relativeY * h) - (9 * context.sf),
|
||||
child: CircleAvatar(
|
||||
radius: 9 * context.sf,
|
||||
backgroundColor: shot.isMake ? Colors.green : Colors.red,
|
||||
child: Icon(shot.isMake ? Icons.check : Icons.close, size: 11 * context.sf, color: Colors.white)
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
final double cornerBtnSize = 48 * sf; // Tamanho ideal (Nem 38 nem 55)
|
||||
// --- 2. JOGADORES NO CAMPO ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
Positioned(top: h * 0.25, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[0], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.68, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[1], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.45, left: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[2], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.15, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[3], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.80, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[4], isOpponent: false, sf: sf)),
|
||||
|
||||
Positioned(top: h * 0.25, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[0], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.68, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[1], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.45, right: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[2], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.15, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[3], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.80, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[4], isOpponent: true, sf: sf)),
|
||||
],
|
||||
|
||||
if (_controller.isLoading) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF16202C),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("PREPARANDO O PAVILHÃO", style: TextStyle(color: Colors.white24, fontSize: 45 * sf, fontWeight: FontWeight.bold, letterSpacing: 2)),
|
||||
SizedBox(height: 35 * sf),
|
||||
StreamBuilder(
|
||||
stream: Stream.periodic(const Duration(seconds: 3)),
|
||||
builder: (context, snapshot) {
|
||||
List<String> frases = [
|
||||
"O Treinador está a desenhar a tática...",
|
||||
"A encher as bolas com ar de campeão...",
|
||||
"O árbitro está a testar o apito...",
|
||||
"A verificar se o cesto está nivelado...",
|
||||
"Os jogadores estão a terminar o aquecimento..."
|
||||
];
|
||||
String frase = frases[DateTime.now().second % frases.length];
|
||||
return Text(frase, style: TextStyle(color: Colors.orange.withOpacity(0.7), fontSize: 26 * sf, fontStyle: FontStyle.italic));
|
||||
// --- 3. BOTÕES DE FALTAS NO CAMPO ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.39, 0.0, h * 0.31, sf),
|
||||
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0.0, w * 0.39, h * 0.31, sf),
|
||||
],
|
||||
|
||||
// --- 4. BOTÃO PLAY/PAUSE NO MEIO ---
|
||||
if (!_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: (h * 0.32) + (40 * sf),
|
||||
left: 0, right: 0,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => _controller.toggleTimer(context),
|
||||
child: CircleAvatar(
|
||||
radius: 68 * sf,
|
||||
backgroundColor: Colors.grey.withOpacity(0.5),
|
||||
child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 58 * sf)
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- 5. PLACAR LÁ NO TOPO ---
|
||||
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
|
||||
|
||||
// --- 6. PAINEL DE BOTÕES DE AÇÃO LÁ EM BAIXO ---
|
||||
if (!_controller.isSelectingShotLocation) Positioned(bottom: -10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
|
||||
|
||||
// --- 7. OVERLAY ESCURO PARA MARCAR PONTO NO CAMPO ---
|
||||
if (_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: h * 0.4, left: 0, right: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 35 * sf, vertical: 18 * sf),
|
||||
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(11 * sf), border: Border.all(color: Colors.white, width: 1.5 * sf)),
|
||||
child: Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 27 * sf, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF266174),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
// 👇 A MÁGICA DO IGNORE POINTER COMEÇA AQUI 👇
|
||||
child: IgnorePointer(
|
||||
ignoring: _controller.isSaving, // Se estiver a gravar, ignora os toques!
|
||||
child: Stack(
|
||||
children: [
|
||||
// --- O CAMPO ---
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.5)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final w = constraints.maxWidth;
|
||||
final h = constraints.maxHeight;
|
||||
// ==========================================
|
||||
// BOTÕES LATERAIS DE FORA DO CAMPO
|
||||
// ==========================================
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTapDown: (details) {
|
||||
if (_controller.isSelectingShotLocation) {
|
||||
_controller.registerShotLocation(context, details.localPosition, Size(w, h));
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/campo.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: _controller.matchShots.map((shot) => Positioned(
|
||||
// Agora usamos relativeX e relativeY multiplicados pela largura(w) e altura(h)
|
||||
left: (shot.relativeX * w) - (9 * context.sf),
|
||||
top: (shot.relativeY * h) - (9 * context.sf),
|
||||
child: CircleAvatar(
|
||||
radius: 9 * context.sf,
|
||||
backgroundColor: shot.isMake ? Colors.green : Colors.red,
|
||||
child: Icon(shot.isMake ? Icons.check : Icons.close, size: 11 * context.sf, color: Colors.white)
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- JOGADORES ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
Positioned(top: h * 0.25, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[0], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.68, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[1], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.45, left: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[2], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.15, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[3], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.80, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[4], isOpponent: false, sf: sf)),
|
||||
|
||||
Positioned(top: h * 0.25, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[0], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.68, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[1], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.45, right: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[2], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.15, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[3], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.80, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[4], isOpponent: true, sf: sf)),
|
||||
],
|
||||
|
||||
// --- BOTÕES DE FALTAS ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.39, 0.0, h * 0.31, sf),
|
||||
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0.0, w * 0.39, h * 0.31, sf),
|
||||
],
|
||||
|
||||
// --- BOTÃO PLAY/PAUSE ---
|
||||
if (!_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: (h * 0.32) + (40 * sf),
|
||||
left: 0, right: 0,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => _controller.toggleTimer(context),
|
||||
child: CircleAvatar(
|
||||
radius: 68 * sf,
|
||||
backgroundColor: Colors.grey.withOpacity(0.5),
|
||||
child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 58 * sf)
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// --- PLACAR NO TOPO ---
|
||||
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
|
||||
|
||||
// --- BOTÕES DE AÇÃO ---
|
||||
if (!_controller.isSelectingShotLocation) Positioned(bottom: -10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
|
||||
|
||||
// --- OVERLAY LANÇAMENTO ---
|
||||
if (_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: h * 0.4, left: 0, right: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 35 * sf, vertical: 18 * sf),
|
||||
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(11 * sf), border: Border.all(color: Colors.white, width: 1.5 * sf)),
|
||||
child: Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 27 * sf, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// --- BOTÕES LATERAIS ---
|
||||
// Topo Esquerdo: Guardar e Sair (Botão Único)
|
||||
Positioned(
|
||||
top: 50 * sf, left: 12 * sf,
|
||||
child: _buildCornerBtn(
|
||||
heroTag: 'btn_save_exit',
|
||||
icon: Icons.save_alt,
|
||||
color: const Color(0xFFD92C2C),
|
||||
size: cornerBtnSize,
|
||||
isLoading: _controller.isSaving,
|
||||
onTap: () async {
|
||||
// 1. Primeiro obriga a guardar os dados na BD
|
||||
await _controller.saveGameStats(context);
|
||||
|
||||
// 2. Só depois de acabar de guardar é que volta para trás
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
// Topo Esquerdo: Guardar e Sair
|
||||
Positioned(
|
||||
top: 50 * sf, left: 12 * sf,
|
||||
child: _buildCornerBtn(
|
||||
heroTag: 'btn_save_exit',
|
||||
icon: Icons.save_alt,
|
||||
color: const Color(0xFFD92C2C),
|
||||
size: cornerBtnSize,
|
||||
isLoading: _controller.isSaving,
|
||||
onTap: () async {
|
||||
// Guarda na BD e sai
|
||||
await _controller.saveGameStats(context);
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
),
|
||||
|
||||
// Base Esquerda: Banco Casa + TIMEOUT DA CASA
|
||||
Positioned(
|
||||
bottom: 55 * sf, left: 12 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showMyBench) BenchPlayersList(controller: _controller, isOpponent: false, sf: sf),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_home', icon: Icons.swap_horiz, color: const Color(0xFF1E5BB2), size: cornerBtnSize, onTap: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); }),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(
|
||||
heroTag: 'btn_to_home',
|
||||
icon: Icons.timer,
|
||||
color: _controller.myTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFF1E5BB2),
|
||||
size: cornerBtnSize,
|
||||
onTap: _controller.myTimeoutsUsed >= 3
|
||||
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa da casa já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
|
||||
: () => _controller.useTimeout(false)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Base Direita: Banco Visitante + TIMEOUT DO VISITANTE
|
||||
Positioned(
|
||||
bottom: 55 * sf, right: 12 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showOppBench) BenchPlayersList(controller: _controller, isOpponent: true, sf: sf),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_away', icon: Icons.swap_horiz, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); }),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(
|
||||
heroTag: 'btn_to_away',
|
||||
icon: Icons.timer,
|
||||
color: _controller.opponentTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFFD92C2C),
|
||||
size: cornerBtnSize,
|
||||
onTap: _controller.opponentTimeoutsUsed >= 3
|
||||
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa visitante já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
|
||||
: () => _controller.useTimeout(true)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 👇 EFEITO VISUAL (Ecrã escurece para mostrar que está a carregar) 👇
|
||||
if (_controller.isSaving)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
// Base Esquerda: Banco + TIMEOUT DA CASA
|
||||
Positioned(
|
||||
bottom: 55 * sf, left: 12 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showMyBench) BenchPlayersList(controller: _controller, isOpponent: false, sf: sf),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_home', icon: Icons.swap_horiz, color: const Color(0xFF1E5BB2), size: cornerBtnSize, onTap: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); }),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(
|
||||
heroTag: 'btn_to_home',
|
||||
icon: Icons.timer,
|
||||
color: _controller.myTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFF1E5BB2),
|
||||
size: cornerBtnSize,
|
||||
onTap: _controller.myTimeoutsUsed >= 3
|
||||
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa da casa já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
|
||||
: () => _controller.useTimeout(false)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
// Base Direita: Banco + TIMEOUT DO VISITANTE
|
||||
Positioned(
|
||||
bottom: 55 * sf, right: 12 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showOppBench) BenchPlayersList(controller: _controller, isOpponent: true, sf: sf),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_away', icon: Icons.swap_horiz, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); }),
|
||||
SizedBox(height: 12 * sf),
|
||||
_buildCornerBtn(
|
||||
heroTag: 'btn_to_away',
|
||||
icon: Icons.timer,
|
||||
color: _controller.opponentTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFFD92C2C),
|
||||
size: cornerBtnSize,
|
||||
onTap: _controller.opponentTimeoutsUsed >= 3
|
||||
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa visitante já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
|
||||
: () => _controller.useTimeout(true)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 👇 EFEITO VISUAL (Ecrã escurece para mostrar que está a carregar quando se clica no Guardar) 👇
|
||||
if (_controller.isSaving)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
void _openZoneMap(String action, String playerData) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => ZoneMapDialog(
|
||||
playerName: playerData.replaceAll("player_my_", "").replaceAll("player_opp_", ""),
|
||||
isMake: action.startsWith("add_"),
|
||||
onZoneSelected: (zone, points, relX, relY) {
|
||||
_controller.registerShotFromPopup(
|
||||
context,
|
||||
action,
|
||||
playerData,
|
||||
zone,
|
||||
points,
|
||||
relX,
|
||||
relY
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||
import '../controllers/register_controller.dart';
|
||||
import '../widgets/register_widgets.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||
@@ -22,11 +23,20 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
// 👇 BLINDADO: Adapta-se automaticamente ao Modo Claro/Escuro
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text("Criar Conta", style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
backgroundColor: Colors.white,
|
||||
title: Text(
|
||||
"Criar Conta",
|
||||
style: TextStyle(
|
||||
fontSize: 18 * context.sf,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurface, // 👇 Adaptável ao Modo Escuro
|
||||
)
|
||||
),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
elevation: 0,
|
||||
iconTheme: IconThemeData(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
@@ -40,7 +50,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const RegisterHeader(), // 🔥 Agora sim, usa o Header bonito!
|
||||
const RegisterHeader(),
|
||||
SizedBox(height: 30 * context.sf),
|
||||
|
||||
RegisterFormFields(controller: _controller),
|
||||
|
||||
@@ -1,76 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
import '../models/game_model.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 NOVO SUPERPODER AQUI TAMBÉM!
|
||||
import '../utils/size_extension.dart';
|
||||
|
||||
// --- CARD DE EXIBIÇÃO DO JOGO ---
|
||||
class GameResultCard extends StatelessWidget {
|
||||
final String gameId, myTeam, opponentTeam, myScore, opponentScore, status, season;
|
||||
final String? myTeamLogo, opponentTeamLogo;
|
||||
final String? myTeamLogo, opponentTeamLogo;
|
||||
final double sf;
|
||||
|
||||
const GameResultCard({
|
||||
super.key, required this.gameId, required this.myTeam, required this.opponentTeam,
|
||||
required this.myScore, required this.opponentScore, required this.status, required this.season,
|
||||
this.myTeamLogo, this.opponentTeamLogo,
|
||||
this.myTeamLogo, this.opponentTeamLogo, required this.sf,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bgColor = Theme.of(context).cardTheme.color;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 16 * context.sf),
|
||||
padding: EdgeInsets.all(16 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(20 * context.sf), boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10 * context.sf)]),
|
||||
margin: EdgeInsets.only(bottom: 16 * sf),
|
||||
padding: EdgeInsets.all(16 * sf),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(20 * sf),
|
||||
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10 * sf)],
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: _buildTeamInfo(context, myTeam, const Color(0xFFE74C3C), myTeamLogo)),
|
||||
_buildScoreCenter(context, gameId),
|
||||
Expanded(child: _buildTeamInfo(context, opponentTeam, Colors.black87, opponentTeamLogo)),
|
||||
Expanded(child: _buildTeamInfo(myTeam, AppTheme.primaryRed, myTeamLogo, sf, textColor)),
|
||||
_buildScoreCenter(context, gameId, sf, textColor),
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.grey.shade600, opponentTeamLogo, sf, textColor)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTeamInfo(BuildContext context, String name, Color color, String? logoUrl) {
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl, double sf, Color textColor) {
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(radius: 24 * context.sf, backgroundColor: color, backgroundImage: (logoUrl != null && logoUrl.isNotEmpty) ? NetworkImage(logoUrl) : null, child: (logoUrl == null || logoUrl.isEmpty) ? Icon(Icons.shield, color: Colors.white, size: 24 * context.sf) : null),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * context.sf), textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
CircleAvatar(
|
||||
radius: 24 * sf,
|
||||
backgroundColor: color,
|
||||
backgroundImage: (logoUrl != null && logoUrl.isNotEmpty) ? NetworkImage(logoUrl) : null,
|
||||
child: (logoUrl == null || logoUrl.isEmpty) ? Icon(Icons.shield, color: Colors.white, size: 24 * sf) : null,
|
||||
),
|
||||
SizedBox(height: 6 * sf),
|
||||
Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * sf, color: textColor), textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScoreCenter(BuildContext context, String id) {
|
||||
Widget _buildScoreCenter(BuildContext context, String id, double sf, Color textColor) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_scoreBox(context, myScore, Colors.green),
|
||||
Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22 * context.sf)),
|
||||
_scoreBox(context, opponentScore, Colors.grey),
|
||||
_scoreBox(myScore, AppTheme.successGreen, sf),
|
||||
Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22 * sf, color: textColor)),
|
||||
_scoreBox(opponentScore, Colors.grey, sf),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10 * context.sf),
|
||||
SizedBox(height: 10 * sf),
|
||||
TextButton.icon(
|
||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => PlacarPage(gameId: id, myTeam: myTeam, opponentTeam: opponentTeam))),
|
||||
icon: Icon(Icons.play_circle_fill, size: 18 * context.sf, color: const Color(0xFFE74C3C)),
|
||||
label: Text("RETORNAR", style: TextStyle(fontSize: 11 * context.sf, color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold)),
|
||||
style: TextButton.styleFrom(backgroundColor: const Color(0xFFE74C3C).withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 14 * context.sf, vertical: 8 * context.sf), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)), visualDensity: VisualDensity.compact),
|
||||
icon: Icon(Icons.play_circle_fill, size: 18 * sf, color: AppTheme.primaryRed),
|
||||
label: Text("RETORNAR", style: TextStyle(fontSize: 11 * sf, color: AppTheme.primaryRed, fontWeight: FontWeight.bold)),
|
||||
style: TextButton.styleFrom(backgroundColor: AppTheme.primaryRed.withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 14 * sf, vertical: 8 * sf), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * sf)), visualDensity: VisualDensity.compact),
|
||||
),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Text(status, style: TextStyle(fontSize: 12 * context.sf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6 * sf),
|
||||
Text(status, style: TextStyle(fontSize: 12 * sf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scoreBox(BuildContext context, String pts, Color c) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf, vertical: 6 * context.sf),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * context.sf)),
|
||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * context.sf)),
|
||||
Widget _scoreBox(String pts, Color c, double sf) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 6 * sf),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * sf)),
|
||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,8 +93,9 @@ class GameResultCard extends StatelessWidget {
|
||||
class CreateGameDialogManual extends StatefulWidget {
|
||||
final TeamController teamController;
|
||||
final GameController gameController;
|
||||
final double sf;
|
||||
|
||||
const CreateGameDialogManual({super.key, required this.teamController, required this.gameController});
|
||||
const CreateGameDialogManual({super.key, required this.teamController, required this.gameController, required this.sf});
|
||||
|
||||
@override
|
||||
State<CreateGameDialogManual> createState() => _CreateGameDialogManualState();
|
||||
@@ -105,24 +121,29 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||
title: Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * context.sf)),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * widget.sf)),
|
||||
title: Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * widget.sf, color: Theme.of(context).colorScheme.onSurface)),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(controller: _seasonController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * context.sf), border: const OutlineInputBorder(), prefixIcon: Icon(Icons.calendar_today, size: 20 * context.sf))),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
TextField(
|
||||
controller: _seasonController,
|
||||
style: TextStyle(fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||
decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * widget.sf), border: const OutlineInputBorder(), prefixIcon: Icon(Icons.calendar_today, size: 20 * widget.sf))
|
||||
),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
_buildSearch(context, "Minha Equipa", _myTeamController),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 10 * context.sf), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 16 * context.sf))),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 10 * widget.sf), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 16 * widget.sf))),
|
||||
_buildSearch(context, "Adversário", _opponentController),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('CANCELAR', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('CANCELAR', style: TextStyle(fontSize: 14 * widget.sf, color: Colors.grey))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * context.sf)), padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 10 * context.sf)),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primaryRed, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * widget.sf)), padding: EdgeInsets.symmetric(horizontal: 16 * widget.sf, vertical: 10 * widget.sf)),
|
||||
onPressed: _isLoading ? null : () async {
|
||||
if (_myTeamController.text.isNotEmpty && _opponentController.text.isNotEmpty) {
|
||||
setState(() => _isLoading = true);
|
||||
@@ -134,7 +155,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
}
|
||||
}
|
||||
},
|
||||
child: _isLoading ? SizedBox(width: 20 * context.sf, height: 20 * context.sf, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) : Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
child: _isLoading ? SizedBox(width: 20 * widget.sf, height: 20 * widget.sf, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) : Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * widget.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -156,9 +177,10 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4.0, borderRadius: BorderRadius.circular(8 * context.sf),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
elevation: 4.0, borderRadius: BorderRadius.circular(8 * widget.sf),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: 250 * context.sf, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
constraints: BoxConstraints(maxHeight: 250 * widget.sf, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero, shrinkWrap: true, itemCount: options.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
@@ -166,8 +188,8 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
final String name = option['name'].toString();
|
||||
final String? imageUrl = option['image_url'];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(radius: 20 * context.sf, backgroundColor: Colors.grey.shade200, backgroundImage: (imageUrl != null && imageUrl.isNotEmpty) ? NetworkImage(imageUrl) : null, child: (imageUrl == null || imageUrl.isEmpty) ? Icon(Icons.shield, color: Colors.grey, size: 20 * context.sf) : null),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
leading: CircleAvatar(radius: 20 * widget.sf, backgroundColor: Colors.grey.withOpacity(0.2), backgroundImage: (imageUrl != null && imageUrl.isNotEmpty) ? NetworkImage(imageUrl) : null, child: (imageUrl == null || imageUrl.isEmpty) ? Icon(Icons.shield, color: Colors.grey, size: 20 * widget.sf) : null),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface)),
|
||||
onTap: () { onSelected(option); },
|
||||
);
|
||||
},
|
||||
@@ -180,8 +202,9 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
if (txtCtrl.text.isEmpty && controller.text.isNotEmpty) txtCtrl.text = controller.text;
|
||||
txtCtrl.addListener(() { controller.text = txtCtrl.text; });
|
||||
return TextField(
|
||||
controller: txtCtrl, focusNode: node, style: TextStyle(fontSize: 14 * context.sf),
|
||||
decoration: InputDecoration(labelText: label, labelStyle: TextStyle(fontSize: 14 * context.sf), prefixIcon: Icon(Icons.search, size: 20 * context.sf), border: const OutlineInputBorder()),
|
||||
controller: txtCtrl, focusNode: node,
|
||||
style: TextStyle(fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||
decoration: InputDecoration(labelText: label, labelStyle: TextStyle(fontSize: 14 * widget.sf), prefixIcon: Icon(Icons.search, size: 20 * widget.sf, color: AppTheme.primaryRed)),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -209,16 +232,16 @@ class _GamePageState extends State<GamePage> {
|
||||
bool isFilterActive = selectedSeason != 'Todas' || selectedTeam != 'Todas';
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text("Jogos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 8.0 * context.sf),
|
||||
child: IconButton(
|
||||
icon: Icon(isFilterActive ? Icons.filter_list_alt : Icons.filter_list, color: isFilterActive ? const Color(0xFFE74C3C) : Colors.black87, size: 26 * context.sf),
|
||||
icon: Icon(isFilterActive ? Icons.filter_list_alt : Icons.filter_list, color: isFilterActive ? AppTheme.primaryRed : Theme.of(context).colorScheme.onSurface, size: 26 * context.sf),
|
||||
onPressed: () => _showFilterPopup(context),
|
||||
),
|
||||
)
|
||||
@@ -232,9 +255,9 @@ class _GamePageState extends State<GamePage> {
|
||||
stream: gameController.getFilteredGames(teamFilter: selectedTeam, seasonFilter: selectedSeason),
|
||||
builder: (context, gameSnapshot) {
|
||||
if (gameSnapshot.connectionState == ConnectionState.waiting && teamsList.isEmpty) return const Center(child: CircularProgressIndicator());
|
||||
if (gameSnapshot.hasError) return Center(child: Text("Erro: ${gameSnapshot.error}", style: TextStyle(fontSize: 14 * context.sf)));
|
||||
if (gameSnapshot.hasError) return Center(child: Text("Erro: ${gameSnapshot.error}", style: TextStyle(fontSize: 14 * context.sf, color: Theme.of(context).colorScheme.onSurface)));
|
||||
if (!gameSnapshot.hasData || gameSnapshot.data!.isEmpty) {
|
||||
return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.search_off, size: 48 * context.sf, color: Colors.grey.shade300), SizedBox(height: 10 * context.sf), Text("Nenhum jogo encontrado.", style: TextStyle(fontSize: 14 * context.sf, color: Colors.grey.shade600))]));
|
||||
return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.search_off, size: 48 * context.sf, color: Colors.grey.withOpacity(0.3)), SizedBox(height: 10 * context.sf), Text("Nenhum jogo encontrado.", style: TextStyle(fontSize: 14 * context.sf, color: Colors.grey))]));
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.all(16 * context.sf),
|
||||
@@ -249,6 +272,7 @@ class _GamePageState extends State<GamePage> {
|
||||
return GameResultCard(
|
||||
gameId: game.id, myTeam: game.myTeam, opponentTeam: game.opponentTeam, myScore: game.myScore,
|
||||
opponentScore: game.opponentScore, status: game.status, season: game.season, myTeamLogo: myLogo, opponentTeamLogo: oppLogo,
|
||||
sf: context.sf,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -257,10 +281,10 @@ class _GamePageState extends State<GamePage> {
|
||||
},
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'add_game_btn', // 👇 A MÁGICA ESTÁ AQUI TAMBÉM!
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
heroTag: 'add_game_btn',
|
||||
backgroundColor: AppTheme.primaryRed,
|
||||
child: Icon(Icons.add, color: Colors.white, size: 24 * context.sf),
|
||||
onPressed: () => showDialog(context: context, builder: (context) => CreateGameDialogManual(teamController: teamController, gameController: gameController)),
|
||||
onPressed: () => showDialog(context: context, builder: (context) => CreateGameDialogManual(teamController: teamController, gameController: gameController, sf: context.sf)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -274,34 +298,36 @@ class _GamePageState extends State<GamePage> {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setPopupState) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Filtrar Jogos', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * context.sf)),
|
||||
Text('Filtrar Jogos', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * context.sf, color: Theme.of(context).colorScheme.onSurface)),
|
||||
IconButton(icon: const Icon(Icons.close, color: Colors.grey), onPressed: () => Navigator.pop(context), padding: EdgeInsets.zero, constraints: const BoxConstraints())
|
||||
],
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Temporada", style: TextStyle(fontSize: 12 * context.sf, color: Colors.grey.shade600, fontWeight: FontWeight.bold)),
|
||||
Text("Temporada", style: TextStyle(fontSize: 12 * context.sf, color: Colors.grey, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf), decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(10 * context.sf)),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf), decoration: BoxDecoration(color: Theme.of(context).cardTheme.color, borderRadius: BorderRadius.circular(10 * context.sf), border: Border.all(color: Colors.grey.withOpacity(0.2))),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
isExpanded: true, value: tempSeason, style: TextStyle(fontSize: 14 * context.sf, color: Colors.black87, fontWeight: FontWeight.bold),
|
||||
dropdownColor: Theme.of(context).colorScheme.surface,
|
||||
isExpanded: true, value: tempSeason, style: TextStyle(fontSize: 14 * context.sf, color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold),
|
||||
items: ['Todas', '2024/25', '2025/26'].map((String value) => DropdownMenuItem<String>(value: value, child: Text(value))).toList(),
|
||||
onChanged: (newValue) => setPopupState(() => tempSeason = newValue!),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20 * context.sf),
|
||||
Text("Equipa", style: TextStyle(fontSize: 12 * context.sf, color: Colors.grey.shade600, fontWeight: FontWeight.bold)),
|
||||
Text("Equipa", style: TextStyle(fontSize: 12 * context.sf, color: Colors.grey, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf), decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(10 * context.sf)),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf), decoration: BoxDecoration(color: Theme.of(context).cardTheme.color, borderRadius: BorderRadius.circular(10 * context.sf), border: Border.all(color: Colors.grey.withOpacity(0.2))),
|
||||
child: StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
@@ -310,7 +336,8 @@ class _GamePageState extends State<GamePage> {
|
||||
if (!teamNames.contains(tempTeam)) tempTeam = 'Todas';
|
||||
return DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
isExpanded: true, value: tempTeam, style: TextStyle(fontSize: 14 * context.sf, color: Colors.black87, fontWeight: FontWeight.bold),
|
||||
dropdownColor: Theme.of(context).colorScheme.surface,
|
||||
isExpanded: true, value: tempTeam, style: TextStyle(fontSize: 14 * context.sf, color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold),
|
||||
items: teamNames.map((String value) => DropdownMenuItem<String>(value: value, child: Text(value, overflow: TextOverflow.ellipsis))).toList(),
|
||||
onChanged: (newValue) => setPopupState(() => tempTeam = newValue!),
|
||||
),
|
||||
@@ -322,7 +349,7 @@ class _GamePageState extends State<GamePage> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () { setState(() { selectedSeason = 'Todas'; selectedTeam = 'Todas'; }); Navigator.pop(context); }, child: Text('LIMPAR', style: TextStyle(fontSize: 12 * context.sf, color: Colors.grey))),
|
||||
ElevatedButton(style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * context.sf))), onPressed: () { setState(() { selectedSeason = tempSeason; selectedTeam = tempTeam; }); Navigator.pop(context); }, child: Text('APLICAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 13 * context.sf))),
|
||||
ElevatedButton(style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primaryRed, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * context.sf))), onPressed: () { setState(() { selectedSeason = tempSeason; selectedTeam = tempTeam; }); Navigator.pop(context); }, child: Text('APLICAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 13 * context.sf))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/classe/home.config.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import 'package:playmaker/grafico%20de%20pizza/grafico.dart';
|
||||
import 'package:playmaker/pages/gamePage.dart';
|
||||
import 'package:playmaker/pages/teamPage.dart';
|
||||
import 'package:playmaker/controllers/team_controller.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:playmaker/pages/status_page.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
import 'package:playmaker/grafico%20de%20pizza/controllers/contollers_grafico.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
import 'settings_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
@@ -30,24 +30,28 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Já não precisamos calcular o sf aqui!
|
||||
|
||||
final List<Widget> pages = [
|
||||
_buildHomeContent(context), // Passamos só o context
|
||||
_buildHomeContent(context),
|
||||
const GamePage(),
|
||||
const TeamsPage(),
|
||||
const StatusPage(),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // Fundo dinâmico
|
||||
appBar: AppBar(
|
||||
title: Text('PlayMaker', style: TextStyle(fontSize: 20 * context.sf)),
|
||||
backgroundColor: HomeConfig.primaryColor,
|
||||
backgroundColor: AppTheme.primaryRed,
|
||||
foregroundColor: Colors.white,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.person, size: 24 * context.sf),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
// 👇 MAGIA ACONTECE AQUI 👇
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const SettingsScreen()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -62,7 +66,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
|
||||
elevation: 1,
|
||||
// O math.min não é necessário se já tens o sf. Mas podes usar context.sf
|
||||
height: 70 * (context.sf < 1.2 ? context.sf : 1.2),
|
||||
destinations: const [
|
||||
NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home_filled), label: 'Home'),
|
||||
@@ -77,13 +80,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
void _showTeamSelector(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface, // Fundo dinâmico
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20 * context.sf))),
|
||||
builder: (context) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: _teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return const SizedBox(height: 200, child: Center(child: CircularProgressIndicator()));
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return SizedBox(height: 200 * context.sf, child: const Center(child: Text("Nenhuma equipa criada.")));
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return SizedBox(height: 200 * context.sf, child: Center(child: Text("Nenhuma equipa criada.", style: TextStyle(color: Theme.of(context).colorScheme.onSurface))));
|
||||
|
||||
final teams = snapshot.data!;
|
||||
return ListView.builder(
|
||||
@@ -92,7 +96,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
final team = teams[index];
|
||||
return ListTile(
|
||||
title: Text(team['name']),
|
||||
title: Text(team['name'], style: TextStyle(color: Theme.of(context).colorScheme.onSurface)), // Texto dinâmico
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedTeamId = team['id'];
|
||||
@@ -115,6 +119,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget _buildHomeContent(BuildContext context) {
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double cardHeight = wScreen * 0.5;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: _selectedTeamId != null
|
||||
@@ -133,12 +138,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
onTap: () => _showTeamSelector(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(12 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(15 * context.sf), border: Border.all(color: Colors.grey.shade300)),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardTheme.color,
|
||||
borderRadius: BorderRadius.circular(15 * context.sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.2))
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [Icon(Icons.shield, color: HomeConfig.primaryColor, size: 24 * context.sf), SizedBox(width: 10 * context.sf), Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold))]),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
Row(children: [
|
||||
Icon(Icons.shield, color: AppTheme.primaryRed, size: 24 * context.sf),
|
||||
SizedBox(width: 10 * context.sf),
|
||||
Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold, color: textColor))
|
||||
]),
|
||||
Icon(Icons.arrow_drop_down, color: textColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -149,9 +162,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
height: cardHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Mais Pontos', playerName: leaders['pts_name'], statValue: leaders['pts_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF1565C0), isHighlighted: true)),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Mais Pontos', playerName: leaders['pts_name'], statValue: leaders['pts_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statPtsBg, isHighlighted: true)),
|
||||
SizedBox(width: 12 * context.sf),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Assistências', playerName: leaders['ast_name'], statValue: leaders['ast_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF2E7D32))),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Assistências', playerName: leaders['ast_name'], statValue: leaders['ast_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statAstBg)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -161,7 +174,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
height: cardHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Rebotes', playerName: leaders['rbs_name'], statValue: leaders['rbs_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF6A1B9A))),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Rebotes', playerName: leaders['rbs_name'], statValue: leaders['rbs_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statRebBg)),
|
||||
SizedBox(width: 12 * context.sf),
|
||||
Expanded(
|
||||
child: PieChartCard(
|
||||
@@ -170,8 +183,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
draws: _teamDraws,
|
||||
title: 'DESEMPENHO',
|
||||
subtitle: 'Temporada',
|
||||
backgroundColor: const Color(0xFFC62828),
|
||||
sf: context.sf // Aqui o PieChartCard ainda usa sf, então passamos
|
||||
backgroundColor: AppTheme.statPieBg,
|
||||
sf: context.sf
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -179,7 +192,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
SizedBox(height: 40 * context.sf),
|
||||
|
||||
Text('Histórico de Jogos', style: TextStyle(fontSize: 20 * context.sf, fontWeight: FontWeight.bold, color: Colors.grey[800])),
|
||||
Text('Histórico de Jogos', style: TextStyle(fontSize: 20 * context.sf, fontWeight: FontWeight.bold, color: textColor)),
|
||||
SizedBox(height: 16 * context.sf),
|
||||
|
||||
_selectedTeamName == "Selecionar Equipa"
|
||||
@@ -192,7 +205,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
stream: _supabase.from('games').stream(primaryKey: ['id'])
|
||||
.order('game_date', ascending: false),
|
||||
builder: (context, gameSnapshot) {
|
||||
|
||||
if (gameSnapshot.hasError) return Text("Erro: ${gameSnapshot.error}", style: const TextStyle(color: Colors.red));
|
||||
if (gameSnapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
||||
|
||||
@@ -207,9 +219,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (gamesList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: BorderRadius.circular(14)),
|
||||
decoration: BoxDecoration(color: Theme.of(context).cardTheme.color, borderRadius: BorderRadius.circular(14)),
|
||||
alignment: Alignment.center,
|
||||
child: Text("Ainda não há jogos terminados para $_selectedTeamName.", style: TextStyle(color: Colors.grey)),
|
||||
child: const Text("Ainda não há jogos terminados.", style: TextStyle(color: Colors.grey)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -236,7 +248,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (myScore < oppScore) result = 'D';
|
||||
|
||||
return _buildGameHistoryCard(
|
||||
context: context, // Usamos o context para o sf
|
||||
context: context,
|
||||
opponent: opponent,
|
||||
result: result,
|
||||
myScore: myScore,
|
||||
@@ -252,7 +264,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
SizedBox(height: 20 * context.sf),
|
||||
],
|
||||
),
|
||||
@@ -280,14 +291,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget _buildStatCard({required BuildContext context, required String title, required String playerName, required String statValue, required String statLabel, required Color color, bool isHighlighted = false}) {
|
||||
return Card(
|
||||
elevation: 4, margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14), side: isHighlighted ? const BorderSide(color: Colors.amber, width: 2) : BorderSide.none),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14), side: isHighlighted ? const BorderSide(color: AppTheme.warningAmber, width: 2) : BorderSide.none),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [color.withOpacity(0.9), color])),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final double ch = constraints.maxHeight;
|
||||
final double cw = constraints.maxWidth;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(cw * 0.06),
|
||||
child: Column(
|
||||
@@ -327,13 +337,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}) {
|
||||
bool isWin = result == 'V';
|
||||
bool isDraw = result == 'E';
|
||||
Color statusColor = isWin ? Colors.green : (isDraw ? Colors.yellow.shade700 : Colors.red);
|
||||
Color statusColor = isWin ? AppTheme.successGreen : (isDraw ? AppTheme.warningAmber : AppTheme.oppTeamRed);
|
||||
final bgColor = Theme.of(context).cardTheme.color;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 14 * context.sf),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.grey.shade200), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 4))],
|
||||
color: bgColor, borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 4))],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -356,16 +368,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: Text(_selectedTeamName == "Selecionar Equipa" ? "Minha Equipa" : _selectedTeamName, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold), maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Expanded(child: Text(_selectedTeamName == "Selecionar Equipa" ? "Minha Equipa" : _selectedTeamName, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold, color: textColor), maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('$myScore - $oppScore', style: TextStyle(fontSize: 15 * context.sf, fontWeight: FontWeight.w900, letterSpacing: 1.5, color: Colors.black87)),
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withOpacity(0.05), borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('$myScore - $oppScore', style: TextStyle(fontSize: 15 * context.sf, fontWeight: FontWeight.w900, letterSpacing: 1.5, color: textColor)),
|
||||
),
|
||||
),
|
||||
Expanded(child: Text(opponent, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold), textAlign: TextAlign.right, maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Expanded(child: Text(opponent, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold, color: textColor), textAlign: TextAlign.right, maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -374,10 +386,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(height: 1, color: Colors.grey.shade100, thickness: 1.5),
|
||||
Divider(height: 1, color: Colors.grey.withOpacity(0.1), thickness: 1.5),
|
||||
Container(
|
||||
width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 12 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(16), bottomRight: Radius.circular(16))),
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(16), bottomRight: Radius.circular(16))),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
@@ -413,13 +425,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
children: [
|
||||
Icon(icon, size: 14 * context.sf, color: color),
|
||||
SizedBox(width: 4 * context.sf),
|
||||
Text('$label: ', style: TextStyle(fontSize: 11 * context.sf, color: Colors.grey.shade600, fontWeight: FontWeight.bold)),
|
||||
Text('$label: ', style: TextStyle(fontSize: 11 * context.sf, color: Colors.grey, fontWeight: FontWeight.bold)),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 11 * context.sf,
|
||||
color: isMvp ? Colors.amber.shade900 : Colors.black87,
|
||||
color: isMvp ? AppTheme.warningAmber : Theme.of(context).colorScheme.onSurface,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/controllers/login_controller.dart';
|
||||
import '../widgets/login_widgets.dart';
|
||||
import 'home.dart'; // <--- IMPORTANTE: Importa a tua HomeScreen
|
||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||
import 'home.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
@@ -23,7 +23,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
// 👇 Adaptável ao Modo Claro/Escuro do Flutter
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
body: SafeArea(
|
||||
child: ListenableBuilder(
|
||||
listenable: controller,
|
||||
@@ -32,7 +33,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
// Garante que o form não fica gigante num tablet
|
||||
constraints: BoxConstraints(maxWidth: 450 * context.sf),
|
||||
padding: EdgeInsets.all(32 * context.sf),
|
||||
child: Column(
|
||||
|
||||
250
lib/pages/settings_screen.dart
Normal file
250
lib/pages/settings_screen.dart
Normal file
@@ -0,0 +1,250 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
import 'login.dart';
|
||||
|
||||
// 👇 OBRIGATÓRIO IMPORTAR O MAIN.DART PARA LER A VARIÁVEL "themeNotifier"
|
||||
import '../main.dart';
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 👇 CORES DINÂMICAS (A MÁGICA DO MODO ESCURO)
|
||||
final Color primaryRed = AppTheme.primaryRed;
|
||||
final Color bgColor = Theme.of(context).scaffoldBackgroundColor;
|
||||
final Color cardColor = Theme.of(context).cardTheme.color ?? Theme.of(context).colorScheme.surface;
|
||||
final Color textColor = Theme.of(context).colorScheme.onSurface;
|
||||
final Color textLightColor = textColor.withOpacity(0.6);
|
||||
|
||||
// 👇 SABER SE A APP ESTÁ ESCURA OU CLARA NESTE EXATO MOMENTO
|
||||
bool isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: bgColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryRed,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
"Perfil e Definições",
|
||||
style: TextStyle(
|
||||
fontSize: 18 * context.sf,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0 * context.sf, vertical: 24.0 * context.sf),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ==========================================
|
||||
// CARTÃO DE PERFIL
|
||||
// ==========================================
|
||||
Container(
|
||||
padding: EdgeInsets.all(20 * context.sf),
|
||||
decoration: BoxDecoration(
|
||||
color: cardColor,
|
||||
borderRadius: BorderRadius.circular(16 * context.sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 32 * context.sf,
|
||||
backgroundColor: primaryRed.withOpacity(0.1),
|
||||
child: Icon(Icons.person, color: primaryRed, size: 32 * context.sf),
|
||||
),
|
||||
SizedBox(width: 16 * context.sf),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Treinador",
|
||||
style: TextStyle(
|
||||
fontSize: 18 * context.sf,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4 * context.sf),
|
||||
Text(
|
||||
Supabase.instance.client.auth.currentUser?.email ?? "sem@email.com",
|
||||
style: TextStyle(
|
||||
color: textLightColor,
|
||||
fontSize: 14 * context.sf,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 32 * context.sf),
|
||||
|
||||
// ==========================================
|
||||
// SECÇÃO: DEFINIÇÕES
|
||||
// ==========================================
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 4 * context.sf, bottom: 12 * context.sf),
|
||||
child: Text(
|
||||
"Definições",
|
||||
style: TextStyle(
|
||||
color: textLightColor,
|
||||
fontSize: 14 * context.sf,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: cardColor,
|
||||
borderRadius: BorderRadius.circular(16 * context.sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 20 * context.sf, vertical: 8 * context.sf),
|
||||
leading: Icon(isDark ? Icons.dark_mode : Icons.light_mode, color: primaryRed, size: 28 * context.sf),
|
||||
title: Text(
|
||||
"Modo Escuro",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, color: textColor, fontSize: 16 * context.sf),
|
||||
),
|
||||
subtitle: Text(
|
||||
"Altera as cores da aplicação",
|
||||
style: TextStyle(color: textLightColor, fontSize: 13 * context.sf),
|
||||
),
|
||||
trailing: Switch(
|
||||
value: isDark,
|
||||
activeColor: primaryRed,
|
||||
onChanged: (bool value) {
|
||||
// 👇 CHAMA A VARIÁVEL DO MAIN.DART E ATUALIZA A APP TODA
|
||||
themeNotifier.value = value ? ThemeMode.dark : ThemeMode.light;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 32 * context.sf),
|
||||
|
||||
// ==========================================
|
||||
// SECÇÃO: CONTA
|
||||
// ==========================================
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 4 * context.sf, bottom: 12 * context.sf),
|
||||
child: Text(
|
||||
"Conta",
|
||||
style: TextStyle(
|
||||
color: textLightColor,
|
||||
fontSize: 14 * context.sf,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: cardColor,
|
||||
borderRadius: BorderRadius.circular(16 * context.sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 20 * context.sf, vertical: 4 * context.sf),
|
||||
leading: Icon(Icons.logout_outlined, color: primaryRed, size: 26 * context.sf),
|
||||
title: Text(
|
||||
"Terminar Sessão",
|
||||
style: TextStyle(
|
||||
color: primaryRed,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15 * context.sf,
|
||||
),
|
||||
),
|
||||
onTap: () => _confirmLogout(context), // 👇 CHAMA O LOGOUT REAL
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 50 * context.sf),
|
||||
|
||||
// ==========================================
|
||||
// VERSÃO DA APP
|
||||
// ==========================================
|
||||
Center(
|
||||
child: Text(
|
||||
"PlayMaker v1.0.0",
|
||||
style: TextStyle(
|
||||
color: textLightColor.withOpacity(0.7),
|
||||
fontSize: 13 * context.sf,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20 * context.sf),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 👇 FUNÇÃO PARA FAZER LOGOUT
|
||||
void _confirmLogout(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
title: Text("Terminar Sessão", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||
content: Text("Tens a certeza que queres sair da conta?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text("Cancelar", style: TextStyle(color: Colors.grey))),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await Supabase.instance.client.auth.signOut();
|
||||
if (ctx.mounted) {
|
||||
// Mata a navegação toda para trás e manda para o Login
|
||||
Navigator.of(ctx).pushAndRemoveUntil(
|
||||
MaterialPageRoute(builder: (context) => const LoginPage()),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text("Sair", style: TextStyle(color: AppTheme.primaryRed, fontWeight: FontWeight.bold))
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 A MAGIA DO SF!
|
||||
import '../utils/size_extension.dart';
|
||||
|
||||
class StatusPage extends StatefulWidget {
|
||||
const StatusPage({super.key});
|
||||
@@ -21,6 +22,9 @@ class _StatusPageState extends State<StatusPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bgColor = Theme.of(context).cardTheme.color ?? Colors.white;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
@@ -30,20 +34,20 @@ class _StatusPageState extends State<StatusPage> {
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(12 * context.sf),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(15 * context.sf),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.2)),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 5)]
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [
|
||||
Icon(Icons.shield, color: const Color(0xFFE74C3C), size: 24 * context.sf),
|
||||
Icon(Icons.shield, color: AppTheme.primaryRed, size: 24 * context.sf),
|
||||
SizedBox(width: 10 * context.sf),
|
||||
Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold))
|
||||
Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold, color: textColor))
|
||||
]),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
Icon(Icons.arrow_drop_down, color: textColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -63,7 +67,7 @@ class _StatusPageState extends State<StatusPage> {
|
||||
stream: _supabase.from('members').stream(primaryKey: ['id']).eq('team_id', _selectedTeamId!),
|
||||
builder: (context, membersSnapshot) {
|
||||
if (statsSnapshot.connectionState == ConnectionState.waiting || gamesSnapshot.connectionState == ConnectionState.waiting || membersSnapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator(color: Color(0xFFE74C3C)));
|
||||
return Center(child: CircularProgressIndicator(color: AppTheme.primaryRed));
|
||||
}
|
||||
|
||||
final membersData = membersSnapshot.data ?? [];
|
||||
@@ -82,7 +86,7 @@ class _StatusPageState extends State<StatusPage> {
|
||||
return _isAscending ? valA.compareTo(valB) : valB.compareTo(valA);
|
||||
});
|
||||
|
||||
return _buildStatsGrid(context, playerTotals, teamTotals);
|
||||
return _buildStatsGrid(context, playerTotals, teamTotals, bgColor, textColor);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -96,12 +100,10 @@ class _StatusPageState extends State<StatusPage> {
|
||||
|
||||
List<Map<String, dynamic>> _aggregateStats(List<dynamic> stats, List<dynamic> games, List<dynamic> members) {
|
||||
Map<String, Map<String, dynamic>> aggregated = {};
|
||||
|
||||
for (var member in members) {
|
||||
String name = member['name']?.toString() ?? "Desconhecido";
|
||||
aggregated[name] = {'name': name, 'j': 0, 'pts': 0, 'ast': 0, 'rbs': 0, 'stl': 0, 'blk': 0, 'mvp': 0, 'def': 0};
|
||||
}
|
||||
|
||||
for (var row in stats) {
|
||||
String name = row['player_name']?.toString() ?? "Desconhecido";
|
||||
if (!aggregated.containsKey(name)) aggregated[name] = {'name': name, 'j': 0, 'pts': 0, 'ast': 0, 'rbs': 0, 'stl': 0, 'blk': 0, 'mvp': 0, 'def': 0};
|
||||
@@ -113,7 +115,6 @@ class _StatusPageState extends State<StatusPage> {
|
||||
aggregated[name]!['stl'] += (row['stl'] ?? 0);
|
||||
aggregated[name]!['blk'] += (row['blk'] ?? 0);
|
||||
}
|
||||
|
||||
for (var game in games) {
|
||||
String? mvp = game['mvp_name'];
|
||||
String? defRaw = game['top_def_name'];
|
||||
@@ -134,52 +135,53 @@ class _StatusPageState extends State<StatusPage> {
|
||||
return {'name': 'TOTAL EQUIPA', 'j': teamGames, 'pts': tPts, 'ast': tAst, 'rbs': tRbs, 'stl': tStl, 'blk': tBlk, 'mvp': tMvp, 'def': tDef};
|
||||
}
|
||||
|
||||
Widget _buildStatsGrid(BuildContext context, List<Map<String, dynamic>> players, Map<String, dynamic> teamTotals) {
|
||||
Widget _buildStatsGrid(BuildContext context, List<Map<String, dynamic>> players, Map<String, dynamic> teamTotals, Color bgColor, Color textColor) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
color: Colors.transparent,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: DataTable(
|
||||
columnSpacing: 25 * context.sf,
|
||||
headingRowColor: MaterialStateProperty.all(Colors.grey.shade100),
|
||||
dataRowHeight: 60 * context.sf,
|
||||
headingRowColor: WidgetStateProperty.all(Theme.of(context).colorScheme.surface),
|
||||
dataRowMaxHeight: 60 * context.sf,
|
||||
dataRowMinHeight: 60 * context.sf,
|
||||
columns: [
|
||||
DataColumn(label: const Text('JOGADOR')),
|
||||
_buildSortableColumn(context, 'J', 'j'),
|
||||
_buildSortableColumn(context, 'PTS', 'pts'),
|
||||
_buildSortableColumn(context, 'AST', 'ast'),
|
||||
_buildSortableColumn(context, 'RBS', 'rbs'),
|
||||
_buildSortableColumn(context, 'STL', 'stl'),
|
||||
_buildSortableColumn(context, 'BLK', 'blk'),
|
||||
_buildSortableColumn(context, 'DEF 🛡️', 'def'),
|
||||
_buildSortableColumn(context, 'MVP 🏆', 'mvp'),
|
||||
DataColumn(label: Text('JOGADOR', style: TextStyle(color: textColor))),
|
||||
_buildSortableColumn(context, 'J', 'j', textColor),
|
||||
_buildSortableColumn(context, 'PTS', 'pts', textColor),
|
||||
_buildSortableColumn(context, 'AST', 'ast', textColor),
|
||||
_buildSortableColumn(context, 'RBS', 'rbs', textColor),
|
||||
_buildSortableColumn(context, 'STL', 'stl', textColor),
|
||||
_buildSortableColumn(context, 'BLK', 'blk', textColor),
|
||||
_buildSortableColumn(context, 'DEF 🛡️', 'def', textColor),
|
||||
_buildSortableColumn(context, 'MVP 🏆', 'mvp', textColor),
|
||||
],
|
||||
rows: [
|
||||
...players.map((player) => DataRow(cells: [
|
||||
DataCell(Row(children: [CircleAvatar(radius: 15 * context.sf, backgroundColor: Colors.grey.shade200, child: Icon(Icons.person, size: 18 * context.sf)), SizedBox(width: 10 * context.sf), Text(player['name'], style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * context.sf))])),
|
||||
DataCell(Center(child: Text(player['j'].toString()))),
|
||||
_buildStatCell(context, player['pts'], isHighlight: true),
|
||||
_buildStatCell(context, player['ast']),
|
||||
_buildStatCell(context, player['rbs']),
|
||||
_buildStatCell(context, player['stl']),
|
||||
_buildStatCell(context, player['blk']),
|
||||
_buildStatCell(context, player['def'], isBlue: true),
|
||||
_buildStatCell(context, player['mvp'], isGold: true),
|
||||
DataCell(Row(children: [CircleAvatar(radius: 15 * context.sf, backgroundColor: Colors.grey.withOpacity(0.2), child: Icon(Icons.person, size: 18 * context.sf, color: Colors.grey)), SizedBox(width: 10 * context.sf), Text(player['name'], style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * context.sf, color: textColor))])),
|
||||
DataCell(Center(child: Text(player['j'].toString(), style: TextStyle(color: textColor)))),
|
||||
_buildStatCell(context, player['pts'], textColor, isHighlight: true),
|
||||
_buildStatCell(context, player['ast'], textColor),
|
||||
_buildStatCell(context, player['rbs'], textColor),
|
||||
_buildStatCell(context, player['stl'], textColor),
|
||||
_buildStatCell(context, player['blk'], textColor),
|
||||
_buildStatCell(context, player['def'], textColor, isBlue: true),
|
||||
_buildStatCell(context, player['mvp'], textColor, isGold: true),
|
||||
])),
|
||||
DataRow(
|
||||
color: MaterialStateProperty.all(Colors.grey.shade50),
|
||||
color: WidgetStateProperty.all(Theme.of(context).colorScheme.surface.withOpacity(0.5)),
|
||||
cells: [
|
||||
DataCell(Text('TOTAL EQUIPA', style: TextStyle(fontWeight: FontWeight.w900, color: Colors.black, fontSize: 12 * context.sf))),
|
||||
DataCell(Center(child: Text(teamTotals['j'].toString(), style: const TextStyle(fontWeight: FontWeight.bold)))),
|
||||
_buildStatCell(context, teamTotals['pts'], isHighlight: true),
|
||||
_buildStatCell(context, teamTotals['ast']),
|
||||
_buildStatCell(context, teamTotals['rbs']),
|
||||
_buildStatCell(context, teamTotals['stl']),
|
||||
_buildStatCell(context, teamTotals['blk']),
|
||||
_buildStatCell(context, teamTotals['def'], isBlue: true),
|
||||
_buildStatCell(context, teamTotals['mvp'], isGold: true),
|
||||
DataCell(Text('TOTAL EQUIPA', style: TextStyle(fontWeight: FontWeight.w900, color: textColor, fontSize: 12 * context.sf))),
|
||||
DataCell(Center(child: Text(teamTotals['j'].toString(), style: TextStyle(fontWeight: FontWeight.bold, color: textColor)))),
|
||||
_buildStatCell(context, teamTotals['pts'], textColor, isHighlight: true),
|
||||
_buildStatCell(context, teamTotals['ast'], textColor),
|
||||
_buildStatCell(context, teamTotals['rbs'], textColor),
|
||||
_buildStatCell(context, teamTotals['stl'], textColor),
|
||||
_buildStatCell(context, teamTotals['blk'], textColor),
|
||||
_buildStatCell(context, teamTotals['def'], textColor, isBlue: true),
|
||||
_buildStatCell(context, teamTotals['mvp'], textColor, isGold: true),
|
||||
]
|
||||
)
|
||||
],
|
||||
@@ -189,37 +191,37 @@ class _StatusPageState extends State<StatusPage> {
|
||||
);
|
||||
}
|
||||
|
||||
DataColumn _buildSortableColumn(BuildContext context, String title, String sortKey) {
|
||||
DataColumn _buildSortableColumn(BuildContext context, String title, String sortKey, Color textColor) {
|
||||
return DataColumn(label: InkWell(
|
||||
onTap: () => setState(() {
|
||||
if (_sortColumn == sortKey) _isAscending = !_isAscending;
|
||||
else { _sortColumn = sortKey; _isAscending = false; }
|
||||
}),
|
||||
child: Row(children: [
|
||||
Text(title, style: TextStyle(fontSize: 12 * context.sf, fontWeight: FontWeight.bold)),
|
||||
if (_sortColumn == sortKey) Icon(_isAscending ? Icons.arrow_drop_up : Icons.arrow_drop_down, size: 18 * context.sf, color: const Color(0xFFE74C3C)),
|
||||
Text(title, style: TextStyle(fontSize: 12 * context.sf, fontWeight: FontWeight.bold, color: textColor)),
|
||||
if (_sortColumn == sortKey) Icon(_isAscending ? Icons.arrow_drop_up : Icons.arrow_drop_down, size: 18 * context.sf, color: AppTheme.primaryRed),
|
||||
]),
|
||||
));
|
||||
}
|
||||
|
||||
DataCell _buildStatCell(BuildContext context, int value, {bool isHighlight = false, bool isGold = false, bool isBlue = false}) {
|
||||
DataCell _buildStatCell(BuildContext context, int value, Color textColor, {bool isHighlight = false, bool isGold = false, bool isBlue = false}) {
|
||||
return DataCell(Center(child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
||||
decoration: BoxDecoration(color: isGold && value > 0 ? Colors.amber.withOpacity(0.2) : (isBlue && value > 0 ? Colors.blue.withOpacity(0.1) : Colors.transparent), borderRadius: BorderRadius.circular(6)),
|
||||
child: Text(value == 0 ? "-" : value.toString(), style: TextStyle(
|
||||
fontWeight: (isHighlight || isGold || isBlue) ? FontWeight.w900 : FontWeight.w600,
|
||||
fontSize: 14 * context.sf, color: isGold && value > 0 ? Colors.orange.shade900 : (isBlue && value > 0 ? Colors.blue.shade800 : (isHighlight ? Colors.green.shade700 : Colors.black87))
|
||||
fontSize: 14 * context.sf, color: isGold && value > 0 ? Colors.orange.shade900 : (isBlue && value > 0 ? Colors.blue.shade800 : (isHighlight ? AppTheme.successGreen : textColor))
|
||||
)),
|
||||
)));
|
||||
}
|
||||
|
||||
void _showTeamSelector(BuildContext context) {
|
||||
showModalBottomSheet(context: context, builder: (context) => StreamBuilder<List<Map<String, dynamic>>>(
|
||||
showModalBottomSheet(context: context, backgroundColor: Theme.of(context).colorScheme.surface, builder: (context) => StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: _teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
final teams = snapshot.data ?? [];
|
||||
return ListView.builder(itemCount: teams.length, itemBuilder: (context, i) => ListTile(
|
||||
title: Text(teams[i]['name']),
|
||||
title: Text(teams[i]['name'], style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||
onTap: () { setState(() { _selectedTeamId = teams[i]['id']; _selectedTeamName = teams[i]['name']; }); Navigator.pop(context); },
|
||||
));
|
||||
},
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/screens/team_stats_page.dart';
|
||||
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../models/team_model.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 IMPORTANTE: O TEU NOVO SUPERPODER
|
||||
import '../utils/size_extension.dart';
|
||||
|
||||
class TeamsPage extends StatefulWidget {
|
||||
const TeamsPage({super.key});
|
||||
@@ -32,14 +33,14 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setModalState) {
|
||||
return AlertDialog(
|
||||
backgroundColor: const Color(0xFF2C3E50),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Filtros de pesquisa", style: TextStyle(color: Colors.white, fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
Text("Filtros de pesquisa", style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close, color: Colors.white, size: 20 * context.sf),
|
||||
icon: Icon(Icons.close, color: Colors.grey, size: 20 * context.sf),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
)
|
||||
],
|
||||
@@ -47,7 +48,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Divider(color: Colors.white24),
|
||||
Divider(color: Colors.grey.withOpacity(0.2)),
|
||||
SizedBox(height: 16 * context.sf),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -82,7 +83,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text("CONCLUÍDO", style: TextStyle(color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
child: Text("CONCLUÍDO", style: TextStyle(color: AppTheme.primaryRed, fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -107,7 +108,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
child: Text(
|
||||
opt,
|
||||
style: TextStyle(
|
||||
color: isSelected ? const Color(0xFFE74C3C) : Colors.white70,
|
||||
color: isSelected ? AppTheme.primaryRed : Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontSize: 14 * context.sf,
|
||||
),
|
||||
@@ -121,16 +122,15 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 🔥 OLHA QUE LIMPEZA: Já não precisamos de calcular nada aqui!
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text("Minhas Equipas", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.filter_list, color: const Color(0xFFE74C3C), size: 24 * context.sf),
|
||||
icon: Icon(Icons.filter_list, color: AppTheme.primaryRed, size: 24 * context.sf),
|
||||
onPressed: () => _showFilterDialog(context),
|
||||
),
|
||||
],
|
||||
@@ -142,8 +142,8 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'add_team_btn', // 👇 A MÁGICA ESTÁ AQUI!
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
heroTag: 'add_team_btn',
|
||||
backgroundColor: AppTheme.primaryRed,
|
||||
child: Icon(Icons.add, color: Colors.white, size: 24 * context.sf),
|
||||
onPressed: () => _showCreateDialog(context),
|
||||
),
|
||||
@@ -156,13 +156,13 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (v) => setState(() => _searchQuery = v.toLowerCase()),
|
||||
style: TextStyle(fontSize: 16 * context.sf),
|
||||
style: TextStyle(fontSize: 16 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Pesquisar equipa...',
|
||||
hintStyle: TextStyle(fontSize: 16 * context.sf),
|
||||
prefixIcon: Icon(Icons.search, color: const Color(0xFFE74C3C), size: 22 * context.sf),
|
||||
hintStyle: TextStyle(fontSize: 16 * context.sf, color: Colors.grey),
|
||||
prefixIcon: Icon(Icons.search, color: AppTheme.primaryRed, size: 22 * context.sf),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
fillColor: Theme.of(context).colorScheme.surface, // 👇 Adapta-se ao Dark Mode
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15 * context.sf), borderSide: BorderSide.none),
|
||||
),
|
||||
),
|
||||
@@ -173,8 +173,8 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: controller.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return Center(child: Text("Nenhuma equipa encontrada.", style: TextStyle(fontSize: 16 * context.sf)));
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return Center(child: CircularProgressIndicator(color: AppTheme.primaryRed));
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return Center(child: Text("Nenhuma equipa encontrada.", style: TextStyle(fontSize: 16 * context.sf, color: Theme.of(context).colorScheme.onSurface)));
|
||||
|
||||
var data = List<Map<String, dynamic>>.from(snapshot.data!);
|
||||
|
||||
@@ -201,6 +201,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
team: team,
|
||||
controller: controller,
|
||||
onFavoriteTap: () => controller.toggleFavorite(team.id, team.isFavorite),
|
||||
sf: context.sf,
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -210,7 +211,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
}
|
||||
|
||||
void _showCreateDialog(BuildContext context) {
|
||||
showDialog(context: context, builder: (context) => CreateTeamDialog(onConfirm: (name, season, imageUrl) => controller.createTeam(name, season, imageUrl)));
|
||||
showDialog(context: context, builder: (context) => CreateTeamDialog(sf: context.sf, onConfirm: (name, season, imageUrl) => controller.createTeam(name, season, imageUrl)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,73 +220,140 @@ class TeamCard extends StatelessWidget {
|
||||
final Team team;
|
||||
final TeamController controller;
|
||||
final VoidCallback onFavoriteTap;
|
||||
final double sf;
|
||||
|
||||
const TeamCard({super.key, required this.team, required this.controller, required this.onFavoriteTap});
|
||||
const TeamCard({
|
||||
super.key,
|
||||
required this.team,
|
||||
required this.controller,
|
||||
required this.onFavoriteTap,
|
||||
required this.sf,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: Colors.white, elevation: 3, margin: EdgeInsets.only(bottom: 12 * context.sf),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 8 * context.sf),
|
||||
leading: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 28 * context.sf, backgroundColor: Colors.grey[200],
|
||||
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http')) ? NetworkImage(team.imageUrl) : null,
|
||||
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http')) ? Text(team.imageUrl.isEmpty ? "🏀" : team.imageUrl, style: TextStyle(fontSize: 24 * context.sf)) : null,
|
||||
),
|
||||
Positioned(
|
||||
left: -15 * context.sf, top: -10 * context.sf,
|
||||
child: IconButton(
|
||||
icon: Icon(team.isFavorite ? Icons.star : Icons.star_border, color: team.isFavorite ? Colors.amber : Colors.black.withOpacity(0.1), size: 28 * context.sf, shadows: [Shadow(color: Colors.black.withOpacity(team.isFavorite ? 0.3 : 0.1), blurRadius: 4 * context.sf)]),
|
||||
onPressed: onFavoriteTap,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(team.name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * context.sf), overflow: TextOverflow.ellipsis),
|
||||
subtitle: Padding(
|
||||
padding: EdgeInsets.only(top: 6.0 * context.sf),
|
||||
child: Row(
|
||||
final bgColor = Theme.of(context).cardTheme.color ?? Theme.of(context).colorScheme.surface;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 12 * sf),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(15 * sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10 * sf)]
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(15 * sf),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16 * sf, vertical: 8 * sf),
|
||||
leading: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Icon(Icons.groups_outlined, size: 16 * context.sf, color: Colors.grey),
|
||||
SizedBox(width: 4 * context.sf),
|
||||
StreamBuilder<int>(
|
||||
stream: controller.getPlayerCountStream(team.id),
|
||||
initialData: 0,
|
||||
builder: (context, snapshot) {
|
||||
final count = snapshot.data ?? 0;
|
||||
return Text("$count Jogs.", style: TextStyle(color: count > 0 ? Colors.green[700] : Colors.orange, fontWeight: FontWeight.bold, fontSize: 13 * context.sf));
|
||||
},
|
||||
CircleAvatar(
|
||||
radius: 28 * sf,
|
||||
backgroundColor: Colors.grey.withOpacity(0.2),
|
||||
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
|
||||
? NetworkImage(team.imageUrl)
|
||||
: null,
|
||||
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
|
||||
? Text(
|
||||
team.imageUrl.isEmpty ? "🏀" : team.imageUrl,
|
||||
style: TextStyle(fontSize: 24 * sf),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
Positioned(
|
||||
left: -15 * sf,
|
||||
top: -10 * sf,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
team.isFavorite ? Icons.star : Icons.star_border,
|
||||
color: team.isFavorite ? AppTheme.warningAmber : Theme.of(context).colorScheme.onSurface.withOpacity(0.2),
|
||||
size: 28 * sf,
|
||||
shadows: [
|
||||
Shadow(color: Colors.black.withOpacity(team.isFavorite ? 0.3 : 0.1), blurRadius: 4 * sf),
|
||||
],
|
||||
),
|
||||
onPressed: onFavoriteTap,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(
|
||||
team.name,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * sf, color: textColor),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Padding(
|
||||
padding: EdgeInsets.only(top: 6.0 * sf),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.groups_outlined, size: 16 * sf, color: Colors.grey),
|
||||
SizedBox(width: 4 * sf),
|
||||
StreamBuilder<int>(
|
||||
stream: controller.getPlayerCountStream(team.id),
|
||||
initialData: 0,
|
||||
builder: (context, snapshot) {
|
||||
final count = snapshot.data ?? 0;
|
||||
return Text(
|
||||
"$count Jogs.",
|
||||
style: TextStyle(
|
||||
color: count > 0 ? AppTheme.successGreen : AppTheme.warningAmber, // 👇 Usando cores do tema
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13 * sf,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 8 * sf),
|
||||
Expanded(
|
||||
child: Text("| ${team.season}", style: TextStyle(color: Colors.grey, fontSize: 13 * sf), overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
tooltip: 'Ver Estatísticas',
|
||||
icon: Icon(Icons.bar_chart_rounded, color: Colors.blue, size: 24 * sf),
|
||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TeamStatsPage(team: team))),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Eliminar Equipa',
|
||||
icon: Icon(Icons.delete_outline, color: AppTheme.primaryRed, size: 24 * sf),
|
||||
onPressed: () => _confirmDelete(context, sf, bgColor, textColor),
|
||||
),
|
||||
SizedBox(width: 8 * context.sf),
|
||||
Expanded(child: Text("| ${team.season}", style: TextStyle(color: Colors.grey, fontSize: 13 * context.sf), overflow: TextOverflow.ellipsis)),
|
||||
],
|
||||
),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(tooltip: 'Ver Estatísticas', icon: Icon(Icons.bar_chart_rounded, color: Colors.blue, size: 24 * context.sf), onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TeamStatsPage(team: team)))),
|
||||
IconButton(tooltip: 'Eliminar Equipa', icon: Icon(Icons.delete_outline, color: const Color(0xFFE74C3C), size: 24 * context.sf), onPressed: () => _confirmDelete(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _confirmDelete(BuildContext context) {
|
||||
void _confirmDelete(BuildContext context, double sf, Color cardColor, Color textColor) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Eliminar Equipa?', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
content: Text('Tens a certeza que queres eliminar "${team.name}"?', style: TextStyle(fontSize: 14 * context.sf)),
|
||||
backgroundColor: cardColor,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
title: Text('Eliminar Equipa?', style: TextStyle(fontSize: 18 * sf, fontWeight: FontWeight.bold, color: textColor)),
|
||||
content: Text('Tens a certeza que queres eliminar "${team.name}"?', style: TextStyle(fontSize: 14 * sf, color: textColor)),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancelar', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
TextButton(onPressed: () { controller.deleteTeam(team.id); Navigator.pop(context); }, child: Text('Eliminar', style: TextStyle(color: Colors.red, fontSize: 14 * context.sf))),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('Cancelar', style: TextStyle(fontSize: 14 * sf, color: Colors.grey)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
controller.deleteTeam(team.id);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('Eliminar', style: TextStyle(color: AppTheme.primaryRed, fontSize: 14 * sf)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -295,7 +363,9 @@ class TeamCard extends StatelessWidget {
|
||||
// --- DIALOG DE CRIAÇÃO ---
|
||||
class CreateTeamDialog extends StatefulWidget {
|
||||
final Function(String name, String season, String imageUrl) onConfirm;
|
||||
const CreateTeamDialog({super.key, required this.onConfirm});
|
||||
final double sf;
|
||||
|
||||
const CreateTeamDialog({super.key, required this.onConfirm, required this.sf});
|
||||
|
||||
@override
|
||||
State<CreateTeamDialog> createState() => _CreateTeamDialogState();
|
||||
@@ -309,31 +379,33 @@ class _CreateTeamDialogState extends State<CreateTeamDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||
title: Text('Nova Equipa', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * widget.sf)),
|
||||
title: Text('Nova Equipa', style: TextStyle(fontSize: 18 * widget.sf, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onSurface)),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(controller: _nameController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'Nome da Equipa', labelStyle: TextStyle(fontSize: 14 * context.sf)), textCapitalization: TextCapitalization.words),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
TextField(controller: _nameController, style: TextStyle(fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface), decoration: InputDecoration(labelText: 'Nome da Equipa', labelStyle: TextStyle(fontSize: 14 * widget.sf)), textCapitalization: TextCapitalization.words),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedSeason, decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * context.sf)),
|
||||
style: TextStyle(fontSize: 14 * context.sf, color: Colors.black87),
|
||||
dropdownColor: Theme.of(context).colorScheme.surface,
|
||||
value: _selectedSeason, decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * widget.sf)),
|
||||
style: TextStyle(fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||
items: ['2023/24', '2024/25', '2025/26'].map((s) => DropdownMenuItem(value: s, child: Text(s))).toList(),
|
||||
onChanged: (val) => setState(() => _selectedSeason = val!),
|
||||
),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
TextField(controller: _imageController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'URL Imagem ou Emoji', labelStyle: TextStyle(fontSize: 14 * context.sf), hintText: 'Ex: 🏀 ou https://...', hintStyle: TextStyle(fontSize: 14 * context.sf))),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
TextField(controller: _imageController, style: TextStyle(fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface), decoration: InputDecoration(labelText: 'URL Imagem ou Emoji', labelStyle: TextStyle(fontSize: 14 * widget.sf), hintText: 'Ex: 🏀 ou https://...', hintStyle: TextStyle(fontSize: 14 * widget.sf, color: Colors.grey))),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancelar', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancelar', style: TextStyle(fontSize: 14 * widget.sf, color: Colors.grey))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 10 * context.sf)),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primaryRed, padding: EdgeInsets.symmetric(horizontal: 16 * widget.sf, vertical: 10 * widget.sf)),
|
||||
onPressed: () { if (_nameController.text.trim().isNotEmpty) { widget.onConfirm(_nameController.text.trim(), _selectedSeason, _imageController.text.trim()); Navigator.pop(context); } },
|
||||
child: Text('Criar', style: TextStyle(color: Colors.white, fontSize: 14 * context.sf)),
|
||||
child: Text('Criar', style: TextStyle(color: Colors.white, fontSize: 14 * widget.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user