Compare commits
4 Commits
dev
...
a4ef651d64
| Author | SHA1 | Date | |
|---|---|---|---|
| a4ef651d64 | |||
| cf0a9a9890 | |||
| c2619fe6d6 | |||
| 3dbccdc823 |
@@ -9,7 +9,7 @@ android {
|
|||||||
namespace = "com.example.playmaker"
|
namespace = "com.example.playmaker"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
//ndkVersion = flutter.ndkVersion
|
//ndkVersion = flutter.ndkVersion
|
||||||
ndkVersion = "27.0.12077973"
|
ndkVersion = "26.1.10909125"
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 268 KiB |
@@ -1,208 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
class CalibradorPage extends StatefulWidget {
|
|
||||||
const CalibradorPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CalibradorPage> createState() => _CalibradorPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CalibradorPageState extends State<CalibradorPage> {
|
|
||||||
// --- 👇 VALORES INICIAIS 👇 ---
|
|
||||||
double hoopBaseX = 0.08;
|
|
||||||
double arcRadius = 0.28;
|
|
||||||
double cornerY = 0.40;
|
|
||||||
// -----------------------------------------------------
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.landscapeRight,
|
|
||||||
DeviceOrientation.landscapeLeft,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final double wScreen = MediaQuery.of(context).size.width;
|
|
||||||
final double hScreen = MediaQuery.of(context).size.height;
|
|
||||||
|
|
||||||
// O MESMO CÁLCULO EXATO DO PLACAR
|
|
||||||
final double sf = math.min(wScreen / 1150, hScreen / 720);
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: const Color(0xFF266174),
|
|
||||||
body: SafeArea(
|
|
||||||
top: false,
|
|
||||||
bottom: false,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
// 👇 1. O CAMPO COM AS MARGENS EXATAS DO PLACAR 👇
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: Colors.white, width: 2.5),
|
|
||||||
image: const DecorationImage(
|
|
||||||
image: AssetImage('assets/campo.png'),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
return CustomPaint(
|
|
||||||
painter: LinePainter(
|
|
||||||
hoopBaseX: hoopBaseX,
|
|
||||||
arcRadius: arcRadius,
|
|
||||||
cornerY: cornerY,
|
|
||||||
color: Colors.redAccent,
|
|
||||||
width: constraints.maxWidth,
|
|
||||||
height: constraints.maxHeight,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// 👇 2. TOPO: MOSTRADORES DE VALORES COM FITTEDBOX (Não transborda) 👇
|
|
||||||
Positioned(
|
|
||||||
top: 0, left: 0, right: 0,
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black87.withOpacity(0.8),
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 5 * sf, horizontal: 15 * sf),
|
|
||||||
child: FittedBox( // Isto impede o ecrã de dar o erro dos 179 pixels!
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildValueDisplay("Aro X", hoopBaseX, sf),
|
|
||||||
SizedBox(width: 20 * sf),
|
|
||||||
_buildValueDisplay("Raio", arcRadius, sf),
|
|
||||||
SizedBox(width: 20 * sf),
|
|
||||||
_buildValueDisplay("Canto", cornerY, sf),
|
|
||||||
SizedBox(width: 30 * sf),
|
|
||||||
ElevatedButton.icon(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
icon: Icon(Icons.check, size: 18 * sf),
|
|
||||||
label: Text("FECHAR", style: TextStyle(fontSize: 14 * sf, fontWeight: FontWeight.bold)),
|
|
||||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// 👇 3. FUNDO: SLIDERS (Com altura fixa para não dar o erro "hasSize") 👇
|
|
||||||
Positioned(
|
|
||||||
bottom: 0, left: 0, right: 0,
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black87.withOpacity(0.8),
|
|
||||||
height: 80 * sf, // Altura segura para os sliders
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(child: _buildSlider("Pos. do Aro", hoopBaseX, 0.0, 0.25, (val) => setState(() => hoopBaseX = val), sf)),
|
|
||||||
Expanded(child: _buildSlider("Tam. da Curva", arcRadius, 0.1, 0.5, (val) => setState(() => arcRadius = val), sf)),
|
|
||||||
Expanded(child: _buildSlider("Pos. do Canto", cornerY, 0.2, 0.5, (val) => setState(() => cornerY = val), sf)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildValueDisplay(String label, double value, double sf) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Text("$label: ", style: TextStyle(color: Colors.white70, fontSize: 16 * sf)),
|
|
||||||
Text(value.toStringAsFixed(3), style: TextStyle(color: Colors.yellow, fontSize: 20 * sf, fontWeight: FontWeight.bold)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSlider(String label, double value, double min, double max, ValueChanged<double> onChanged, double sf) {
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(label, style: TextStyle(color: Colors.white, fontSize: 12 * sf)),
|
|
||||||
SizedBox(
|
|
||||||
height: 40 * sf, // Altura exata para o Slider não crashar
|
|
||||||
child: Slider(
|
|
||||||
value: value, min: min, max: max,
|
|
||||||
activeColor: Colors.yellow, inactiveColor: Colors.white24,
|
|
||||||
onChanged: onChanged,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==============================================================
|
|
||||||
// 📐 PINTOR: DESENHA A LINHA MATEMÁTICA NA TELA
|
|
||||||
// ==============================================================
|
|
||||||
class LinePainter extends CustomPainter {
|
|
||||||
final double hoopBaseX;
|
|
||||||
final double arcRadius;
|
|
||||||
final double cornerY;
|
|
||||||
final Color color;
|
|
||||||
final double width;
|
|
||||||
final double height;
|
|
||||||
|
|
||||||
LinePainter({
|
|
||||||
required this.hoopBaseX, required this.arcRadius, required this.cornerY,
|
|
||||||
required this.color, required this.width, required this.height,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
final paint = Paint()
|
|
||||||
..color = color
|
|
||||||
..style = PaintingStyle.stroke
|
|
||||||
..strokeWidth = 4;
|
|
||||||
|
|
||||||
double aspectRatio = width / height;
|
|
||||||
double hoopY = 0.50 * height;
|
|
||||||
|
|
||||||
// O cornerY controla a que distância do meio (50%) estão as linhas retas
|
|
||||||
double cornerDistY = cornerY * height;
|
|
||||||
|
|
||||||
// --- CESTO ESQUERDO ---
|
|
||||||
double hoopLX = hoopBaseX * width;
|
|
||||||
|
|
||||||
canvas.drawLine(Offset(0, hoopY - cornerDistY), Offset(width * 0.35, hoopY - cornerDistY), paint); // Cima
|
|
||||||
canvas.drawLine(Offset(0, hoopY + cornerDistY), Offset(width * 0.35, hoopY + cornerDistY), paint); // Baixo
|
|
||||||
|
|
||||||
canvas.drawArc(
|
|
||||||
Rect.fromCenter(center: Offset(hoopLX, hoopY), width: arcRadius * width * 2 / aspectRatio, height: arcRadius * height * 2),
|
|
||||||
-math.pi / 2, math.pi, false, paint,
|
|
||||||
);
|
|
||||||
|
|
||||||
// --- CESTO DIREITO ---
|
|
||||||
double hoopRX = (1.0 - hoopBaseX) * width;
|
|
||||||
|
|
||||||
canvas.drawLine(Offset(width, hoopY - cornerDistY), Offset(width * 0.65, hoopY - cornerDistY), paint); // Cima
|
|
||||||
canvas.drawLine(Offset(width, hoopY + cornerDistY), Offset(width * 0.65, hoopY + cornerDistY), paint); // Baixo
|
|
||||||
|
|
||||||
canvas.drawArc(
|
|
||||||
Rect.fromCenter(center: Offset(hoopRX, hoopY), width: arcRadius * width * 2 / aspectRatio, height: arcRadius * height * 2),
|
|
||||||
math.pi / 2, math.pi, false, paint,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(covariant LinePainter oldDelegate) {
|
|
||||||
return oldDelegate.hoopBaseX != hoopBaseX || oldDelegate.arcRadius != arcRadius || oldDelegate.cornerY != cornerY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,34 +4,25 @@ import '../models/game_model.dart';
|
|||||||
class GameController {
|
class GameController {
|
||||||
final _supabase = Supabase.instance.client;
|
final _supabase = Supabase.instance.client;
|
||||||
|
|
||||||
// 1. LER JOGOS (Com Filtros Opcionais)
|
// 1. LER JOGOS (Stream em Tempo Real)
|
||||||
Stream<List<Game>> getFilteredGames({String? teamFilter, String? seasonFilter}) {
|
Stream<List<Game>> get gamesStream {
|
||||||
return _supabase
|
return _supabase
|
||||||
.from('games')
|
.from('games') // 1. Fica à escuta da tabela original (Garante o Tempo Real!)
|
||||||
.stream(primaryKey: ['id'])
|
.stream(primaryKey: ['id'])
|
||||||
.asyncMap((event) async {
|
.asyncMap((event) async {
|
||||||
|
// 2. Sempre que a tabela 'games' mudar (novo jogo, alteração de resultado),
|
||||||
|
// vamos buscar os dados já misturados com as imagens à nossa View.
|
||||||
|
final viewData = await _supabase
|
||||||
|
.from('games_with_logos')
|
||||||
|
.select()
|
||||||
|
.order('game_date', ascending: false);
|
||||||
|
|
||||||
// 👇 A CORREÇÃO ESTÁ AQUI: Lê diretamente da tabela 'games'
|
// 3. Convertemos para a nossa lista de objetos Game
|
||||||
var query = _supabase.from('games').select();
|
|
||||||
|
|
||||||
// Aplica o filtro de Temporada
|
|
||||||
if (seasonFilter != null && seasonFilter.isNotEmpty && seasonFilter != 'Todas') {
|
|
||||||
query = query.eq('season', seasonFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aplica o filtro de Equipa (Procura em casa ou fora)
|
|
||||||
if (teamFilter != null && teamFilter.isNotEmpty && teamFilter != 'Todas') {
|
|
||||||
query = query.or('my_team.eq.$teamFilter,opponent_team.eq.$teamFilter');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Executa a query com a ordenação por data
|
|
||||||
final viewData = await query.order('game_date', ascending: false);
|
|
||||||
|
|
||||||
return viewData.map((json) => Game.fromMap(json)).toList();
|
return viewData.map((json) => Game.fromMap(json)).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. CRIAR JOGO
|
// 2. CRIAR JOGO
|
||||||
|
// Retorna o ID do jogo criado para podermos navegar para o placar
|
||||||
Future<String?> createGame(String myTeam, String opponent, String season) async {
|
Future<String?> createGame(String myTeam, String opponent, String season) async {
|
||||||
try {
|
try {
|
||||||
final response = await _supabase.from('games').insert({
|
final response = await _supabase.from('games').insert({
|
||||||
@@ -40,16 +31,18 @@ class GameController {
|
|||||||
'season': season,
|
'season': season,
|
||||||
'my_score': 0,
|
'my_score': 0,
|
||||||
'opponent_score': 0,
|
'opponent_score': 0,
|
||||||
'status': 'Decorrer',
|
'status': 'Decorrer', // Começa como "Decorrer"
|
||||||
'game_date': DateTime.now().toIso8601String(),
|
'game_date': DateTime.now().toIso8601String(),
|
||||||
}).select().single();
|
}).select().single(); // .select().single() retorna o objeto criado
|
||||||
|
|
||||||
return response['id'];
|
return response['id']; // Retorna o UUID gerado pelo Supabase
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Erro ao criar jogo: $e");
|
print("Erro ao criar jogo: $e");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {}
|
void dispose() {
|
||||||
|
// Não é necessário fechar streams do Supabase manualmente aqui
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,17 @@ class ShotRecord {
|
|||||||
final double relativeY;
|
final double relativeY;
|
||||||
final bool isMake;
|
final bool isMake;
|
||||||
final String playerName;
|
final String playerName;
|
||||||
|
// 👇 AGORA ACEITA ZONAS E PONTOS!
|
||||||
|
final String? zone;
|
||||||
|
final int? points;
|
||||||
|
|
||||||
ShotRecord({
|
ShotRecord({
|
||||||
required this.relativeX,
|
required this.relativeX,
|
||||||
required this.relativeY,
|
required this.relativeY,
|
||||||
required this.isMake,
|
required this.isMake,
|
||||||
required this.playerName
|
required this.playerName,
|
||||||
|
this.zone,
|
||||||
|
this.points,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,31 +279,74 @@ class PlacarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// 👇 A MÁGICA DOS PONTOS ACONTECE AQUI 👇
|
// 👇 REGISTA PONTOS VINDO DO POP-UP AMARELO (E MARCA A BOLINHA)
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
void registerShotFromPopup(BuildContext context, String action, String targetPlayer, String zone, int points, double relativeX, double relativeY) {
|
||||||
|
if (!isRunning) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('⏳ O relógio está parado! Inicie o tempo primeiro.'), backgroundColor: Colors.red));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = targetPlayer.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
||||||
|
bool isMyTeam = targetPlayer.startsWith("player_my_");
|
||||||
|
bool isMake = action.startsWith("add_");
|
||||||
|
|
||||||
|
// 1. ATUALIZA A ESTATÍSTICA DO JOGADOR
|
||||||
|
if (playerStats.containsKey(name)) {
|
||||||
|
playerStats[name]!['fga'] = playerStats[name]!['fga']! + 1;
|
||||||
|
|
||||||
|
if (isMake) {
|
||||||
|
playerStats[name]!['fgm'] = playerStats[name]!['fgm']! + 1;
|
||||||
|
playerStats[name]!['pts'] = playerStats[name]!['pts']! + points;
|
||||||
|
|
||||||
|
// 2. ATUALIZA O PLACAR DA EQUIPA
|
||||||
|
if (isMyTeam) {
|
||||||
|
myScore += points;
|
||||||
|
} else {
|
||||||
|
opponentScore += points;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. CRIA A BOLINHA PARA APARECER NO CAMPO
|
||||||
|
matchShots.add(ShotRecord(
|
||||||
|
relativeX: relativeX,
|
||||||
|
relativeY: relativeY,
|
||||||
|
isMake: isMake,
|
||||||
|
playerName: name,
|
||||||
|
zone: zone,
|
||||||
|
points: points,
|
||||||
|
));
|
||||||
|
|
||||||
|
// 4. MANDA UMA MENSAGEM NO ECRÃ
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(isMake ? '🔥 $name MARCOU de $zone!' : '❌ $name FALHOU de $zone!'),
|
||||||
|
backgroundColor: isMake ? Colors.green : Colors.red,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 5. ATUALIZA O ECRÃ
|
||||||
|
onUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MANTIDO PARA CASO USES A MARCAÇÃO CLÁSSICA DIRETAMENTE NO CAMPO ESCURO
|
||||||
void registerShotLocation(BuildContext context, Offset position, Size size) {
|
void registerShotLocation(BuildContext context, Offset position, Size size) {
|
||||||
if (pendingAction == null || pendingPlayer == null) return;
|
if (pendingAction == null || pendingPlayer == null) return;
|
||||||
|
|
||||||
bool is3Pt = pendingAction!.contains("_3");
|
bool is3Pt = pendingAction!.contains("_3");
|
||||||
bool is2Pt = pendingAction!.contains("_2");
|
bool is2Pt = pendingAction!.contains("_2");
|
||||||
|
|
||||||
// O ÁRBITRO MATEMÁTICO COM AS TUAS VARIÁVEIS CALIBRADAS
|
|
||||||
if (is3Pt || is2Pt) {
|
if (is3Pt || is2Pt) {
|
||||||
bool isValid = _validateShotZone(position, size, is3Pt);
|
bool isValid = _validateShotZone(position, size, is3Pt);
|
||||||
|
if (!isValid) return;
|
||||||
// SE A JOGADA FOI NO SÍTIO ERRADO
|
|
||||||
if (!isValid) {
|
|
||||||
|
|
||||||
return; // <-- ESTE RETURN BLOQUEIA A GRAVAÇÃO DO PONTO!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SE A JOGADA FOI VÁLIDA:
|
|
||||||
bool isMake = pendingAction!.startsWith("add_pts_");
|
bool isMake = pendingAction!.startsWith("add_pts_");
|
||||||
|
|
||||||
double relX = position.dx / size.width;
|
double relX = position.dx / size.width;
|
||||||
double relY = position.dy / size.height;
|
double relY = position.dy / size.height;
|
||||||
|
|
||||||
String name = pendingPlayer!.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
String name = pendingPlayer!.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
||||||
|
|
||||||
matchShots.add(ShotRecord(
|
matchShots.add(ShotRecord(
|
||||||
@@ -329,13 +377,10 @@ class PlacarController {
|
|||||||
|
|
||||||
bool isInside2Pts;
|
bool isInside2Pts;
|
||||||
|
|
||||||
// Lógica das laterais (Cantos)
|
|
||||||
if (distFromCenterY > cornerY) {
|
if (distFromCenterY > cornerY) {
|
||||||
double distToBaseline = isLeftHalf ? relX : (1.0 - relX);
|
double distToBaseline = isLeftHalf ? relX : (1.0 - relX);
|
||||||
isInside2Pts = distToBaseline <= hoopBaseX;
|
isInside2Pts = distToBaseline <= hoopBaseX;
|
||||||
}
|
} else {
|
||||||
// Lógica da Curva Frontal
|
|
||||||
else {
|
|
||||||
double dx = (relX - hoopX) * aspectRatio;
|
double dx = (relX - hoopX) * aspectRatio;
|
||||||
double dy = (relY - hoopY);
|
double dy = (relY - hoopY);
|
||||||
double distanceToHoop = math.sqrt((dx * dx) + (dy * dy));
|
double distanceToHoop = math.sqrt((dx * dx) + (dy * dy));
|
||||||
@@ -345,7 +390,6 @@ class PlacarController {
|
|||||||
if (is3Pt) return !isInside2Pts;
|
if (is3Pt) return !isInside2Pts;
|
||||||
return isInside2Pts;
|
return isInside2Pts;
|
||||||
}
|
}
|
||||||
// 👆 ===================================================================== 👆
|
|
||||||
|
|
||||||
void cancelShotLocation() {
|
void cancelShotLocation() {
|
||||||
isSelectingShotLocation = false; pendingAction = null; pendingPlayer = null; onUpdate();
|
isSelectingShotLocation = false; pendingAction = null; pendingPlayer = null; onUpdate();
|
||||||
|
|||||||
158
lib/controllers/stats_controller.dart
Normal file
158
lib/controllers/stats_controller.dart
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/*import 'package:flutter/material.dart';
|
||||||
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
import '../models/person_model.dart';
|
||||||
|
|
||||||
|
class StatsController {
|
||||||
|
final SupabaseClient _supabase = Supabase.instance.client;
|
||||||
|
|
||||||
|
// 1. LER
|
||||||
|
Stream<List<Person>> getMembers(String teamId) {
|
||||||
|
return _supabase
|
||||||
|
.from('members')
|
||||||
|
.stream(primaryKey: ['id'])
|
||||||
|
.eq('team_id', teamId)
|
||||||
|
.order('name', ascending: true)
|
||||||
|
.map((data) => data.map((json) => Person.fromMap(json)).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. APAGAR
|
||||||
|
Future<void> deletePerson(String personId) async {
|
||||||
|
try {
|
||||||
|
await _supabase.from('members').delete().eq('id', personId);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("Erro ao eliminar: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. DIÁLOGOS
|
||||||
|
void showAddPersonDialog(BuildContext context, String teamId) {
|
||||||
|
_showForm(context, teamId: teamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showEditPersonDialog(BuildContext context, String teamId, Person person) {
|
||||||
|
_showForm(context, teamId: teamId, person: person);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- O POPUP ESTÁ AQUI ---
|
||||||
|
void _showForm(BuildContext context, {required String teamId, Person? person}) {
|
||||||
|
final isEdit = person != null;
|
||||||
|
final nameCtrl = TextEditingController(text: person?.name ?? '');
|
||||||
|
final numCtrl = TextEditingController(text: person?.number ?? '');
|
||||||
|
|
||||||
|
// Define o valor inicial
|
||||||
|
String selectedType = person?.type ?? 'Jogador';
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => StatefulBuilder(
|
||||||
|
builder: (ctx, setState) => AlertDialog(
|
||||||
|
title: Text(isEdit ? "Editar" : "Adicionar"),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// NOME
|
||||||
|
TextField(
|
||||||
|
controller: nameCtrl,
|
||||||
|
decoration: const InputDecoration(labelText: "Nome"),
|
||||||
|
textCapitalization: TextCapitalization.sentences,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// FUNÇÃO
|
||||||
|
DropdownButtonFormField<String>(
|
||||||
|
value: selectedType,
|
||||||
|
decoration: const InputDecoration(labelText: "Função"),
|
||||||
|
items: ["Jogador", "Treinador"]
|
||||||
|
.map((e) => DropdownMenuItem(value: e, child: Text(e)))
|
||||||
|
.toList(),
|
||||||
|
onChanged: (v) {
|
||||||
|
if (v != null) setState(() => selectedType = v);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// NÚMERO (Só aparece se for Jogador)
|
||||||
|
if (selectedType == "Jogador") ...[
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
controller: numCtrl,
|
||||||
|
decoration: const InputDecoration(labelText: "Número da Camisola"),
|
||||||
|
keyboardType: TextInputType.text, // Aceita texto para evitar erros
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx),
|
||||||
|
child: const Text("Cancelar")
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFF00C853)),
|
||||||
|
onPressed: () async {
|
||||||
|
print("--- 1. CLICOU EM GUARDAR ---");
|
||||||
|
|
||||||
|
// Validação Simples
|
||||||
|
if (nameCtrl.text.trim().isEmpty) {
|
||||||
|
print("ERRO: Nome vazio");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lógica do Número:
|
||||||
|
// Se for Treinador -> envia NULL
|
||||||
|
// Se for Jogador e estiver vazio -> envia NULL
|
||||||
|
// Se tiver texto -> envia o Texto
|
||||||
|
String? numeroFinal;
|
||||||
|
if (selectedType == "Treinador") {
|
||||||
|
numeroFinal = null;
|
||||||
|
} else {
|
||||||
|
numeroFinal = numCtrl.text.trim().isEmpty ? null : numCtrl.text.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
print("--- 2. DADOS A ENVIAR ---");
|
||||||
|
print("Nome: ${nameCtrl.text}");
|
||||||
|
print("Tipo: $selectedType");
|
||||||
|
print("Número: $numeroFinal");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isEdit) {
|
||||||
|
await _supabase.from('members').update({
|
||||||
|
'name': nameCtrl.text.trim(),
|
||||||
|
'type': selectedType,
|
||||||
|
'number': numeroFinal,
|
||||||
|
}).eq('id', person!.id);
|
||||||
|
} else {
|
||||||
|
await _supabase.from('members').insert({
|
||||||
|
'team_id': teamId, // Verifica se este teamId é válido!
|
||||||
|
'name': nameCtrl.text.trim(),
|
||||||
|
'type': selectedType,
|
||||||
|
'number': numeroFinal,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
print("--- 3. SUCESSO! FECHANDO DIÁLOGO ---");
|
||||||
|
if (ctx.mounted) Navigator.pop(ctx);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
print("--- X. ERRO AO GUARDAR ---");
|
||||||
|
print(e.toString());
|
||||||
|
|
||||||
|
// MOSTRA O ERRO NO TELEMÓVEL
|
||||||
|
if (ctx.mounted) {
|
||||||
|
ScaffoldMessenger.of(ctx).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text("Erro: $e"),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
duration: const Duration(seconds: 4),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text("Guardar", style: TextStyle(color: Colors.white)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
@@ -1,24 +1,21 @@
|
|||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
|
||||||
class TeamController {
|
class TeamController {
|
||||||
|
// Instância do cliente Supabase
|
||||||
final _supabase = Supabase.instance.client;
|
final _supabase = Supabase.instance.client;
|
||||||
|
|
||||||
// 1. Variável fixa para guardar o Stream principal
|
// 1. STREAM (Realtime)
|
||||||
late final Stream<List<Map<String, dynamic>>> teamsStream;
|
// Adicionei o .map() no final para garantir que o Dart entende que é uma List<Map>
|
||||||
|
Stream<List<Map<String, dynamic>>> get teamsStream {
|
||||||
// 2. Dicionário (Cache) para não recriar Streams de contagem repetidos
|
return _supabase
|
||||||
final Map<String, Stream<int>> _playerCountStreams = {};
|
|
||||||
|
|
||||||
TeamController() {
|
|
||||||
// INICIALIZAÇÃO: O stream é criado APENAS UMA VEZ quando abres a página!
|
|
||||||
teamsStream = _supabase
|
|
||||||
.from('teams')
|
.from('teams')
|
||||||
.stream(primaryKey: ['id'])
|
.stream(primaryKey: ['id'])
|
||||||
.order('name', ascending: true)
|
.order('name', ascending: true)
|
||||||
.map((data) => List<Map<String, dynamic>>.from(data));
|
.map((data) => List<Map<String, dynamic>>.from(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRIAR
|
// 2. CRIAR
|
||||||
|
// Alterei imageUrl para String? (pode ser nulo) para evitar erros se não houver imagem
|
||||||
Future<void> createTeam(String name, String season, String? imageUrl) async {
|
Future<void> createTeam(String name, String season, String? imageUrl) async {
|
||||||
try {
|
try {
|
||||||
await _supabase.from('teams').insert({
|
await _supabase.from('teams').insert({
|
||||||
@@ -33,50 +30,42 @@ class TeamController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ELIMINAR
|
// 3. ELIMINAR
|
||||||
Future<void> deleteTeam(String id) async {
|
Future<void> deleteTeam(String id) async {
|
||||||
try {
|
try {
|
||||||
await _supabase.from('teams').delete().eq('id', id);
|
await _supabase.from('teams').delete().eq('id', id);
|
||||||
// Limpa o cache deste teamId se a equipa for apagada
|
|
||||||
_playerCountStreams.remove(id);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("❌ Erro ao eliminar: $e");
|
print("❌ Erro ao eliminar: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FAVORITAR
|
// 4. FAVORITAR
|
||||||
Future<void> toggleFavorite(String teamId, bool currentStatus) async {
|
Future<void> toggleFavorite(String teamId, bool currentStatus) async {
|
||||||
try {
|
try {
|
||||||
await _supabase
|
await _supabase
|
||||||
.from('teams')
|
.from('teams')
|
||||||
.update({'is_favorite': !currentStatus})
|
.update({'is_favorite': !currentStatus}) // Inverte o valor
|
||||||
.eq('id', teamId);
|
.eq('id', teamId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("❌ Erro ao favoritar: $e");
|
print("❌ Erro ao favoritar: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONTAR JOGADORES (AGORA COM CACHE DE MEMÓRIA!)
|
// 5. CONTAR JOGADORES
|
||||||
Stream<int> getPlayerCountStream(String teamId) {
|
// CORRIGIDO: A sintaxe antiga dava erro. O método .count() é o correto agora.
|
||||||
// Se já criámos um "Tubo de ligação" para esta equipa, REUTILIZA-O!
|
Future<int> getPlayerCount(String teamId) async {
|
||||||
if (_playerCountStreams.containsKey(teamId)) {
|
try {
|
||||||
return _playerCountStreams[teamId]!;
|
final count = await _supabase
|
||||||
}
|
|
||||||
|
|
||||||
// Se é a primeira vez que pede esta equipa, cria a ligação e guarda na memória
|
|
||||||
final newStream = _supabase
|
|
||||||
.from('members')
|
.from('members')
|
||||||
.stream(primaryKey: ['id'])
|
.count() // Retorna diretamente o número inteiro
|
||||||
.eq('team_id', teamId)
|
.eq('team_id', teamId);
|
||||||
.map((data) => data.length);
|
return count;
|
||||||
|
} catch (e) {
|
||||||
_playerCountStreams[teamId] = newStream; // Guarda no dicionário
|
print("Erro ao contar jogadores: $e");
|
||||||
return newStream;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LIMPEZA FINAL QUANDO SAÍMOS DA PÁGINA
|
// Mantemos o dispose vazio para não quebrar a chamada na TeamsPage
|
||||||
void dispose() {
|
void dispose() {}
|
||||||
// Limpamos o dicionário de streams para libertar memória RAM
|
|
||||||
_playerCountStreams.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
class PieChartData {
|
class PieChartData {
|
||||||
final int victories;
|
final int victories;
|
||||||
final int defeats;
|
final int defeats;
|
||||||
final int draws; // 👇 AQUI ESTÃO OS EMPATES
|
final int draws;
|
||||||
|
|
||||||
const PieChartData({
|
const PieChartData({
|
||||||
required this.victories,
|
required this.victories,
|
||||||
@@ -9,7 +9,6 @@ class PieChartData {
|
|||||||
this.draws = 0,
|
this.draws = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 👇 MATEMÁTICA ATUALIZADA 👇
|
|
||||||
int get total => victories + defeats + draws;
|
int get total => victories + defeats + draws;
|
||||||
|
|
||||||
double get victoryPercentage => total > 0 ? victories / total : 0;
|
double get victoryPercentage => total > 0 ? victories / total : 0;
|
||||||
@@ -23,6 +22,5 @@ class PieChartData {
|
|||||||
'total': total,
|
'total': total,
|
||||||
'victoryPercentage': victoryPercentage,
|
'victoryPercentage': victoryPercentage,
|
||||||
'defeatPercentage': defeatPercentage,
|
'defeatPercentage': defeatPercentage,
|
||||||
'drawPercentage': drawPercentage,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3,20 +3,15 @@ import 'package:playmaker/grafico%20de%20pizza/widgets/grafico_widgets.dart';
|
|||||||
import 'dados_grafico.dart';
|
import 'dados_grafico.dart';
|
||||||
|
|
||||||
class PieChartCard extends StatefulWidget {
|
class PieChartCard extends StatefulWidget {
|
||||||
final int victories;
|
final PieChartController? controller;
|
||||||
final int defeats;
|
|
||||||
final int draws;
|
|
||||||
final String title;
|
final String title;
|
||||||
final String subtitle;
|
final String subtitle;
|
||||||
final Color backgroundColor;
|
final Color? backgroundColor;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
final double sf;
|
|
||||||
|
|
||||||
const PieChartCard({
|
const PieChartCard({
|
||||||
super.key,
|
super.key,
|
||||||
this.victories = 0,
|
this.controller,
|
||||||
this.defeats = 0,
|
|
||||||
this.draws = 0,
|
|
||||||
this.title = 'DESEMPENHO',
|
this.title = 'DESEMPENHO',
|
||||||
this.subtitle = 'Temporada',
|
this.subtitle = 'Temporada',
|
||||||
this.onTap,
|
this.onTap,
|
||||||
@@ -29,25 +24,29 @@ class PieChartCard extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderStateMixin {
|
class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderStateMixin {
|
||||||
|
late PieChartController _controller;
|
||||||
late AnimationController _animationController;
|
late AnimationController _animationController;
|
||||||
late Animation<double> _animation;
|
late Animation<double> _animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_animationController = AnimationController(duration: const Duration(milliseconds: 600), vsync: this);
|
_controller = widget.controller ?? PieChartController();
|
||||||
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(parent: _animationController, curve: Curves.easeOutBack));
|
|
||||||
_animationController.forward();
|
_animationController = AnimationController(
|
||||||
}
|
duration: const Duration(milliseconds: 600),
|
||||||
|
vsync: this,
|
||||||
|
);
|
||||||
|
|
||||||
|
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||||
|
CurvedAnimation(
|
||||||
|
parent: _animationController,
|
||||||
|
curve: Curves.easeOutBack,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(PieChartCard oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
if (oldWidget.victories != widget.victories || oldWidget.defeats != widget.defeats || oldWidget.draws != widget.draws) {
|
|
||||||
_animationController.reset();
|
|
||||||
_animationController.forward();
|
_animationController.forward();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -168,15 +167,49 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
|
|||||||
color: Colors.white
|
color: Colors.white
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 10), // Espaço controlado
|
||||||
|
|
||||||
|
// Win rate - Sempre visível e não sobreposto
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
data.victoryPercentage > 0.5
|
||||||
|
? Icons.trending_up
|
||||||
|
: Icons.trending_down,
|
||||||
|
color: data.victoryPercentage > 0.5
|
||||||
|
? Colors.green
|
||||||
|
: Colors.red,
|
||||||
|
size: 18, // Pequeno
|
||||||
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Win Rate: ${(data.victoryPercentage * 100).toStringAsFixed(1)}%',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14, // Pequeno
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ class PieChartWidget extends StatelessWidget {
|
|||||||
final double victoryPercentage;
|
final double victoryPercentage;
|
||||||
final double defeatPercentage;
|
final double defeatPercentage;
|
||||||
final double drawPercentage;
|
final double drawPercentage;
|
||||||
final double sf;
|
final double size;
|
||||||
|
|
||||||
const PieChartWidget({
|
const PieChartWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.victoryPercentage,
|
required this.victoryPercentage,
|
||||||
required this.defeatPercentage,
|
required this.defeatPercentage,
|
||||||
this.drawPercentage = 0,
|
this.drawPercentage = 0,
|
||||||
required this.sf,
|
this.size = 140, // Aumentado para 400x300
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -73,12 +73,12 @@ class PieChartWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PieChartPainter extends CustomPainter {
|
class _DonutChartPainter extends CustomPainter {
|
||||||
final double victoryPercentage;
|
final double victoryPercentage;
|
||||||
final double defeatPercentage;
|
final double defeatPercentage;
|
||||||
final double drawPercentage;
|
final double drawPercentage;
|
||||||
|
|
||||||
_PieChartPainter({
|
_DonutChartPainter({
|
||||||
required this.victoryPercentage,
|
required this.victoryPercentage,
|
||||||
required this.defeatPercentage,
|
required this.defeatPercentage,
|
||||||
required this.drawPercentage,
|
required this.drawPercentage,
|
||||||
|
|||||||
@@ -1,35 +1,42 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORTA O TEU TEMA
|
||||||
import 'pages/login.dart';
|
import 'pages/login.dart';
|
||||||
|
|
||||||
|
// ========================================================
|
||||||
|
// 👇 A VARIÁVEL MÁGICA QUE FALTAVA (Fora do void main) 👇
|
||||||
|
// ========================================================
|
||||||
|
final ValueNotifier<ThemeMode> themeNotifier = ValueNotifier(ThemeMode.system);
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
await Supabase.initialize(
|
await Supabase.initialize(
|
||||||
url: 'https://sihwjdshexjyvsbettcd.supabase.co',
|
url: 'https://sihwjdshexjyvsbettcd.supabase.co',
|
||||||
anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaHdqZHNoZXhqeXZzYmV0dGNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MTQxMjgsImV4cCI6MjA4NDQ5MDEyOH0.gW3AvTJVNyE1Dqa72OTnhrUIKsndexrY3pKxMIAaAy8', // Uma string longa
|
anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaHdqZHNoZXhqeXZzYmV0dGNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MTQxMjgsImV4cCI6MjA4NDQ5MDEyOH0.gW3AvTJVNyE1Dqa72OTnhrUIKsndexrY3pKxMIAaAy8',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// FICA À ESCUTA DO THEMENOTIFIER
|
||||||
|
return ValueListenableBuilder<ThemeMode>(
|
||||||
|
valueListenable: themeNotifier,
|
||||||
|
builder: (_, ThemeMode currentMode, __) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'PlayMaker',
|
title: 'PlayMaker',
|
||||||
theme: ThemeData(
|
theme: AppTheme.lightTheme,
|
||||||
colorScheme: ColorScheme.fromSeed(
|
darkTheme: AppTheme.darkTheme,
|
||||||
seedColor: const Color(0xFFE74C3C),
|
themeMode: currentMode, // 👇 ISTO RECEBE O VALOR DO NOTIFIER
|
||||||
),
|
|
||||||
useMaterial3: true,
|
|
||||||
),
|
|
||||||
home: const LoginPage(),
|
home: const LoginPage(),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@ class Game {
|
|||||||
final String id;
|
final String id;
|
||||||
final String myTeam;
|
final String myTeam;
|
||||||
final String opponentTeam;
|
final String opponentTeam;
|
||||||
|
final String? myTeamLogo; // URL da imagem
|
||||||
|
final String? opponentTeamLogo; // URL da imagem
|
||||||
final String myScore;
|
final String myScore;
|
||||||
final String opponentScore;
|
final String opponentScore;
|
||||||
final String status;
|
final String status;
|
||||||
@@ -11,22 +13,26 @@ class Game {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.myTeam,
|
required this.myTeam,
|
||||||
required this.opponentTeam,
|
required this.opponentTeam,
|
||||||
|
this.myTeamLogo,
|
||||||
|
this.opponentTeamLogo,
|
||||||
required this.myScore,
|
required this.myScore,
|
||||||
required this.opponentScore,
|
required this.opponentScore,
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.season,
|
required this.season,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// No seu factory, certifique-se de mapear os campos da tabela (ou de um JOIN)
|
||||||
factory Game.fromMap(Map<String, dynamic> map) {
|
factory Game.fromMap(Map<String, dynamic> map) {
|
||||||
return Game(
|
return Game(
|
||||||
// O "?." converte para texto com segurança, e o "?? '...'" diz o que mostrar se for nulo (vazio)
|
id: map['id'],
|
||||||
id: map['id']?.toString() ?? '',
|
myTeam: map['my_team_name'],
|
||||||
myTeam: map['my_team']?.toString() ?? 'Desconhecida',
|
opponentTeam: map['opponent_team_name'],
|
||||||
opponentTeam: map['opponent_team']?.toString() ?? 'Adversário',
|
myTeamLogo: map['my_team_logo'], // Certifique-se que o Supabase retorna isto
|
||||||
myScore: map['my_score']?.toString() ?? '0',
|
opponentTeamLogo: map['opponent_team_logo'],
|
||||||
opponentScore: map['opponent_score']?.toString() ?? '0',
|
myScore: map['my_score'].toString(),
|
||||||
status: map['status']?.toString() ?? 'Terminado',
|
opponentScore: map['opponent_score'].toString(),
|
||||||
season: map['season']?.toString() ?? 'Sem Época',
|
status: map['status'],
|
||||||
|
season: map['season'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,33 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:playmaker/controllers/placar_controller.dart';
|
import 'package:playmaker/controllers/placar_controller.dart';
|
||||||
import 'package:playmaker/utils/size_extension.dart';
|
import 'package:playmaker/utils/size_extension.dart';
|
||||||
import 'package:playmaker/widgets/placar_widgets.dart';
|
import 'package:playmaker/widgets/placar_widgets.dart'; // 👇 As tuas classes extra vivem aqui!
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
class PlacarPage extends StatefulWidget {
|
import 'package:playmaker/zone_map_dialog.dart';
|
||||||
|
|
||||||
|
class PlacarPage extends StatefulWidget {
|
||||||
final String gameId, myTeam, opponentTeam;
|
final String gameId, myTeam, opponentTeam;
|
||||||
const PlacarPage({super.key, required this.gameId, required this.myTeam, required this.opponentTeam});
|
|
||||||
|
const PlacarPage({
|
||||||
|
super.key,
|
||||||
|
required this.gameId,
|
||||||
|
required this.myTeam,
|
||||||
|
required this.opponentTeam
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PlacarPage> createState() => _PlacarPageState();
|
State<PlacarPage> createState() => _PlacarPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PlacarPageState extends State<PlacarPage> {
|
class _PlacarPageState extends State<PlacarPage> {
|
||||||
late PlacarController _controller;
|
late PlacarController _controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
// Obriga o telemóvel a ficar deitado
|
||||||
SystemChrome.setPreferredOrientations([
|
SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.landscapeRight,
|
DeviceOrientation.landscapeRight,
|
||||||
DeviceOrientation.landscapeLeft,
|
DeviceOrientation.landscapeLeft,
|
||||||
@@ -38,6 +47,7 @@ import 'package:playmaker/utils/size_extension.dart';
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller.dispose();
|
_controller.dispose();
|
||||||
|
// Volta a deixar o telemóvel ao alto quando sais
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -85,7 +95,7 @@ import 'package:playmaker/utils/size_extension.dart';
|
|||||||
elevation: 5,
|
elevation: 5,
|
||||||
onPressed: isLoading ? null : onTap,
|
onPressed: isLoading ? null : onTap,
|
||||||
child: isLoading
|
child: isLoading
|
||||||
? SizedBox(width: size*0.45, height: size*0.45, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5))
|
? 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),
|
: Icon(icon, color: Colors.white, size: size * 0.55),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -98,9 +108,11 @@ import 'package:playmaker/utils/size_extension.dart';
|
|||||||
|
|
||||||
// 👇 CÁLCULO MANUAL DO SF 👇
|
// 👇 CÁLCULO MANUAL DO SF 👇
|
||||||
final double sf = math.min(wScreen / 1150, hScreen / 720);
|
final double sf = math.min(wScreen / 1150, hScreen / 720);
|
||||||
|
final double cornerBtnSize = 48 * sf; // Tamanho ideal
|
||||||
|
|
||||||
final double cornerBtnSize = 48 * sf; // Tamanho ideal (Nem 38 nem 55)
|
// ==========================================
|
||||||
|
// ECRÃ DE CARREGAMENTO (LOADING)
|
||||||
|
// ==========================================
|
||||||
if (_controller.isLoading) {
|
if (_controller.isLoading) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFF16202C),
|
backgroundColor: const Color(0xFF16202C),
|
||||||
@@ -130,17 +142,20 @@ import 'package:playmaker/utils/size_extension.dart';
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// ECRÃ PRINCIPAL (O JOGO)
|
||||||
|
// ==========================================
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFF266174),
|
backgroundColor: const Color(0xFF266174),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
bottom: false,
|
bottom: false,
|
||||||
// 👇 A MÁGICA DO IGNORE POINTER COMEÇA AQUI 👇
|
// 👇 IGNORE POINTER BLOQUEIA CLIQUES ENQUANTO GUARDA 👇
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
ignoring: _controller.isSaving, // Se estiver a gravar, ignora os toques!
|
ignoring: _controller.isSaving,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
// --- O CAMPO ---
|
// --- 1. O CAMPO ---
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
|
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
|
||||||
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.5)),
|
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.5)),
|
||||||
@@ -164,9 +179,9 @@ import 'package:playmaker/utils/size_extension.dart';
|
|||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: _controller.matchShots.map((shot) => Positioned(
|
children: _controller.matchShots.map((shot) => Positioned(
|
||||||
// Agora usamos relativeX e relativeY multiplicados pela largura(w) e altura(h)
|
// Posição calculada matematicamente pelo click anterior
|
||||||
left: (shot.relativeX * w) - (9 * context.sf),
|
left: (shot.relativeX * w) - (9 * context.sf),
|
||||||
top: (shot.relativeY * h) - (9 * context.sf),
|
top: (shot.relativeY * h) - (9 * context.sf),
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
@@ -179,7 +194,7 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// --- JOGADORES ---
|
// --- 2. JOGADORES NO CAMPO ---
|
||||||
if (!_controller.isSelectingShotLocation) ...[
|
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.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.68, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[1], isOpponent: false, sf: sf)),
|
||||||
@@ -194,13 +209,13 @@ child: Stack(
|
|||||||
Positioned(top: h * 0.80, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[4], 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 ---
|
// --- 3. BOTÕES DE FALTAS NO CAMPO ---
|
||||||
if (!_controller.isSelectingShotLocation) ...[
|
if (!_controller.isSelectingShotLocation) ...[
|
||||||
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.39, 0.0, h * 0.31, sf),
|
_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),
|
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0.0, w * 0.39, h * 0.31, sf),
|
||||||
],
|
],
|
||||||
|
|
||||||
// --- BOTÃO PLAY/PAUSE ---
|
// --- 4. BOTÃO PLAY/PAUSE NO MEIO ---
|
||||||
if (!_controller.isSelectingShotLocation)
|
if (!_controller.isSelectingShotLocation)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: (h * 0.32) + (40 * sf),
|
top: (h * 0.32) + (40 * sf),
|
||||||
@@ -216,13 +231,14 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// --- PLACAR NO TOPO ---
|
|
||||||
|
// --- 5. PLACAR LÁ NO TOPO ---
|
||||||
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
|
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
|
||||||
|
|
||||||
// --- BOTÕES DE AÇÃO ---
|
// --- 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)),
|
if (!_controller.isSelectingShotLocation) Positioned(bottom: -10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
|
||||||
|
|
||||||
// --- OVERLAY LANÇAMENTO ---
|
// --- 7. OVERLAY ESCURO PARA MARCAR PONTO NO CAMPO ---
|
||||||
if (_controller.isSelectingShotLocation)
|
if (_controller.isSelectingShotLocation)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: h * 0.4, left: 0, right: 0,
|
top: h * 0.4, left: 0, right: 0,
|
||||||
@@ -240,8 +256,11 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// --- BOTÕES LATERAIS ---
|
// ==========================================
|
||||||
// Topo Esquerdo: Guardar e Sair (Botão Único)
|
// BOTÕES LATERAIS DE FORA DO CAMPO
|
||||||
|
// ==========================================
|
||||||
|
|
||||||
|
// Topo Esquerdo: Guardar e Sair
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 50 * sf, left: 12 * sf,
|
top: 50 * sf, left: 12 * sf,
|
||||||
child: _buildCornerBtn(
|
child: _buildCornerBtn(
|
||||||
@@ -251,10 +270,8 @@ child: Stack(
|
|||||||
size: cornerBtnSize,
|
size: cornerBtnSize,
|
||||||
isLoading: _controller.isSaving,
|
isLoading: _controller.isSaving,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// 1. Primeiro obriga a guardar os dados na BD
|
// Guarda na BD e sai
|
||||||
await _controller.saveGameStats(context);
|
await _controller.saveGameStats(context);
|
||||||
|
|
||||||
// 2. Só depois de acabar de guardar é que volta para trás
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
@@ -262,7 +279,7 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Base Esquerda: Banco Casa + TIMEOUT DA CASA
|
// Base Esquerda: Banco + TIMEOUT DA CASA
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 55 * sf, left: 12 * sf,
|
bottom: 55 * sf, left: 12 * sf,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -285,7 +302,7 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Base Direita: Banco Visitante + TIMEOUT DO VISITANTE
|
// Base Direita: Banco + TIMEOUT DO VISITANTE
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 55 * sf, right: 12 * sf,
|
bottom: 55 * sf, right: 12 * sf,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -308,18 +325,38 @@ child: Stack(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 👇 EFEITO VISUAL (Ecrã escurece para mostrar que está a carregar) 👇
|
// 👇 EFEITO VISUAL (Ecrã escurece para mostrar que está a carregar quando se clica no Guardar) 👇
|
||||||
if (_controller.isSaving)
|
if (_controller.isSaving)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.black.withOpacity(0.4),
|
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:flutter/material.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||||
import '../controllers/register_controller.dart';
|
import '../controllers/register_controller.dart';
|
||||||
import '../widgets/register_widgets.dart';
|
import '../widgets/register_widgets.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||||
@@ -22,11 +23,20 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
// 👇 BLINDADO: Adapta-se automaticamente ao Modo Claro/Escuro
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Criar Conta", style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
title: Text(
|
||||||
backgroundColor: Colors.white,
|
"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,
|
elevation: 0,
|
||||||
|
iconTheme: IconThemeData(color: Theme.of(context).colorScheme.onSurface),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@@ -40,7 +50,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const RegisterHeader(), // 🔥 Agora sim, usa o Header bonito!
|
const RegisterHeader(),
|
||||||
SizedBox(height: 30 * context.sf),
|
SizedBox(height: 30 * context.sf),
|
||||||
|
|
||||||
RegisterFormFields(controller: _controller),
|
RegisterFormFields(controller: _controller),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:playmaker/pages/PlacarPage.dart';
|
import 'package:playmaker/pages/PlacarPage.dart';
|
||||||
import '../controllers/game_controller.dart';
|
import '../controllers/game_controller.dart';
|
||||||
import '../controllers/team_controller.dart';
|
import '../controllers/team_controller.dart';
|
||||||
|
import '../controllers/game_controller.dart';
|
||||||
import '../models/game_model.dart';
|
import '../models/game_model.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 NOVO SUPERPODER AQUI TAMBÉM!
|
import '../utils/size_extension.dart'; // 👇 NOVO SUPERPODER AQUI TAMBÉM!
|
||||||
|
|
||||||
@@ -201,15 +202,11 @@ class GamePage extends StatefulWidget {
|
|||||||
class _GamePageState extends State<GamePage> {
|
class _GamePageState extends State<GamePage> {
|
||||||
final GameController gameController = GameController();
|
final GameController gameController = GameController();
|
||||||
final TeamController teamController = TeamController();
|
final TeamController teamController = TeamController();
|
||||||
String selectedSeason = 'Todas';
|
|
||||||
String selectedTeam = 'Todas';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isFilterActive = selectedSeason != 'Todas' || selectedTeam != 'Todas';
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F7FA),
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Jogos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
title: Text("Jogos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
@@ -228,24 +225,37 @@ class _GamePageState extends State<GamePage> {
|
|||||||
stream: teamController.teamsStream,
|
stream: teamController.teamsStream,
|
||||||
builder: (context, teamSnapshot) {
|
builder: (context, teamSnapshot) {
|
||||||
final List<Map<String, dynamic>> teamsList = teamSnapshot.data ?? [];
|
final List<Map<String, dynamic>> teamsList = teamSnapshot.data ?? [];
|
||||||
|
|
||||||
|
// 2º STREAM: Lemos os jogos
|
||||||
return StreamBuilder<List<Game>>(
|
return StreamBuilder<List<Game>>(
|
||||||
stream: gameController.getFilteredGames(teamFilter: selectedTeam, seasonFilter: selectedSeason),
|
stream: gameController.gamesStream,
|
||||||
builder: (context, gameSnapshot) {
|
builder: (context, gameSnapshot) {
|
||||||
if (gameSnapshot.connectionState == ConnectionState.waiting && teamsList.isEmpty) return const Center(child: CircularProgressIndicator());
|
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)));
|
||||||
if (!gameSnapshot.hasData || gameSnapshot.data!.isEmpty) {
|
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.shade300), SizedBox(height: 10 * context.sf), Text("Nenhum jogo encontrado.", style: TextStyle(fontSize: 14 * context.sf, color: Colors.grey.shade600))]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: EdgeInsets.all(16 * context.sf),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: gameSnapshot.data!.length,
|
itemCount: gameSnapshot.data!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final game = gameSnapshot.data![index];
|
final game = gameSnapshot.data![index];
|
||||||
String? myLogo, oppLogo;
|
|
||||||
|
// --- LÓGICA PARA ENCONTRAR A IMAGEM PELO NOME ---
|
||||||
|
String? myLogo;
|
||||||
|
String? oppLogo;
|
||||||
|
|
||||||
for (var team in teamsList) {
|
for (var team in teamsList) {
|
||||||
if (team['name'] == game.myTeam) myLogo = team['image_url'];
|
if (team['name'] == game.myTeam) {
|
||||||
if (team['name'] == game.opponentTeam) oppLogo = team['image_url'];
|
myLogo = team['image_url'];
|
||||||
}
|
}
|
||||||
|
if (team['name'] == game.opponentTeam) {
|
||||||
|
oppLogo = team['image_url'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agora já passamos as imagens para o cartão!
|
||||||
return GameResultCard(
|
return GameResultCard(
|
||||||
gameId: game.id, myTeam: game.myTeam, opponentTeam: game.opponentTeam, myScore: game.myScore,
|
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,
|
opponentScore: game.opponentScore, status: game.status, season: game.season, myTeamLogo: myLogo, opponentTeamLogo: oppLogo,
|
||||||
@@ -265,9 +275,7 @@ class _GamePageState extends State<GamePage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showFilterPopup(BuildContext context) {
|
void _showCreateDialog(BuildContext context) {
|
||||||
String tempSeason = selectedSeason;
|
|
||||||
String tempTeam = selectedTeam;
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/grafico%20de%20pizza/grafico.dart';
|
||||||
import 'package:playmaker/pages/gamePage.dart';
|
import 'package:playmaker/pages/gamePage.dart';
|
||||||
import 'package:playmaker/pages/teamPage.dart';
|
import 'package:playmaker/pages/teamPage.dart';
|
||||||
@@ -7,7 +7,7 @@ import 'package:playmaker/controllers/team_controller.dart';
|
|||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
import 'package:playmaker/pages/status_page.dart';
|
import 'package:playmaker/pages/status_page.dart';
|
||||||
import '../utils/size_extension.dart';
|
import '../utils/size_extension.dart';
|
||||||
import 'package:playmaker/grafico%20de%20pizza/controllers/contollers_grafico.dart';
|
import 'settings_screen.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const HomeScreen({super.key});
|
const HomeScreen({super.key});
|
||||||
@@ -30,24 +30,28 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Já não precisamos calcular o sf aqui!
|
|
||||||
|
|
||||||
final List<Widget> pages = [
|
final List<Widget> pages = [
|
||||||
_buildHomeContent(context), // Passamos só o context
|
_buildHomeContent(context),
|
||||||
const GamePage(),
|
const GamePage(),
|
||||||
const TeamsPage(),
|
const TeamsPage(),
|
||||||
const StatusPage(),
|
const StatusPage(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // Fundo dinâmico
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('PlayMaker', style: TextStyle(fontSize: 20 * context.sf)),
|
title: Text('PlayMaker', style: TextStyle(fontSize: 20 * context.sf)),
|
||||||
backgroundColor: HomeConfig.primaryColor,
|
backgroundColor: AppTheme.primaryRed,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(Icons.person, size: 24 * context.sf),
|
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,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
|
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
|
||||||
elevation: 1,
|
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),
|
height: 70 * (context.sf < 1.2 ? context.sf : 1.2),
|
||||||
destinations: const [
|
destinations: const [
|
||||||
NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home_filled), label: 'Home'),
|
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) {
|
void _showTeamSelector(BuildContext context) {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface, // Fundo dinâmico
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20 * context.sf))),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20 * context.sf))),
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||||
stream: _teamController.teamsStream,
|
stream: _teamController.teamsStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) return const SizedBox(height: 200, child: Center(child: CircularProgressIndicator()));
|
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!;
|
final teams = snapshot.data!;
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
@@ -92,7 +96,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final team = teams[index];
|
final team = teams[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(team['name']),
|
title: Text(team['name'], style: TextStyle(color: Theme.of(context).colorScheme.onSurface)), // Texto dinâmico
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedTeamId = team['id'];
|
_selectedTeamId = team['id'];
|
||||||
@@ -115,6 +119,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Widget _buildHomeContent(BuildContext context) {
|
Widget _buildHomeContent(BuildContext context) {
|
||||||
final double wScreen = MediaQuery.of(context).size.width;
|
final double wScreen = MediaQuery.of(context).size.width;
|
||||||
final double cardHeight = wScreen * 0.5;
|
final double cardHeight = wScreen * 0.5;
|
||||||
|
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||||
|
|
||||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||||
stream: _selectedTeamId != null
|
stream: _selectedTeamId != null
|
||||||
@@ -133,12 +138,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
onTap: () => _showTeamSelector(context),
|
onTap: () => _showTeamSelector(context),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(12 * context.sf),
|
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(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
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))]),
|
Row(children: [
|
||||||
const Icon(Icons.arrow_drop_down),
|
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,
|
height: cardHeight,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
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),
|
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,
|
height: cardHeight,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
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),
|
SizedBox(width: 12 * context.sf),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PieChartCard(
|
child: PieChartCard(
|
||||||
@@ -170,8 +183,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
draws: _teamDraws,
|
draws: _teamDraws,
|
||||||
title: 'DESEMPENHO',
|
title: 'DESEMPENHO',
|
||||||
subtitle: 'Temporada',
|
subtitle: 'Temporada',
|
||||||
backgroundColor: const Color(0xFFC62828),
|
backgroundColor: AppTheme.statPieBg,
|
||||||
sf: context.sf // Aqui o PieChartCard ainda usa sf, então passamos
|
sf: context.sf
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -179,7 +192,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 40 * context.sf),
|
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),
|
SizedBox(height: 16 * context.sf),
|
||||||
|
|
||||||
_selectedTeamName == "Selecionar Equipa"
|
_selectedTeamName == "Selecionar Equipa"
|
||||||
@@ -192,7 +205,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
stream: _supabase.from('games').stream(primaryKey: ['id'])
|
stream: _supabase.from('games').stream(primaryKey: ['id'])
|
||||||
.order('game_date', ascending: false),
|
.order('game_date', ascending: false),
|
||||||
builder: (context, gameSnapshot) {
|
builder: (context, gameSnapshot) {
|
||||||
|
|
||||||
if (gameSnapshot.hasError) return Text("Erro: ${gameSnapshot.error}", style: const TextStyle(color: Colors.red));
|
if (gameSnapshot.hasError) return Text("Erro: ${gameSnapshot.error}", style: const TextStyle(color: Colors.red));
|
||||||
if (gameSnapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
if (gameSnapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
||||||
|
|
||||||
@@ -207,9 +219,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
if (gamesList.isEmpty) {
|
if (gamesList.isEmpty) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(20 * context.sf),
|
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,
|
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';
|
if (myScore < oppScore) result = 'D';
|
||||||
|
|
||||||
return _buildGameHistoryCard(
|
return _buildGameHistoryCard(
|
||||||
context: context, // Usamos o context para o sf
|
context: context,
|
||||||
opponent: opponent,
|
opponent: opponent,
|
||||||
result: result,
|
result: result,
|
||||||
myScore: myScore,
|
myScore: myScore,
|
||||||
@@ -252,7 +264,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 20 * context.sf),
|
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}) {
|
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(
|
return Card(
|
||||||
elevation: 4, margin: EdgeInsets.zero,
|
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(
|
child: Container(
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [color.withOpacity(0.9), color])),
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [color.withOpacity(0.9), color])),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final double ch = constraints.maxHeight;
|
final double ch = constraints.maxHeight;
|
||||||
final double cw = constraints.maxWidth;
|
final double cw = constraints.maxWidth;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.all(cw * 0.06),
|
padding: EdgeInsets.all(cw * 0.06),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -327,13 +337,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}) {
|
}) {
|
||||||
bool isWin = result == 'V';
|
bool isWin = result == 'V';
|
||||||
bool isDraw = result == 'E';
|
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(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: 14 * context.sf),
|
margin: EdgeInsets.only(bottom: 14 * context.sf),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white, borderRadius: BorderRadius.circular(16),
|
color: bgColor, 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))],
|
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(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -356,16 +368,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
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(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf),
|
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
||||||
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(8)),
|
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: Colors.black87)),
|
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(
|
Container(
|
||||||
width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 12 * context.sf),
|
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(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@@ -413,13 +425,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Icon(icon, size: 14 * context.sf, color: color),
|
Icon(icon, size: 14 * context.sf, color: color),
|
||||||
SizedBox(width: 4 * context.sf),
|
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(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
value,
|
value,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11 * context.sf,
|
fontSize: 11 * context.sf,
|
||||||
color: isMvp ? Colors.amber.shade900 : Colors.black87,
|
color: isMvp ? AppTheme.warningAmber : Theme.of(context).colorScheme.onSurface,
|
||||||
fontWeight: FontWeight.bold
|
fontWeight: FontWeight.bold
|
||||||
),
|
),
|
||||||
maxLines: 1, overflow: TextOverflow.ellipsis
|
maxLines: 1, overflow: TextOverflow.ellipsis
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:playmaker/controllers/login_controller.dart';
|
import 'package:playmaker/controllers/login_controller.dart';
|
||||||
import '../widgets/login_widgets.dart';
|
import '../widgets/login_widgets.dart';
|
||||||
import 'home.dart'; // <--- IMPORTANTE: Importa a tua HomeScreen
|
import 'home.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
import '../utils/size_extension.dart';
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {
|
class LoginPage extends StatefulWidget {
|
||||||
const LoginPage({super.key});
|
const LoginPage({super.key});
|
||||||
@@ -23,7 +23,8 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
// 👇 Adaptável ao Modo Claro/Escuro do Flutter
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: ListenableBuilder(
|
child: ListenableBuilder(
|
||||||
listenable: controller,
|
listenable: controller,
|
||||||
@@ -32,7 +33,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
// Garante que o form não fica gigante num tablet
|
|
||||||
constraints: BoxConstraints(maxWidth: 450 * context.sf),
|
constraints: BoxConstraints(maxWidth: 450 * context.sf),
|
||||||
padding: EdgeInsets.all(32 * context.sf),
|
padding: EdgeInsets.all(32 * context.sf),
|
||||||
child: Column(
|
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:flutter/material.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart';
|
||||||
import '../controllers/team_controller.dart';
|
import '../controllers/team_controller.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 A MAGIA DO SF!
|
import '../utils/size_extension.dart';
|
||||||
|
|
||||||
class StatusPage extends StatefulWidget {
|
class StatusPage extends StatefulWidget {
|
||||||
const StatusPage({super.key});
|
const StatusPage({super.key});
|
||||||
@@ -21,6 +22,9 @@ class _StatusPageState extends State<StatusPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final bgColor = Theme.of(context).cardTheme.color ?? Colors.white;
|
||||||
|
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -30,20 +34,20 @@ class _StatusPageState extends State<StatusPage> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(12 * context.sf),
|
padding: EdgeInsets.all(12 * context.sf),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: bgColor,
|
||||||
borderRadius: BorderRadius.circular(15 * context.sf),
|
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)]
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 5)]
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(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),
|
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!),
|
stream: _supabase.from('members').stream(primaryKey: ['id']).eq('team_id', _selectedTeamId!),
|
||||||
builder: (context, membersSnapshot) {
|
builder: (context, membersSnapshot) {
|
||||||
if (statsSnapshot.connectionState == ConnectionState.waiting || gamesSnapshot.connectionState == ConnectionState.waiting || membersSnapshot.connectionState == ConnectionState.waiting) {
|
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 ?? [];
|
final membersData = membersSnapshot.data ?? [];
|
||||||
@@ -82,7 +86,7 @@ class _StatusPageState extends State<StatusPage> {
|
|||||||
return _isAscending ? valA.compareTo(valB) : valB.compareTo(valA);
|
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) {
|
List<Map<String, dynamic>> _aggregateStats(List<dynamic> stats, List<dynamic> games, List<dynamic> members) {
|
||||||
Map<String, Map<String, dynamic>> aggregated = {};
|
Map<String, Map<String, dynamic>> aggregated = {};
|
||||||
|
|
||||||
for (var member in members) {
|
for (var member in members) {
|
||||||
String name = member['name']?.toString() ?? "Desconhecido";
|
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};
|
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) {
|
for (var row in stats) {
|
||||||
String name = row['player_name']?.toString() ?? "Desconhecido";
|
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};
|
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]!['stl'] += (row['stl'] ?? 0);
|
||||||
aggregated[name]!['blk'] += (row['blk'] ?? 0);
|
aggregated[name]!['blk'] += (row['blk'] ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var game in games) {
|
for (var game in games) {
|
||||||
String? mvp = game['mvp_name'];
|
String? mvp = game['mvp_name'];
|
||||||
String? defRaw = game['top_def_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};
|
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(
|
return Container(
|
||||||
color: Colors.white,
|
color: Colors.transparent,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: DataTable(
|
child: DataTable(
|
||||||
columnSpacing: 25 * context.sf,
|
columnSpacing: 25 * context.sf,
|
||||||
headingRowColor: MaterialStateProperty.all(Colors.grey.shade100),
|
headingRowColor: WidgetStateProperty.all(Theme.of(context).colorScheme.surface),
|
||||||
dataRowHeight: 60 * context.sf,
|
dataRowMaxHeight: 60 * context.sf,
|
||||||
|
dataRowMinHeight: 60 * context.sf,
|
||||||
columns: [
|
columns: [
|
||||||
DataColumn(label: const Text('JOGADOR')),
|
DataColumn(label: Text('JOGADOR', style: TextStyle(color: textColor))),
|
||||||
_buildSortableColumn(context, 'J', 'j'),
|
_buildSortableColumn(context, 'J', 'j', textColor),
|
||||||
_buildSortableColumn(context, 'PTS', 'pts'),
|
_buildSortableColumn(context, 'PTS', 'pts', textColor),
|
||||||
_buildSortableColumn(context, 'AST', 'ast'),
|
_buildSortableColumn(context, 'AST', 'ast', textColor),
|
||||||
_buildSortableColumn(context, 'RBS', 'rbs'),
|
_buildSortableColumn(context, 'RBS', 'rbs', textColor),
|
||||||
_buildSortableColumn(context, 'STL', 'stl'),
|
_buildSortableColumn(context, 'STL', 'stl', textColor),
|
||||||
_buildSortableColumn(context, 'BLK', 'blk'),
|
_buildSortableColumn(context, 'BLK', 'blk', textColor),
|
||||||
_buildSortableColumn(context, 'DEF 🛡️', 'def'),
|
_buildSortableColumn(context, 'DEF 🛡️', 'def', textColor),
|
||||||
_buildSortableColumn(context, 'MVP 🏆', 'mvp'),
|
_buildSortableColumn(context, 'MVP 🏆', 'mvp', textColor),
|
||||||
],
|
],
|
||||||
rows: [
|
rows: [
|
||||||
...players.map((player) => DataRow(cells: [
|
...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(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()))),
|
DataCell(Center(child: Text(player['j'].toString(), style: TextStyle(color: textColor)))),
|
||||||
_buildStatCell(context, player['pts'], isHighlight: true),
|
_buildStatCell(context, player['pts'], textColor, isHighlight: true),
|
||||||
_buildStatCell(context, player['ast']),
|
_buildStatCell(context, player['ast'], textColor),
|
||||||
_buildStatCell(context, player['rbs']),
|
_buildStatCell(context, player['rbs'], textColor),
|
||||||
_buildStatCell(context, player['stl']),
|
_buildStatCell(context, player['stl'], textColor),
|
||||||
_buildStatCell(context, player['blk']),
|
_buildStatCell(context, player['blk'], textColor),
|
||||||
_buildStatCell(context, player['def'], isBlue: true),
|
_buildStatCell(context, player['def'], textColor, isBlue: true),
|
||||||
_buildStatCell(context, player['mvp'], isGold: true),
|
_buildStatCell(context, player['mvp'], textColor, isGold: true),
|
||||||
])),
|
])),
|
||||||
DataRow(
|
DataRow(
|
||||||
color: MaterialStateProperty.all(Colors.grey.shade50),
|
color: WidgetStateProperty.all(Theme.of(context).colorScheme.surface.withOpacity(0.5)),
|
||||||
cells: [
|
cells: [
|
||||||
DataCell(Text('TOTAL EQUIPA', style: TextStyle(fontWeight: FontWeight.w900, color: Colors.black, fontSize: 12 * context.sf))),
|
DataCell(Text('TOTAL EQUIPA', style: TextStyle(fontWeight: FontWeight.w900, color: textColor, fontSize: 12 * context.sf))),
|
||||||
DataCell(Center(child: Text(teamTotals['j'].toString(), style: const TextStyle(fontWeight: FontWeight.bold)))),
|
DataCell(Center(child: Text(teamTotals['j'].toString(), style: TextStyle(fontWeight: FontWeight.bold, color: textColor)))),
|
||||||
_buildStatCell(context, teamTotals['pts'], isHighlight: true),
|
_buildStatCell(context, teamTotals['pts'], textColor, isHighlight: true),
|
||||||
_buildStatCell(context, teamTotals['ast']),
|
_buildStatCell(context, teamTotals['ast'], textColor),
|
||||||
_buildStatCell(context, teamTotals['rbs']),
|
_buildStatCell(context, teamTotals['rbs'], textColor),
|
||||||
_buildStatCell(context, teamTotals['stl']),
|
_buildStatCell(context, teamTotals['stl'], textColor),
|
||||||
_buildStatCell(context, teamTotals['blk']),
|
_buildStatCell(context, teamTotals['blk'], textColor),
|
||||||
_buildStatCell(context, teamTotals['def'], isBlue: true),
|
_buildStatCell(context, teamTotals['def'], textColor, isBlue: true),
|
||||||
_buildStatCell(context, teamTotals['mvp'], isGold: 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(
|
return DataColumn(label: InkWell(
|
||||||
onTap: () => setState(() {
|
onTap: () => setState(() {
|
||||||
if (_sortColumn == sortKey) _isAscending = !_isAscending;
|
if (_sortColumn == sortKey) _isAscending = !_isAscending;
|
||||||
else { _sortColumn = sortKey; _isAscending = false; }
|
else { _sortColumn = sortKey; _isAscending = false; }
|
||||||
}),
|
}),
|
||||||
child: Row(children: [
|
child: Row(children: [
|
||||||
Text(title, style: TextStyle(fontSize: 12 * context.sf, fontWeight: FontWeight.bold)),
|
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: const Color(0xFFE74C3C)),
|
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(
|
return DataCell(Center(child: Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
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)),
|
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(
|
child: Text(value == 0 ? "-" : value.toString(), style: TextStyle(
|
||||||
fontWeight: (isHighlight || isGold || isBlue) ? FontWeight.w900 : FontWeight.w600,
|
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) {
|
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,
|
stream: _teamController.teamsStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final teams = snapshot.data ?? [];
|
final teams = snapshot.data ?? [];
|
||||||
return ListView.builder(itemCount: teams.length, itemBuilder: (context, i) => ListTile(
|
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); },
|
onTap: () { setState(() { _selectedTeamId = teams[i]['id']; _selectedTeamName = teams[i]['name']; }); Navigator.pop(context); },
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:playmaker/screens/team_stats_page.dart';
|
import 'package:playmaker/screens/team_stats_page.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||||
import '../controllers/team_controller.dart';
|
import '../controllers/team_controller.dart';
|
||||||
import '../models/team_model.dart';
|
import '../models/team_model.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 IMPORTANTE: O TEU NOVO SUPERPODER
|
import '../utils/size_extension.dart'; // 👇 IMPORTANTE: O TEU NOVO SUPERPODER
|
||||||
@@ -25,6 +26,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- POPUP DE FILTROS ---
|
||||||
void _showFilterDialog(BuildContext context) {
|
void _showFilterDialog(BuildContext context) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -52,6 +54,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
// Coluna Temporada
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildPopupColumn(
|
child: _buildPopupColumn(
|
||||||
title: "TEMPORADA",
|
title: "TEMPORADA",
|
||||||
@@ -63,7 +66,8 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 20 * context.sf),
|
const SizedBox(width: 20),
|
||||||
|
// Coluna Ordenar
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildPopupColumn(
|
child: _buildPopupColumn(
|
||||||
title: "ORDENAR POR",
|
title: "ORDENAR POR",
|
||||||
@@ -92,24 +96,28 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildPopupColumn({required String title, required List<String> options, required String currentValue, required Function(String) onSelect}) {
|
Widget _buildPopupColumn({
|
||||||
|
required String title,
|
||||||
|
required List<String> options,
|
||||||
|
required String currentValue,
|
||||||
|
required Function(String) onSelect,
|
||||||
|
}) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(title, style: TextStyle(color: Colors.grey, fontSize: 11 * context.sf, fontWeight: FontWeight.bold)),
|
Text(title, style: const TextStyle(color: Colors.grey, fontSize: 11, fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 12 * context.sf),
|
const SizedBox(height: 12),
|
||||||
...options.map((opt) {
|
...options.map((opt) {
|
||||||
final isSelected = currentValue == opt;
|
final isSelected = currentValue == opt;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => onSelect(opt),
|
onTap: () => onSelect(opt),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 8.0 * context.sf),
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
opt,
|
opt,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected ? const Color(0xFFE74C3C) : Colors.white70,
|
color: isSelected ? const Color(0xFFE74C3C) : Colors.white70,
|
||||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
fontSize: 14 * context.sf,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -121,9 +129,8 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// 🔥 OLHA QUE LIMPEZA: Já não precisamos de calcular nada aqui!
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F7FA),
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Minhas Equipas", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
title: Text("Minhas Equipas", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
||||||
backgroundColor: const Color(0xFFF5F7FA),
|
backgroundColor: const Color(0xFFF5F7FA),
|
||||||
@@ -152,7 +159,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
|
|
||||||
Widget _buildSearchBar() {
|
Widget _buildSearchBar() {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.all(16.0 * context.sf),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
onChanged: (v) => setState(() => _searchQuery = v.toLowerCase()),
|
onChanged: (v) => setState(() => _searchQuery = v.toLowerCase()),
|
||||||
@@ -178,29 +185,51 @@ class _TeamsPageState extends State<TeamsPage> {
|
|||||||
|
|
||||||
var data = List<Map<String, dynamic>>.from(snapshot.data!);
|
var data = List<Map<String, dynamic>>.from(snapshot.data!);
|
||||||
|
|
||||||
if (_selectedSeason != 'Todas') data = data.where((t) => t['season'] == _selectedSeason).toList();
|
// --- 1. FILTROS ---
|
||||||
if (_searchQuery.isNotEmpty) data = data.where((t) => t['name'].toString().toLowerCase().contains(_searchQuery)).toList();
|
if (_selectedSeason != 'Todas') {
|
||||||
|
data = data.where((t) => t['season'] == _selectedSeason).toList();
|
||||||
|
}
|
||||||
|
if (_searchQuery.isNotEmpty) {
|
||||||
|
data = data.where((t) => t['name'].toString().toLowerCase().contains(_searchQuery)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 2. ORDENAÇÃO (FAVORITOS PRIMEIRO) ---
|
||||||
data.sort((a, b) {
|
data.sort((a, b) {
|
||||||
|
// Apanhar o estado de favorito (tratando null como false)
|
||||||
bool favA = a['is_favorite'] ?? false;
|
bool favA = a['is_favorite'] ?? false;
|
||||||
bool favB = b['is_favorite'] ?? false;
|
bool favB = b['is_favorite'] ?? false;
|
||||||
if (favA && !favB) return -1;
|
|
||||||
if (!favA && favB) return 1;
|
// REGRA 1: Favoritos aparecem sempre primeiro
|
||||||
if (_currentSort == 'Nome') return a['name'].toString().compareTo(b['name'].toString());
|
if (favA && !favB) return -1; // A sobe
|
||||||
else return (b['created_at'] ?? '').toString().compareTo((a['created_at'] ?? '').toString());
|
if (!favA && favB) return 1; // B sobe
|
||||||
|
|
||||||
|
// REGRA 2: Se o estado de favorito for igual, aplica o filtro do utilizador
|
||||||
|
if (_currentSort == 'Nome') {
|
||||||
|
return a['name'].toString().compareTo(b['name'].toString());
|
||||||
|
} else { // Recentes
|
||||||
|
return (b['created_at'] ?? '').toString().compareTo((a['created_at'] ?? '').toString());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16 * context.sf),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
itemCount: data.length,
|
itemCount: data.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final team = Team.fromMap(data[index]);
|
final team = Team.fromMap(data[index]);
|
||||||
|
|
||||||
|
// Navegação para estatísticas
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TeamStatsPage(team: team))),
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => TeamStatsPage(team: team)),
|
||||||
|
);
|
||||||
|
},
|
||||||
child: TeamCard(
|
child: TeamCard(
|
||||||
team: team,
|
team: team,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onFavoriteTap: () => controller.toggleFavorite(team.id, team.isFavorite),
|
onFavoriteTap: () => controller.toggleFavorite(team.id, team.isFavorite),
|
||||||
|
sf: context.sf,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
1
lib/screens/game_screen.dart
Normal file
1
lib/screens/game_screen.dart
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA!
|
||||||
import '../models/team_model.dart';
|
import '../models/team_model.dart';
|
||||||
import '../models/person_model.dart';
|
import '../models/person_model.dart';
|
||||||
|
import '../utils/size_extension.dart'; // 👇 SUPERPODER SF
|
||||||
|
|
||||||
// --- CABEÇALHO ---
|
// --- CABEÇALHO ---
|
||||||
class StatsHeader extends StatelessWidget {
|
class StatsHeader extends StatelessWidget {
|
||||||
@@ -13,22 +15,24 @@ class StatsHeader extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20),
|
padding: EdgeInsets.only(top: 50 * context.sf, left: 20 * context.sf, right: 20 * context.sf, bottom: 20 * context.sf),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color(0xFF2C3E50),
|
color: AppTheme.primaryRed, // 👇 Usando a cor oficial
|
||||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(30), bottomRight: Radius.circular(30)),
|
borderRadius: BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(30 * context.sf),
|
||||||
|
bottomRight: Radius.circular(30 * context.sf)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
icon: Icon(Icons.arrow_back, color: Colors.white, size: 24 * context.sf),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
SizedBox(width: 10 * context.sf),
|
||||||
|
|
||||||
// IMAGEM OU EMOJI DA EQUIPA AQUI!
|
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 24,
|
radius: 24 * context.sf,
|
||||||
backgroundColor: Colors.white24,
|
backgroundColor: Colors.white24,
|
||||||
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
|
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
|
||||||
? NetworkImage(team.imageUrl)
|
? NetworkImage(team.imageUrl)
|
||||||
@@ -36,18 +40,25 @@ class StatsHeader extends StatelessWidget {
|
|||||||
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
|
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
|
||||||
? Text(
|
? Text(
|
||||||
team.imageUrl.isEmpty ? "🛡️" : team.imageUrl,
|
team.imageUrl.isEmpty ? "🛡️" : team.imageUrl,
|
||||||
style: const TextStyle(fontSize: 20),
|
style: TextStyle(fontSize: 20 * context.sf),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(width: 15),
|
SizedBox(width: 15 * context.sf),
|
||||||
Expanded( // Expanded evita overflow se o nome for muito longo
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(team.name, style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.ellipsis),
|
Text(
|
||||||
Text(team.season, style: const TextStyle(color: Colors.white70, fontSize: 14)),
|
team.name,
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 20 * context.sf, fontWeight: FontWeight.bold),
|
||||||
|
overflow: TextOverflow.ellipsis
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
team.season,
|
||||||
|
style: TextStyle(color: Colors.white70, fontSize: 14 * context.sf)
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -65,20 +76,36 @@ class StatsSummaryCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// 👇 Adapta-se ao Modo Claro/Escuro
|
||||||
|
final Color bgColor = Theme.of(context).brightness == Brightness.dark ? const Color(0xFF1E1E1E) : Colors.white;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: EdgeInsets.all(20 * context.sf),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(20),
|
color: bgColor,
|
||||||
gradient: LinearGradient(colors: [Colors.blue.shade700, Colors.blue.shade400]),
|
borderRadius: BorderRadius.circular(20 * context.sf),
|
||||||
|
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text("Total de Membros", style: TextStyle(color: Colors.white, fontSize: 16)),
|
Row(
|
||||||
Text("$total", style: const TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold)),
|
children: [
|
||||||
|
Icon(Icons.groups, color: AppTheme.primaryRed, size: 28 * context.sf), // 👇 Cor do tema
|
||||||
|
SizedBox(width: 10 * context.sf),
|
||||||
|
Text(
|
||||||
|
"Total de Membros",
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 16 * context.sf, fontWeight: FontWeight.w600)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"$total",
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 28 * context.sf, fontWeight: FontWeight.bold)
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -97,8 +124,11 @@ class StatsSectionTitle extends StatelessWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(title, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF2C3E50))),
|
Text(
|
||||||
const Divider(),
|
title,
|
||||||
|
style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onSurface)
|
||||||
|
),
|
||||||
|
Divider(color: Colors.grey.withOpacity(0.2)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -121,37 +151,50 @@ class PersonCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
// 👇 Adapta as cores do Card ao Modo Escuro e ao Tema
|
||||||
margin: const EdgeInsets.only(top: 12),
|
final Color defaultBg = Theme.of(context).brightness == Brightness.dark ? const Color(0xFF1E1E1E) : Colors.white;
|
||||||
elevation: 2,
|
final Color coachBg = Theme.of(context).brightness == Brightness.dark ? AppTheme.warningAmber.withOpacity(0.1) : const Color(0xFFFFF9C4);
|
||||||
color: isCoach ? const Color(0xFFFFF9C4) : Colors.white,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
return Card(
|
||||||
child: ListTile(
|
margin: EdgeInsets.only(top: 12 * context.sf),
|
||||||
leading: isCoach
|
elevation: 2,
|
||||||
? const CircleAvatar(backgroundColor: Colors.orange, child: Icon(Icons.person, color: Colors.white))
|
color: isCoach ? coachBg : defaultBg,
|
||||||
: Container(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||||
width: 45,
|
child: ListTile(
|
||||||
height: 45,
|
contentPadding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 4 * context.sf),
|
||||||
alignment: Alignment.center,
|
leading: isCoach
|
||||||
decoration: BoxDecoration(color: Colors.blue.withOpacity(0.1), borderRadius: BorderRadius.circular(10)),
|
? CircleAvatar(
|
||||||
child: Text(person.number ?? "J", style: const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontSize: 16)),
|
radius: 22 * context.sf,
|
||||||
),
|
backgroundColor: AppTheme.warningAmber, // 👇 Cor do tema
|
||||||
title: Text(person.name, style: const TextStyle(fontWeight: FontWeight.bold)),
|
child: Icon(Icons.person, color: Colors.white, size: 24 * context.sf)
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
width: 45 * context.sf,
|
||||||
|
height: 45 * context.sf,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryRed.withOpacity(0.1), // 👇 Cor do tema
|
||||||
|
borderRadius: BorderRadius.circular(10 * context.sf)
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
person.number ?? "J",
|
||||||
|
style: TextStyle(color: AppTheme.primaryRed, fontWeight: FontWeight.bold, fontSize: 16 * context.sf)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
person.name,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * context.sf, color: Theme.of(context).colorScheme.onSurface)
|
||||||
|
),
|
||||||
|
|
||||||
// --- CANTO DIREITO (Trailing) ---
|
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
// IMAGEM DA EQUIPA NO CARD DO JOGADOR
|
|
||||||
|
|
||||||
const SizedBox(width: 5), // Espaço
|
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.edit_outlined, color: Colors.blue),
|
icon: Icon(Icons.edit_outlined, color: Colors.blue, size: 22 * context.sf),
|
||||||
onPressed: onEdit,
|
onPressed: onEdit,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.delete_outline, color: Colors.red),
|
icon: Icon(Icons.delete_outline, color: AppTheme.primaryRed, size: 22 * context.sf), // 👇 Cor do tema
|
||||||
onPressed: onDelete,
|
onPressed: onDelete,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -180,10 +223,9 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F7FA),
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // 👇 Adapta-se ao Modo Escuro
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
// Cabeçalho
|
|
||||||
StatsHeader(team: widget.team),
|
StatsHeader(team: widget.team),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -191,11 +233,11 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
stream: _controller.getMembers(widget.team.id),
|
stream: _controller.getMembers(widget.team.id),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator(color: AppTheme.primaryRed));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return Center(child: Text("Erro ao carregar: ${snapshot.error}"));
|
return Center(child: Text("Erro ao carregar: ${snapshot.error}", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
final members = snapshot.data ?? [];
|
final members = snapshot.data ?? [];
|
||||||
@@ -204,15 +246,16 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
final players = members.where((m) => m.type == 'Jogador').toList();
|
final players = members.where((m) => m.type == 'Jogador').toList();
|
||||||
|
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
|
color: AppTheme.primaryRed,
|
||||||
onRefresh: () async => setState(() {}),
|
onRefresh: () async => setState(() {}),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0 * context.sf),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
StatsSummaryCard(total: members.length),
|
StatsSummaryCard(total: members.length),
|
||||||
const SizedBox(height: 30),
|
SizedBox(height: 30 * context.sf),
|
||||||
|
|
||||||
// TREINADORES
|
// TREINADORES
|
||||||
if (coaches.isNotEmpty) ...[
|
if (coaches.isNotEmpty) ...[
|
||||||
@@ -220,19 +263,18 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
...coaches.map((c) => PersonCard(
|
...coaches.map((c) => PersonCard(
|
||||||
person: c,
|
person: c,
|
||||||
isCoach: true,
|
isCoach: true,
|
||||||
|
|
||||||
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, c),
|
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, c),
|
||||||
onDelete: () => _confirmDelete(context, c),
|
onDelete: () => _confirmDelete(context, c),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 30),
|
SizedBox(height: 30 * context.sf),
|
||||||
],
|
],
|
||||||
|
|
||||||
// JOGADORES
|
// JOGADORES
|
||||||
const StatsSectionTitle(title: "Jogadores"),
|
const StatsSectionTitle(title: "Jogadores"),
|
||||||
if (players.isEmpty)
|
if (players.isEmpty)
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 20),
|
padding: EdgeInsets.only(top: 20 * context.sf),
|
||||||
child: Text("Nenhum jogador nesta equipa.", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
child: Text("Nenhum jogador nesta equipa.", style: TextStyle(color: Colors.grey, fontSize: 16 * context.sf)),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
...players.map((p) => PersonCard(
|
...players.map((p) => PersonCard(
|
||||||
@@ -241,7 +283,7 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, p),
|
onEdit: () => _controller.showEditPersonDialog(context, widget.team.id, p),
|
||||||
onDelete: () => _confirmDelete(context, p),
|
onDelete: () => _confirmDelete(context, p),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 80),
|
SizedBox(height: 80 * context.sf),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -254,8 +296,8 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
heroTag: 'fab_team_${widget.team.id}',
|
heroTag: 'fab_team_${widget.team.id}',
|
||||||
onPressed: () => _controller.showAddPersonDialog(context, widget.team.id),
|
onPressed: () => _controller.showAddPersonDialog(context, widget.team.id),
|
||||||
backgroundColor: const Color(0xFF00C853),
|
backgroundColor: AppTheme.successGreen, // 👇 Cor de sucesso do tema
|
||||||
child: const Icon(Icons.add, color: Colors.white),
|
child: Icon(Icons.add, color: Colors.white, size: 24 * context.sf),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -264,16 +306,20 @@ class _TeamStatsPageState extends State<TeamStatsPage> {
|
|||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
title: const Text("Eliminar Membro?"),
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
content: Text("Tens a certeza que queres remover ${person.name}?"),
|
title: Text("Eliminar Membro?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||||
|
content: Text("Tens a certeza que queres remover ${person.name}?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text("Cancelar")),
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx),
|
||||||
|
child: const Text("Cancelar", style: TextStyle(color: Colors.grey))
|
||||||
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await _controller.deletePerson(person.id);
|
await _controller.deletePerson(person.id);
|
||||||
if (ctx.mounted) Navigator.pop(ctx);
|
if (ctx.mounted) Navigator.pop(ctx);
|
||||||
},
|
},
|
||||||
child: const Text("Eliminar", style: TextStyle(color: Colors.red)),
|
child: Text("Eliminar", style: TextStyle(color: AppTheme.primaryRed)), // 👇 Cor oficial
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -323,20 +369,27 @@ class StatsController {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => StatefulBuilder(
|
builder: (ctx) => StatefulBuilder(
|
||||||
builder: (ctx, setState) => AlertDialog(
|
builder: (ctx, setState) => AlertDialog(
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
title: Text(isEdit ? "Editar Membro" : "Novo Membro"),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||||
|
title: Text(
|
||||||
|
isEdit ? "Editar Membro" : "Novo Membro",
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface)
|
||||||
|
),
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: nameCtrl,
|
controller: nameCtrl,
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: const InputDecoration(labelText: "Nome Completo"),
|
decoration: const InputDecoration(labelText: "Nome Completo"),
|
||||||
textCapitalization: TextCapitalization.words,
|
textCapitalization: TextCapitalization.words,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
SizedBox(height: 15 * context.sf),
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: selectedType,
|
value: selectedType,
|
||||||
|
dropdownColor: Theme.of(context).colorScheme.surface,
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontSize: 16 * context.sf),
|
||||||
decoration: const InputDecoration(labelText: "Função"),
|
decoration: const InputDecoration(labelText: "Função"),
|
||||||
items: ["Jogador", "Treinador"]
|
items: ["Jogador", "Treinador"]
|
||||||
.map((e) => DropdownMenuItem(value: e, child: Text(e)))
|
.map((e) => DropdownMenuItem(value: e, child: Text(e)))
|
||||||
@@ -346,9 +399,10 @@ class StatsController {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (selectedType == "Jogador") ...[
|
if (selectedType == "Jogador") ...[
|
||||||
const SizedBox(height: 15),
|
SizedBox(height: 15 * context.sf),
|
||||||
TextField(
|
TextField(
|
||||||
controller: numCtrl,
|
controller: numCtrl,
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: const InputDecoration(labelText: "Número da Camisola"),
|
decoration: const InputDecoration(labelText: "Número da Camisola"),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
),
|
),
|
||||||
@@ -359,12 +413,13 @@ class StatsController {
|
|||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(ctx),
|
onPressed: () => Navigator.pop(ctx),
|
||||||
child: const Text("Cancelar")
|
child: const Text("Cancelar", style: TextStyle(color: Colors.grey))
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFF00C853),
|
backgroundColor: AppTheme.successGreen, // 👇 Cor verde do tema
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8 * context.sf))
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (nameCtrl.text.trim().isEmpty) return;
|
if (nameCtrl.text.trim().isEmpty) return;
|
||||||
@@ -397,12 +452,12 @@ class StatsController {
|
|||||||
errorMsg = "Já existe um membro com este numero na equipa.";
|
errorMsg = "Já existe um membro com este numero na equipa.";
|
||||||
}
|
}
|
||||||
ScaffoldMessenger.of(ctx).showSnackBar(
|
ScaffoldMessenger.of(ctx).showSnackBar(
|
||||||
SnackBar(content: Text(errorMsg), backgroundColor: Colors.red)
|
SnackBar(content: Text(errorMsg), backgroundColor: AppTheme.primaryRed) // 👇 Cor oficial para erro
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text("Guardar", style: TextStyle(color: Colors.white)),
|
child: const Text("Guardar"),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,15 +1 @@
|
|||||||
import 'package:flutter/material.dart';
|
// TODO Implement this library.
|
||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
// Esta extensão adiciona o superpoder "sf" ao BuildContext
|
|
||||||
extension SizeExtension on BuildContext {
|
|
||||||
|
|
||||||
double get sf {
|
|
||||||
final double wScreen = MediaQuery.of(this).size.width;
|
|
||||||
final double hScreen = MediaQuery.of(this).size.height;
|
|
||||||
|
|
||||||
// Calcula e devolve a escala na hora!
|
|
||||||
return math.min(wScreen, hScreen) / 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ import 'package:playmaker/pages/PlacarPage.dart';
|
|||||||
import '../controllers/team_controller.dart';
|
import '../controllers/team_controller.dart';
|
||||||
import '../controllers/game_controller.dart';
|
import '../controllers/game_controller.dart';
|
||||||
|
|
||||||
// --- CARD DE EXIBIÇÃO DO JOGO ---
|
|
||||||
class GameResultCard extends StatelessWidget {
|
class GameResultCard extends StatelessWidget {
|
||||||
final String gameId;
|
final String gameId;
|
||||||
final String myTeam, opponentTeam, myScore, opponentScore, status, season;
|
final String myTeam, opponentTeam, myScore, opponentScore, status, season;
|
||||||
@@ -27,9 +26,13 @@ class GameResultCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// 👇 Puxa as cores de fundo dependendo do Modo (Claro/Escuro)
|
||||||
|
final bgColor = Theme.of(context).colorScheme.surface;
|
||||||
|
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: 16 * sf),
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
padding: EdgeInsets.all(16 * sf),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(20 * sf),
|
borderRadius: BorderRadius.circular(20 * sf),
|
||||||
@@ -59,7 +62,7 @@ class GameResultCard extends StatelessWidget {
|
|||||||
? Icon(Icons.shield, color: Colors.white, size: 24 * sf)
|
? Icon(Icons.shield, color: Colors.white, size: 24 * sf)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
SizedBox(height: 6 * sf),
|
const SizedBox(height: 4),
|
||||||
Text(name,
|
Text(name,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * sf),
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * sf),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@@ -81,7 +84,7 @@ class GameResultCard extends StatelessWidget {
|
|||||||
_scoreBox(opponentScore, Colors.grey, sf),
|
_scoreBox(opponentScore, Colors.grey, sf),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10 * sf),
|
const SizedBox(height: 8),
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -104,16 +107,16 @@ class GameResultCard extends StatelessWidget {
|
|||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 6 * sf),
|
const SizedBox(height: 4),
|
||||||
Text(status, style: TextStyle(fontSize: 12 * sf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
Text(status, style: const TextStyle(fontSize: 10, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _scoreBox(String pts, Color c, double sf) => Container(
|
Widget _scoreBox(String pts, Color c) => Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 6 * sf),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * sf)),
|
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8)),
|
||||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf)),
|
child: Text(pts, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:playmaker/classe/home.config.dart';
|
||||||
|
|
||||||
class StatCard extends StatelessWidget {
|
class StatCard extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
@@ -10,11 +11,6 @@ class StatCard extends StatelessWidget {
|
|||||||
final bool isHighlighted;
|
final bool isHighlighted;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
// Variáveis novas para que o tamanho não fique preso à HomeConfig
|
|
||||||
final double sf;
|
|
||||||
final double cardWidth;
|
|
||||||
final double cardHeight;
|
|
||||||
|
|
||||||
const StatCard({
|
const StatCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
@@ -25,30 +21,27 @@ class StatCard extends StatelessWidget {
|
|||||||
required this.icon,
|
required this.icon,
|
||||||
this.isHighlighted = false,
|
this.isHighlighted = false,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.sf = 1.0, // Default 1.0 para não dar erro se não passares o valor
|
|
||||||
required this.cardWidth,
|
|
||||||
required this.cardHeight,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return Container(
|
||||||
width: cardWidth,
|
width: HomeConfig.cardwidthPadding,
|
||||||
height: cardHeight,
|
height: HomeConfig.cardheightPadding,
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20 * sf),
|
borderRadius: BorderRadius.circular(20),
|
||||||
side: isHighlighted
|
side: isHighlighted
|
||||||
? BorderSide(color: Colors.amber, width: 2 * sf)
|
? BorderSide(color: Colors.amber, width: 2)
|
||||||
: BorderSide.none,
|
: BorderSide.none,
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
borderRadius: BorderRadius.circular(20 * sf),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(20 * sf),
|
borderRadius: BorderRadius.circular(20),
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
@@ -59,14 +52,13 @@ class StatCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(16.0 * sf),
|
padding: const EdgeInsets.all(20.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Cabeçalho
|
// Cabeçalho
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -74,12 +66,12 @@ class StatCard extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
title.toUpperCase(),
|
title.toUpperCase(),
|
||||||
style: TextStyle(fontSize: 11 * sf, fontWeight: FontWeight.bold, color: Colors.white70),
|
style: HomeConfig.titleStyle,
|
||||||
),
|
),
|
||||||
SizedBox(height: 2 * sf),
|
SizedBox(height: 5),
|
||||||
Text(
|
Text(
|
||||||
playerName,
|
playerName,
|
||||||
style: TextStyle(fontSize: 14 * sf, fontWeight: FontWeight.bold, color: Colors.white),
|
style: HomeConfig.playerNameStyle,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
@@ -88,38 +80,38 @@ class StatCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (isHighlighted)
|
if (isHighlighted)
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(6 * sf),
|
padding: EdgeInsets.all(8),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.amber,
|
color: Colors.amber,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.star,
|
Icons.star,
|
||||||
size: 16 * sf,
|
size: 20,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 8 * sf),
|
SizedBox(height: 10),
|
||||||
|
|
||||||
// Ícone
|
// Ícone
|
||||||
Container(
|
Container(
|
||||||
width: 45 * sf,
|
width: 60,
|
||||||
height: 45 * sf,
|
height: 60,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.2),
|
color: Colors.white.withOpacity(0.2),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
icon,
|
icon,
|
||||||
size: 24 * sf,
|
size: 30,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const Spacer(),
|
Spacer(),
|
||||||
|
|
||||||
// Estatística
|
// Estatística
|
||||||
Center(
|
Center(
|
||||||
@@ -127,26 +119,26 @@ class StatCard extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
statValue,
|
statValue,
|
||||||
style: TextStyle(fontSize: 34 * sf, fontWeight: FontWeight.bold, color: Colors.white),
|
style: HomeConfig.statValueStyle,
|
||||||
),
|
),
|
||||||
SizedBox(height: 2 * sf),
|
SizedBox(height: 5),
|
||||||
Text(
|
Text(
|
||||||
statLabel.toUpperCase(),
|
statLabel.toUpperCase(),
|
||||||
style: TextStyle(fontSize: 12 * sf, color: Colors.white70),
|
style: HomeConfig.statLabelStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const Spacer(),
|
Spacer(),
|
||||||
|
|
||||||
// Botão
|
// Botão
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: EdgeInsets.symmetric(vertical: 8 * sf),
|
padding: EdgeInsets.symmetric(vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.2),
|
color: Colors.white.withOpacity(0.2),
|
||||||
borderRadius: BorderRadius.circular(10 * sf),
|
borderRadius: BorderRadius.circular(15),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -154,7 +146,7 @@ class StatCard extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 11 * sf,
|
fontSize: 14,
|
||||||
letterSpacing: 1,
|
letterSpacing: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -177,12 +169,12 @@ class SportGrid extends StatelessWidget {
|
|||||||
const SportGrid({
|
const SportGrid({
|
||||||
super.key,
|
super.key,
|
||||||
required this.children,
|
required this.children,
|
||||||
this.spacing = 20.0, // Valor padrão se não for passado nada
|
this.spacing = HomeConfig.cardSpacing,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (children.isEmpty) return const SizedBox();
|
if (children.isEmpty) return SizedBox();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:playmaker/controllers/login_controller.dart';
|
import 'package:playmaker/controllers/login_controller.dart';
|
||||||
import 'package:playmaker/pages/RegisterPage.dart';
|
import 'package:playmaker/pages/RegisterPage.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||||
|
import '../utils/size_extension.dart';
|
||||||
|
|
||||||
class BasketTrackHeader extends StatelessWidget {
|
class BasketTrackHeader extends StatelessWidget {
|
||||||
const BasketTrackHeader({super.key});
|
const BasketTrackHeader({super.key});
|
||||||
@@ -11,7 +12,7 @@ class BasketTrackHeader extends StatelessWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 200 * context.sf, // Ajusta o tamanho da imagem suavemente
|
width: 200 * context.sf,
|
||||||
height: 200 * context.sf,
|
height: 200 * context.sf,
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/playmaker-logos.png',
|
'assets/playmaker-logos.png',
|
||||||
@@ -23,7 +24,7 @@ class BasketTrackHeader extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 36 * context.sf,
|
fontSize: 36 * context.sf,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.grey[900],
|
color: Theme.of(context).colorScheme.onSurface, // 👇 Adaptável ao Modo Escuro
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 6 * context.sf),
|
SizedBox(height: 6 * context.sf),
|
||||||
@@ -31,7 +32,7 @@ class BasketTrackHeader extends StatelessWidget {
|
|||||||
'Gere as tuas equipas e estatísticas',
|
'Gere as tuas equipas e estatísticas',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16 * context.sf,
|
fontSize: 16 * context.sf,
|
||||||
color: Colors.grey[600],
|
color: Colors.grey, // Mantemos cinza para subtítulo
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@@ -52,13 +53,17 @@ class LoginFormFields extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: controller.emailController,
|
controller: controller.emailController,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'E-mail',
|
labelText: 'E-mail',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.email_outlined, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.email_outlined, size: 22 * context.sf, color: AppTheme.primaryRed), // 👇 Cor do tema
|
||||||
errorText: controller.emailError,
|
errorText: controller.emailError,
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2), // 👇 Cor do tema ao focar
|
||||||
|
),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
@@ -67,16 +72,21 @@ class LoginFormFields extends StatelessWidget {
|
|||||||
TextField(
|
TextField(
|
||||||
controller: controller.passwordController,
|
controller: controller.passwordController,
|
||||||
obscureText: controller.obscurePassword,
|
obscureText: controller.obscurePassword,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Palavra-passe',
|
labelText: 'Palavra-passe',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.lock_outlined, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.lock_outlined, size: 22 * context.sf, color: AppTheme.primaryRed), // 👇 Cor do tema
|
||||||
errorText: controller.passwordError,
|
errorText: controller.passwordError,
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2), // 👇 Cor do tema ao focar
|
||||||
|
),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
controller.obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
controller.obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
||||||
size: 22 * context.sf
|
size: 22 * context.sf,
|
||||||
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onPressed: controller.togglePasswordVisibility,
|
onPressed: controller.togglePasswordVisibility,
|
||||||
),
|
),
|
||||||
@@ -106,7 +116,7 @@ class LoginButton extends StatelessWidget {
|
|||||||
if (success) onLoginSuccess();
|
if (success) onLoginSuccess();
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFE74C3C),
|
backgroundColor: AppTheme.primaryRed, // 👇 Usando a cor do tema
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
||||||
elevation: 3,
|
elevation: 3,
|
||||||
@@ -135,8 +145,8 @@ class CreateAccountButton extends StatelessWidget {
|
|||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const RegisterPage()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => const RegisterPage()));
|
||||||
},
|
},
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
foregroundColor: const Color(0xFFE74C3C),
|
foregroundColor: AppTheme.primaryRed, // 👇 Usando a cor do tema
|
||||||
side: BorderSide(color: const Color(0xFFE74C3C), width: 2 * context.sf),
|
side: BorderSide(color: AppTheme.primaryRed, width: 2 * context.sf), // 👇 Usando a cor do tema
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
||||||
),
|
),
|
||||||
child: Text('Criar Conta', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
child: Text('Criar Conta', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||||
|
|||||||
@@ -1,117 +1,86 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:playmaker/controllers/placar_controller.dart';
|
import 'package:playmaker/controllers/placar_controller.dart';
|
||||||
|
import 'package:playmaker/zone_map_dialog.dart';
|
||||||
|
|
||||||
// --- PLACAR SUPERIOR ---
|
// ============================================================================
|
||||||
|
// 1. PLACAR SUPERIOR (CRONÓMETRO E RESULTADO)
|
||||||
|
// ============================================================================
|
||||||
class TopScoreboard extends StatelessWidget {
|
class TopScoreboard extends StatelessWidget {
|
||||||
final PlacarController controller;
|
final PlacarController controller;
|
||||||
final double sf;
|
const TopScoreboard({super.key, required this.controller});
|
||||||
|
|
||||||
const TopScoreboard({super.key, required this.controller, required this.sf});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10 * sf, horizontal: 35 * sf),
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 30),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF16202C),
|
color: const Color(0xFF16202C),
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(15), bottomRight: Radius.circular(15)),
|
||||||
bottomLeft: Radius.circular(22 * sf),
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
bottomRight: Radius.circular(22 * sf)
|
|
||||||
),
|
|
||||||
border: Border.all(color: Colors.white, width: 2.5 * sf),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildTeamSection(controller.myTeam, controller.myScore, controller.myFouls, controller.myTimeoutsUsed, const Color(0xFF1E5BB2), false, sf),
|
_buildTeamSection(controller.myTeam, controller.myScore, controller.myFouls, controller.myTimeoutsUsed, const Color(0xFF1E5BB2), false),
|
||||||
SizedBox(width: 30 * sf),
|
const SizedBox(width: 25),
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 18 * sf, vertical: 5 * sf),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: const Color(0xFF2C3E50), borderRadius: BorderRadius.circular(6)),
|
||||||
color: const Color(0xFF2C3E50),
|
child: Text(controller.formatTime(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, fontFamily: 'monospace')),
|
||||||
borderRadius: BorderRadius.circular(9 * sf)
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
controller.formatTime(),
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 28 * sf, fontWeight: FontWeight.w900, fontFamily: 'monospace', letterSpacing: 2 * sf)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: 5 * sf),
|
|
||||||
Text(
|
|
||||||
"PERÍODO ${controller.currentQuarter}",
|
|
||||||
style: TextStyle(color: Colors.orangeAccent, fontSize: 14 * sf, fontWeight: FontWeight.w900)
|
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Text("PERÍODO ${controller.currentQuarter}", style: const TextStyle(color: Colors.orangeAccent, fontSize: 14, fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 30 * sf),
|
const SizedBox(width: 25),
|
||||||
_buildTeamSection(controller.opponentTeam, controller.opponentScore, controller.opponentFouls, controller.opponentTimeoutsUsed, const Color(0xFFD92C2C), true, sf),
|
_buildTeamSection(controller.opponentTeam, controller.opponentScore, controller.opponentFouls, controller.opponentTimeoutsUsed, const Color(0xFFD92C2C), true),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTeamSection(String name, int score, int fouls, int timeouts, Color color, bool isOpp, double sf) {
|
Widget _buildTeamSection(String name, int score, int fouls, int timeouts, Color color, bool isOpp) {
|
||||||
int displayFouls = fouls > 5 ? 5 : fouls;
|
|
||||||
|
|
||||||
final timeoutIndicators = Row(
|
final timeoutIndicators = Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: List.generate(3, (index) => Container(
|
children: List.generate(3, (index) => Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 3.5 * sf),
|
margin: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
width: 12 * sf, height: 12 * sf,
|
width: 12, height: 12,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(shape: BoxShape.circle, color: index < timeouts ? Colors.yellow : Colors.grey.shade600, border: Border.all(color: Colors.black26)),
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: index < timeouts ? Colors.yellow : Colors.grey.shade600,
|
|
||||||
border: Border.all(color: Colors.white54, width: 1.5 * sf)
|
|
||||||
),
|
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
return Row(
|
||||||
List<Widget> content = [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Column(
|
children: isOpp
|
||||||
children: [
|
? [
|
||||||
_scoreBox(score, color, sf),
|
Column(children: [_scoreBox(score, color), const SizedBox(height: 4), Text("FALTAS: $fouls", style: TextStyle(color: fouls >= 5 ? Colors.red : Colors.yellowAccent, fontSize: 12, fontWeight: FontWeight.bold)), timeoutIndicators]),
|
||||||
SizedBox(height: 7 * sf),
|
const SizedBox(width: 15),
|
||||||
timeoutIndicators
|
Text(name.toUpperCase(), style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold))
|
||||||
]
|
]
|
||||||
),
|
: [
|
||||||
SizedBox(width: 18 * sf),
|
Text(name.toUpperCase(), style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
Column(
|
const SizedBox(width: 15),
|
||||||
crossAxisAlignment: isOpp ? CrossAxisAlignment.start : CrossAxisAlignment.end,
|
Column(children: [_scoreBox(score, color), const SizedBox(height: 4), Text("FALTAS: $fouls", style: TextStyle(color: fouls >= 5 ? Colors.red : Colors.yellowAccent, fontSize: 12, fontWeight: FontWeight.bold)), timeoutIndicators])
|
||||||
children: [
|
]
|
||||||
Text(
|
);
|
||||||
name.toUpperCase(),
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 20 * sf, fontWeight: FontWeight.w900, letterSpacing: 1.2 * sf)
|
|
||||||
),
|
|
||||||
SizedBox(height: 5 * sf),
|
|
||||||
Text(
|
|
||||||
"FALTAS: $displayFouls",
|
|
||||||
style: TextStyle(color: displayFouls >= 5 ? Colors.redAccent : Colors.yellowAccent, fontSize: 13 * sf, fontWeight: FontWeight.bold)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
return Row(crossAxisAlignment: CrossAxisAlignment.center, children: isOpp ? content : content.reversed.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _scoreBox(int score, Color color, double sf) => Container(
|
Widget _scoreBox(int score, Color color) => Container(
|
||||||
width: 58 * sf, height: 45 * sf,
|
width: 50, height: 40,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(7 * sf)),
|
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(6)),
|
||||||
child: Text(score.toString(), style: TextStyle(color: Colors.white, fontSize: 26 * sf, fontWeight: FontWeight.w900)),
|
child: Text(score.toString(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- BANCO DE SUPLENTES ---
|
// ============================================================================
|
||||||
|
// 2. BANCO DE SUPLENTES (DRAG & DROP)
|
||||||
|
// ============================================================================
|
||||||
class BenchPlayersList extends StatelessWidget {
|
class BenchPlayersList extends StatelessWidget {
|
||||||
final PlacarController controller;
|
final PlacarController controller;
|
||||||
final bool isOpponent;
|
final bool isOpponent;
|
||||||
final double sf;
|
const BenchPlayersList({super.key, required this.controller, required this.isOpponent});
|
||||||
|
|
||||||
const BenchPlayersList({super.key, required this.controller, required this.isOpponent, required this.sf});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -127,45 +96,24 @@ class BenchPlayersList extends StatelessWidget {
|
|||||||
final bool isFouledOut = fouls >= 5;
|
final bool isFouledOut = fouls >= 5;
|
||||||
|
|
||||||
Widget avatarUI = Container(
|
Widget avatarUI = Container(
|
||||||
margin: EdgeInsets.only(bottom: 7 * sf),
|
margin: const EdgeInsets.only(bottom: 5),
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(color: Colors.white, width: 1.8 * sf),
|
|
||||||
boxShadow: [BoxShadow(color: Colors.black45, blurRadius: 5 * sf, offset: Offset(0, 2.5 * sf))]
|
|
||||||
),
|
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 22 * sf,
|
backgroundColor: isFouledOut ? Colors.grey.shade700 : teamColor,
|
||||||
backgroundColor: isFouledOut ? Colors.grey.shade800 : teamColor,
|
child: Text(num, style: TextStyle(color: isFouledOut ? Colors.red.shade300 : Colors.white, fontSize: 14, decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none)),
|
||||||
child: Text(
|
|
||||||
num,
|
|
||||||
style: TextStyle(
|
|
||||||
color: isFouledOut ? Colors.red.shade300 : Colors.white,
|
|
||||||
fontSize: 16 * sf,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isFouledOut) {
|
if (isFouledOut) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('🛑 $playerName não pode voltar (Expulso).'), backgroundColor: Colors.red)),
|
onTap: () => ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('🛑 $playerName não pode voltar (Expulso).'), backgroundColor: Colors.red)),
|
||||||
child: avatarUI
|
child: avatarUI,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Draggable<String>(
|
return Draggable<String>(
|
||||||
data: "$prefix$playerName",
|
data: "$prefix$playerName",
|
||||||
feedback: Material(
|
feedback: Material(color: Colors.transparent, child: CircleAvatar(backgroundColor: teamColor, child: Text(num, style: const TextStyle(color: Colors.white)))),
|
||||||
color: Colors.transparent,
|
childWhenDragging: const Opacity(opacity: 0.5, child: SizedBox(width: 40, height: 40)),
|
||||||
child: CircleAvatar(
|
|
||||||
radius: 28 * sf,
|
|
||||||
backgroundColor: teamColor,
|
|
||||||
child: Text(num, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18 * sf))
|
|
||||||
)
|
|
||||||
),
|
|
||||||
childWhenDragging: Opacity(opacity: 0.5, child: SizedBox(width: 45 * sf, height: 45 * sf)),
|
|
||||||
child: avatarUI,
|
child: avatarUI,
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
@@ -173,14 +121,18 @@ class BenchPlayersList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CARTÃO DO JOGADOR NO CAMPO ---
|
// ============================================================================
|
||||||
|
// 3. CARTÃO DO JOGADOR NO CAMPO (TARGET DE FALTAS/PONTOS/SUBSTITUIÇÕES)
|
||||||
|
// ============================================================================
|
||||||
|
// ============================================================================
|
||||||
|
// 3. CARTÃO DO JOGADOR NO CAMPO (AGORA ABRE O POPUP AMARELO)
|
||||||
|
// ============================================================================
|
||||||
class PlayerCourtCard extends StatelessWidget {
|
class PlayerCourtCard extends StatelessWidget {
|
||||||
final PlacarController controller;
|
final PlacarController controller;
|
||||||
final String name;
|
final String name;
|
||||||
final bool isOpponent;
|
final bool isOpponent;
|
||||||
final double sf;
|
|
||||||
|
|
||||||
const PlayerCourtCard({super.key, required this.controller, required this.name, required this.isOpponent, required this.sf});
|
const PlayerCourtCard({super.key, required this.controller, required this.name, required this.isOpponent});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -194,25 +146,46 @@ class PlayerCourtCard extends StatelessWidget {
|
|||||||
feedback: Material(
|
feedback: Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 18 * sf, vertical: 11 * sf),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
decoration: BoxDecoration(color: teamColor.withOpacity(0.9), borderRadius: BorderRadius.circular(9 * sf)),
|
decoration: BoxDecoration(color: teamColor.withOpacity(0.9), borderRadius: BorderRadius.circular(8)),
|
||||||
child: Text(name, style: TextStyle(color: Colors.white, fontSize: 20 * sf, fontWeight: FontWeight.bold)),
|
child: Text(name, style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
childWhenDragging: Opacity(opacity: 0.5, child: _playerCardUI(number, name, stats, teamColor, false, false, sf)),
|
childWhenDragging: Opacity(opacity: 0.5, child: _playerCardUI(number, name, stats, teamColor, false, false)),
|
||||||
child: DragTarget<String>(
|
child: DragTarget<String>(
|
||||||
onAcceptWithDetails: (details) {
|
onAcceptWithDetails: (details) {
|
||||||
final action = details.data;
|
final action = details.data;
|
||||||
if (action.startsWith("add_") || action.startsWith("sub_") || action.startsWith("miss_")) {
|
|
||||||
|
// 👇 SE FOR UM LANÇAMENTO DE CAMPO (2 OU 3 PONTOS), ABRE O POPUP AMARELO!
|
||||||
|
if (action == "add_pts_2" || action == "add_pts_3" || action == "miss_2" || action == "miss_3") {
|
||||||
|
bool isMake = action.startsWith("add_");
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => ZoneMapDialog(
|
||||||
|
playerName: name,
|
||||||
|
isMake: isMake,
|
||||||
|
onZoneSelected: (zone, points, relX, relY) {
|
||||||
|
Navigator.pop(ctx); // Fecha o popup amarelo
|
||||||
|
|
||||||
|
// 👇 MANDA OS DADOS PARA O CONTROLLER! (Vais ter de criar esta função no PlacarController)
|
||||||
|
controller.registerShotFromPopup(context, action, "$prefix$name", zone, points, relX, relY);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Se for 1 Ponto (Lance Livre), Falta, Ressalto ou Roubo, FAZ TUDO NORMAL!
|
||||||
|
else if (action.startsWith("add_") || action.startsWith("sub_") || action.startsWith("miss_")) {
|
||||||
controller.handleActionDrag(context, action, "$prefix$name");
|
controller.handleActionDrag(context, action, "$prefix$name");
|
||||||
} else if (action.startsWith("bench_")) {
|
}
|
||||||
|
else if (action.startsWith("bench_")) {
|
||||||
controller.handleSubbing(context, action, name, isOpponent);
|
controller.handleSubbing(context, action, name, isOpponent);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, candidateData, rejectedData) {
|
builder: (context, candidateData, rejectedData) {
|
||||||
bool isSubbing = candidateData.any((data) => data != null && (data.startsWith("bench_my_") || data.startsWith("bench_opp_")));
|
bool isSubbing = candidateData.any((data) => data != null && (data.startsWith("bench_my_") || data.startsWith("bench_opp_")));
|
||||||
bool isActionHover = candidateData.any((data) => data != null && (data.startsWith("add_") || data.startsWith("sub_") || data.startsWith("miss_")));
|
bool isActionHover = candidateData.any((data) => data != null && (data.startsWith("add_") || data.startsWith("sub_") || data.startsWith("miss_")));
|
||||||
return _playerCardUI(number, name, stats, teamColor, isSubbing, isActionHover, sf);
|
return _playerCardUI(number, name, stats, teamColor, isSubbing, isActionHover);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -220,7 +193,7 @@ class PlayerCourtCard extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _playerCardUI(String number, String name, Map<String, int> stats, Color teamColor, bool isSubbing, bool isActionHover, double sf) {
|
Widget _playerCardUI(String number, String name, Map<String, int> stats, Color teamColor, bool isSubbing, bool isActionHover, double sf) {
|
||||||
bool isFouledOut = stats["fls"]! >= 5;
|
bool isFouledOut = stats["fls"]! >= 5;
|
||||||
Color bgColor = isFouledOut ? Colors.red.shade50 : Colors.white;
|
Color bgColor = isFouledOut ? Colors.red.shade100 : Colors.white;
|
||||||
Color borderColor = isFouledOut ? Colors.redAccent : Colors.transparent;
|
Color borderColor = isFouledOut ? Colors.redAccent : Colors.transparent;
|
||||||
|
|
||||||
if (isSubbing) {
|
if (isSubbing) {
|
||||||
@@ -235,11 +208,10 @@ class PlayerCourtCard extends StatelessWidget {
|
|||||||
String displayName = name.length > 12 ? "${name.substring(0, 10)}..." : name;
|
String displayName = name.length > 12 ? "${name.substring(0, 10)}..." : name;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: bgColor,
|
color: bgColor, borderRadius: BorderRadius.circular(12), border: Border.all(color: borderColor, width: 2),
|
||||||
borderRadius: BorderRadius.circular(11 * sf),
|
boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 6, offset: Offset(0, 3))],
|
||||||
border: Border.all(color: borderColor, width: 1.8 * sf),
|
|
||||||
boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 5 * sf, offset: Offset(2 * sf, 3.5 * sf))],
|
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(9 * sf),
|
borderRadius: BorderRadius.circular(9 * sf),
|
||||||
@@ -284,12 +256,12 @@ class PlayerCourtCard extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- PAINEL DE BOTÕES DE AÇÃO ---
|
// ============================================================================
|
||||||
|
// 4. PAINEL DE BOTÕES DE AÇÃO (PONTOS, RESSALTOS, ETC)
|
||||||
|
// ============================================================================
|
||||||
class ActionButtonsPanel extends StatelessWidget {
|
class ActionButtonsPanel extends StatelessWidget {
|
||||||
final PlacarController controller;
|
final PlacarController controller;
|
||||||
final double sf;
|
const ActionButtonsPanel({super.key, required this.controller});
|
||||||
|
|
||||||
const ActionButtonsPanel({super.key, required this.controller, required this.sf});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -302,109 +274,108 @@ class ActionButtonsPanel extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
_columnBtn([
|
_columnBtn([
|
||||||
_dragAndTargetBtn("M1", Colors.redAccent, "miss_1", baseSize, feedSize, sf),
|
_actionBtn("T.O", const Color(0xFF1E5BB2), () => controller.useTimeout(false), labelSize: 20),
|
||||||
_dragAndTargetBtn("1", Colors.orange, "add_pts_1", baseSize, feedSize, sf),
|
_dragAndTargetBtn("1", Colors.orange, "add_pts_1"),
|
||||||
_dragAndTargetBtn("1", Colors.orange, "sub_pts_1", baseSize, feedSize, sf, isX: true),
|
_dragAndTargetBtn("1", Colors.orange, "sub_pts_1", isX: true),
|
||||||
_dragAndTargetBtn("STL", Colors.green, "add_stl", baseSize, feedSize, sf),
|
_dragAndTargetBtn("STL", Colors.green, "add_stl"),
|
||||||
], gap),
|
|
||||||
SizedBox(width: gap * 1),
|
]),
|
||||||
|
const SizedBox(width: 15),
|
||||||
_columnBtn([
|
_columnBtn([
|
||||||
_dragAndTargetBtn("M2", Colors.redAccent, "miss_2", baseSize, feedSize, sf),
|
_dragAndTargetBtn("M2", Colors.redAccent, "miss_2"),
|
||||||
_dragAndTargetBtn("2", Colors.orange, "add_pts_2", baseSize, feedSize, sf),
|
_dragAndTargetBtn("2", Colors.orange, "add_pts_2"),
|
||||||
_dragAndTargetBtn("2", Colors.orange, "sub_pts_2", baseSize, feedSize, sf, isX: true),
|
_dragAndTargetBtn("2", Colors.orange, "sub_pts_2", isX: true),
|
||||||
_dragAndTargetBtn("AST", Colors.blueGrey, "add_ast", baseSize, feedSize, sf),
|
_dragAndTargetBtn("AST", Colors.blueGrey, "add_ast"),
|
||||||
], gap),
|
]),
|
||||||
SizedBox(width: gap * 1),
|
const SizedBox(width: 15),
|
||||||
_columnBtn([
|
_columnBtn([
|
||||||
_dragAndTargetBtn("M3", Colors.redAccent, "miss_3", baseSize, feedSize, sf),
|
_dragAndTargetBtn("M3", Colors.redAccent, "miss_3"),
|
||||||
_dragAndTargetBtn("3", Colors.orange, "add_pts_3", baseSize, feedSize, sf),
|
_dragAndTargetBtn("3", Colors.orange, "add_pts_3"),
|
||||||
_dragAndTargetBtn("3", Colors.orange, "sub_pts_3", baseSize, feedSize, sf, isX: true),
|
_dragAndTargetBtn("3", Colors.orange, "sub_pts_3", isX: true),
|
||||||
_dragAndTargetBtn("TOV", Colors.redAccent, "add_tov", baseSize, feedSize, sf),
|
_dragAndTargetBtn("TOV", Colors.redAccent, "add_tov"),
|
||||||
], gap),
|
]),
|
||||||
SizedBox(width: gap * 1),
|
const SizedBox(width: 15),
|
||||||
_columnBtn([
|
_columnBtn([
|
||||||
_dragAndTargetBtn("ORB", const Color(0xFF1E2A38), "add_orb", baseSize, feedSize, sf, icon: Icons.sports_basketball),
|
_actionBtn("T.O", const Color(0xFFD92C2C), () => controller.useTimeout(true), labelSize: 20),
|
||||||
_dragAndTargetBtn("DRB", const Color(0xFF1E2A38), "add_drb", baseSize, feedSize, sf, icon: Icons.sports_basketball),
|
_dragAndTargetBtn("ORB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
|
||||||
_dragAndTargetBtn("BLK", Colors.deepPurple, "add_blk", baseSize, feedSize, sf, icon: Icons.front_hand),
|
_dragAndTargetBtn("DRB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
|
||||||
], gap),
|
|
||||||
|
_dragAndTargetBtn("BLK", Colors.deepPurple, "add_blk", icon: Icons.front_hand),
|
||||||
|
]),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
_columnBtn([
|
||||||
|
])
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _columnBtn(List<Widget> children, double gap) {
|
// Mantenha os métodos _columnBtn, _dragAndTargetBtn, _actionBtn e _circle exatamente como estão
|
||||||
return Column(
|
Widget _columnBtn(List<Widget> children) => Column(mainAxisSize: MainAxisSize.min, children: children.map((c) => Padding(padding: const EdgeInsets.only(bottom: 8), child: c)).toList());
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: children.map((c) => Padding(padding: EdgeInsets.only(bottom: gap), child: c)).toList()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _dragAndTargetBtn(String label, Color color, String actionData, double baseSize, double feedSize, double sf, {IconData? icon, bool isX = false}) {
|
Widget _dragAndTargetBtn(String label, Color color, String actionData, {IconData? icon, bool isX = false}) {
|
||||||
return Draggable<String>(
|
return Draggable<String>(
|
||||||
data: actionData,
|
data: actionData,
|
||||||
feedback: _circle(label, color, icon, true, baseSize, feedSize, sf, isX: isX),
|
feedback: _circle(label, color, icon, true, isX: isX),
|
||||||
childWhenDragging: Opacity(
|
childWhenDragging: Opacity(opacity: 0.5, child: _circle(label, color, icon, false, isX: isX)),
|
||||||
opacity: 0.5,
|
|
||||||
child: _circle(label, color, icon, false, baseSize, feedSize, sf, isX: isX)
|
|
||||||
),
|
|
||||||
child: DragTarget<String>(
|
child: DragTarget<String>(
|
||||||
onAcceptWithDetails: (details) {},
|
onAcceptWithDetails: (details) {},
|
||||||
builder: (context, candidateData, rejectedData) {
|
builder: (context, candidateData, rejectedData) {
|
||||||
bool isHovered = candidateData.any((data) => data != null && data.startsWith("player_"));
|
bool isHovered = candidateData.any((data) => data != null && data.startsWith("player_"));
|
||||||
return Transform.scale(
|
return Transform.scale(
|
||||||
scale: isHovered ? 1.15 : 1.0,
|
scale: isHovered ? 1.15 : 1.0,
|
||||||
child: Container(
|
child: Container(decoration: isHovered ? BoxDecoration(shape: BoxShape.circle, boxShadow: const [BoxShadow(color: Colors.white, blurRadius: 10, spreadRadius: 3)]) : null, child: _circle(label, color, icon, false, isX: isX)),
|
||||||
decoration: isHovered ? BoxDecoration(shape: BoxShape.circle, boxShadow: [BoxShadow(color: Colors.white, blurRadius: 10 * sf, spreadRadius: 3 * sf)]) : null,
|
|
||||||
child: _circle(label, color, icon, false, baseSize, feedSize, sf, isX: isX)
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _circle(String label, Color color, IconData? icon, bool isFeed, double baseSize, double feedSize, double sf, {bool isX = false}) {
|
Widget _actionBtn(String label, Color color, VoidCallback onTap, {IconData? icon, bool isX = false, double labelSize = 24}) {
|
||||||
double size = isFeed ? feedSize : baseSize;
|
return GestureDetector(onTap: onTap, child: _circle(label, color, icon, false, fontSize: labelSize, isX: isX));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _circle(String label, Color color, IconData? icon, bool isFeed, {double fontSize = 20, bool isX = false}) {
|
||||||
Widget content;
|
Widget content;
|
||||||
bool isPointBtn = label == "1" || label == "2" || label == "3" || label == "M1" || label == "M2" || label == "M3";
|
bool isPointBtn = label == "1" || label == "2" || label == "3" || label == "M2" || label == "M3";
|
||||||
bool isBlkBtn = label == "BLK";
|
bool isBlkBtn = label == "BLK";
|
||||||
|
|
||||||
if (isPointBtn) {
|
if (isPointBtn) {
|
||||||
content = Stack(
|
content = Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(width: size * 0.75, height: size * 0.75, decoration: const BoxDecoration(color: Colors.black, shape: BoxShape.circle)),
|
Container(width: isFeed ? 55 : 45, height: isFeed ? 55 : 45, decoration: const BoxDecoration(color: Colors.black, shape: BoxShape.circle)),
|
||||||
Icon(Icons.sports_basketball, color: color, size: size * 0.9),
|
Icon(Icons.sports_basketball, color: color, size: isFeed ? 65 : 55),
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: TextStyle(fontSize: size * 0.38, fontWeight: FontWeight.w900, foreground: Paint()..style = PaintingStyle.stroke..strokeWidth = size * 0.05..color = Colors.white, decoration: TextDecoration.none)),
|
Text(label, style: TextStyle(fontSize: isFeed ? 26 : 22, fontWeight: FontWeight.w900, foreground: Paint()..style = PaintingStyle.stroke..strokeWidth = 3..color = Colors.white, decoration: TextDecoration.none)),
|
||||||
Text(label, style: TextStyle(fontSize: size * 0.38, fontWeight: FontWeight.w900, color: Colors.black, decoration: TextDecoration.none)),
|
Text(label, style: TextStyle(fontSize: isFeed ? 26 : 22, fontWeight: FontWeight.w900, color: Colors.black, decoration: TextDecoration.none)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (isBlkBtn) {
|
}
|
||||||
|
else if (isBlkBtn) {
|
||||||
content = Stack(
|
content = Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.front_hand, color: const Color.fromARGB(207, 56, 52, 52), size: size * 0.75),
|
Icon(Icons.front_hand, color: const Color.fromARGB(207, 56, 52, 52), size: isFeed ? 55 : 45),
|
||||||
Stack(
|
Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: TextStyle(fontSize: size * 0.28, fontWeight: FontWeight.w900, foreground: Paint()..style = PaintingStyle.stroke..strokeWidth = size * 0.05..color = Colors.black, decoration: TextDecoration.none)),
|
Text(label, style: TextStyle(fontSize: isFeed ? 18 : 16, fontWeight: FontWeight.w900, foreground: Paint()..style = PaintingStyle.stroke..strokeWidth = 3..color = Colors.black, decoration: TextDecoration.none)),
|
||||||
Text(label, style: TextStyle(fontSize: size * 0.28, fontWeight: FontWeight.w900, color: Colors.white, decoration: TextDecoration.none)),
|
Text(label, style: TextStyle(fontSize: isFeed ? 18 : 16, fontWeight: FontWeight.w900, color: Colors.white, decoration: TextDecoration.none)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (icon != null) {
|
} else if (icon != null) {
|
||||||
content = Icon(icon, color: Colors.white, size: size * 0.5);
|
content = Icon(icon, color: Colors.white, size: 30);
|
||||||
} else {
|
} else {
|
||||||
content = Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: size * 0.35, decoration: TextDecoration.none));
|
content = Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: fontSize, decoration: TextDecoration.none));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none, alignment: Alignment.bottomRight,
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: size, height: size,
|
width: size, height: size,
|
||||||
@@ -412,8 +383,9 @@ class ActionButtonsPanel extends StatelessWidget {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: content,
|
child: content,
|
||||||
),
|
),
|
||||||
if (isX) Positioned(top: 0, right: 0, child: Container(decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle), child: Icon(Icons.cancel, color: Colors.red, size: size * 0.4))),
|
if (isX) Positioned(top: 0, right: 0, child: Container(decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle), child: Icon(Icons.cancel, color: Colors.red, size: isFeed ? 28 : 24))),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||||
import '../controllers/register_controller.dart';
|
import '../controllers/register_controller.dart';
|
||||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||||
|
|
||||||
@@ -9,16 +10,20 @@ class RegisterHeader extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.person_add_outlined, size: 100 * context.sf, color: const Color(0xFFE74C3C)),
|
Icon(Icons.person_add_outlined, size: 100 * context.sf, color: AppTheme.primaryRed), // 👇 Cor do tema
|
||||||
SizedBox(height: 10 * context.sf),
|
SizedBox(height: 10 * context.sf),
|
||||||
Text(
|
Text(
|
||||||
'Nova Conta',
|
'Nova Conta',
|
||||||
style: TextStyle(fontSize: 36 * context.sf, fontWeight: FontWeight.bold, color: Colors.grey[900]),
|
style: TextStyle(
|
||||||
|
fontSize: 36 * context.sf,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface, // 👇 Adaptável ao Modo Escuro
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5 * context.sf),
|
SizedBox(height: 5 * context.sf),
|
||||||
Text(
|
Text(
|
||||||
'Cria o teu perfil no BasketTrack',
|
'Cria o teu perfil no BasketTrack',
|
||||||
style: TextStyle(fontSize: 16 * context.sf, color: Colors.grey[600], fontWeight: FontWeight.w500),
|
style: TextStyle(fontSize: 16 * context.sf, color: Colors.grey, fontWeight: FontWeight.w500),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -45,12 +50,16 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
|||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: widget.controller.nameController,
|
controller: widget.controller.nameController,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Nome Completo',
|
labelText: 'Nome Completo',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.person_outline, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.person_outline, size: 22 * context.sf, color: AppTheme.primaryRed), // 👇 Cor do tema
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2), // 👇 Destaque ao focar
|
||||||
|
),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -59,12 +68,16 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
controller: widget.controller.emailController,
|
controller: widget.controller.emailController,
|
||||||
validator: widget.controller.validateEmail,
|
validator: widget.controller.validateEmail,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'E-mail',
|
labelText: 'E-mail',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.email_outlined, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.email_outlined, size: 22 * context.sf, color: AppTheme.primaryRed),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2),
|
||||||
|
),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
@@ -75,13 +88,17 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
|||||||
controller: widget.controller.passwordController,
|
controller: widget.controller.passwordController,
|
||||||
obscureText: _obscurePassword,
|
obscureText: _obscurePassword,
|
||||||
validator: widget.controller.validatePassword,
|
validator: widget.controller.validatePassword,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Palavra-passe',
|
labelText: 'Palavra-passe',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.lock_outlined, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.lock_outlined, size: 22 * context.sf, color: AppTheme.primaryRed),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2),
|
||||||
|
),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined, size: 22 * context.sf),
|
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined, size: 22 * context.sf, color: Colors.grey),
|
||||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||||
),
|
),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||||
@@ -94,11 +111,15 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
|||||||
controller: widget.controller.confirmPasswordController,
|
controller: widget.controller.confirmPasswordController,
|
||||||
obscureText: _obscurePassword,
|
obscureText: _obscurePassword,
|
||||||
validator: widget.controller.validateConfirmPassword,
|
validator: widget.controller.validateConfirmPassword,
|
||||||
style: TextStyle(fontSize: 15 * context.sf),
|
style: TextStyle(fontSize: 15 * context.sf, color: Theme.of(context).colorScheme.onSurface),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Confirmar Palavra-passe',
|
labelText: 'Confirmar Palavra-passe',
|
||||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||||
prefixIcon: Icon(Icons.lock_clock_outlined, size: 22 * context.sf),
|
prefixIcon: Icon(Icons.lock_clock_outlined, size: 22 * context.sf, color: AppTheme.primaryRed),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12 * context.sf),
|
||||||
|
borderSide: BorderSide(color: AppTheme.primaryRed, width: 2),
|
||||||
|
),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||||
),
|
),
|
||||||
@@ -121,7 +142,7 @@ class RegisterButton extends StatelessWidget {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: controller.isLoading ? null : () => controller.signUp(context),
|
onPressed: controller.isLoading ? null : () => controller.signUp(context),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFE74C3C),
|
backgroundColor: AppTheme.primaryRed, // 👇 Cor do tema
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
||||||
elevation: 3,
|
elevation: 3,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:playmaker/screens/team_stats_page.dart';
|
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA
|
||||||
import '../models/team_model.dart';
|
import '../models/team_model.dart';
|
||||||
import '../controllers/team_controller.dart';
|
import '../models/person_model.dart';
|
||||||
|
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||||
|
|
||||||
class TeamCard extends StatelessWidget {
|
// --- CABEÇALHO ---
|
||||||
|
class StatsHeader extends StatelessWidget {
|
||||||
final Team team;
|
final Team team;
|
||||||
final TeamController controller;
|
final TeamController controller;
|
||||||
final VoidCallback onFavoriteTap;
|
final VoidCallback onFavoriteTap;
|
||||||
|
|||||||
@@ -0,0 +1,188 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
class ZoneMapDialog extends StatelessWidget {
|
||||||
|
final String playerName;
|
||||||
|
final bool isMake;
|
||||||
|
final Function(String zone, int points, double relativeX, double relativeY) onZoneSelected;
|
||||||
|
|
||||||
|
const ZoneMapDialog({
|
||||||
|
super.key,
|
||||||
|
required this.playerName,
|
||||||
|
required this.isMake,
|
||||||
|
required this.onZoneSelected,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Color headerColor = const Color(0xFFE88F15);
|
||||||
|
final Color yellowBackground = const Color(0xFFDFAB00);
|
||||||
|
|
||||||
|
final double screenHeight = MediaQuery.of(context).size.height;
|
||||||
|
final double dialogHeight = screenHeight * 0.95;
|
||||||
|
final double dialogWidth = dialogHeight * 1.0;
|
||||||
|
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: yellowBackground,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
insetPadding: const EdgeInsets.all(10),
|
||||||
|
child: SizedBox(
|
||||||
|
height: dialogHeight,
|
||||||
|
width: dialogWidth,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// CABEÇALHO
|
||||||
|
Container(
|
||||||
|
height: 40,
|
||||||
|
color: headerColor,
|
||||||
|
width: double.infinity,
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
isMake ? "Lançamento de $playerName (Marcou)" : "Lançamento de $playerName (Falhou)",
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 8,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => Navigator.pop(context),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||||
|
child: Icon(Icons.close, color: headerColor, size: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// MAPA INTERATIVO
|
||||||
|
Expanded(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTapUp: (details) => _calculateAndReturnZone(context, details.localPosition, constraints.biggest),
|
||||||
|
child: CustomPaint(
|
||||||
|
size: Size(constraints.maxWidth, constraints.maxHeight),
|
||||||
|
painter: DebugPainter(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _calculateAndReturnZone(BuildContext context, Offset tap, Size size) {
|
||||||
|
final double w = size.width;
|
||||||
|
final double h = size.height;
|
||||||
|
final double x = tap.dx;
|
||||||
|
final double y = tap.dy;
|
||||||
|
final double basketX = w / 2;
|
||||||
|
|
||||||
|
// MESMAS MEDIDAS DO PAINTER
|
||||||
|
final double margin = w * 0.10;
|
||||||
|
final double length = h * 0.35;
|
||||||
|
final double larguraDoArco = (w / 2) - margin;
|
||||||
|
final double alturaDoArco = larguraDoArco * 0.30;
|
||||||
|
final double totalArcoHeight = alturaDoArco * 4;
|
||||||
|
|
||||||
|
String zone = "Meia Distância";
|
||||||
|
int pts = 2;
|
||||||
|
|
||||||
|
// 1. TESTE DE 3 PONTOS
|
||||||
|
bool is3 = false;
|
||||||
|
if (y < length) {
|
||||||
|
if (x < margin || x > w - margin) is3 = true;
|
||||||
|
} else {
|
||||||
|
double dx = x - basketX;
|
||||||
|
double dy = y - length;
|
||||||
|
double ellipse = (dx * dx) / (larguraDoArco * larguraDoArco) + (dy * dy) / (math.pow(totalArcoHeight / 2, 2));
|
||||||
|
if (ellipse > 1.0) is3 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is3) {
|
||||||
|
pts = 3;
|
||||||
|
double angle = math.atan2(y - length, x - basketX);
|
||||||
|
if (y < length) {
|
||||||
|
zone = (x < w / 2) ? "Canto Esquerdo" : "Canto Direito";
|
||||||
|
} else if (angle > 2.35) {
|
||||||
|
zone = "Ala Esquerda";
|
||||||
|
} else if (angle < 0.78) {
|
||||||
|
zone = "Ala Direita";
|
||||||
|
} else {
|
||||||
|
zone = "Topo (3pts)";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 2. TESTE DE GARRAFÃO
|
||||||
|
final double pW = w * 0.28;
|
||||||
|
final double pH = h * 0.38;
|
||||||
|
if (x > basketX - pW / 2 && x < basketX + pW / 2 && y < pH) {
|
||||||
|
zone = "Garrafão";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onZoneSelected(zone, pts, x / w, y / h);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DebugPainter extends CustomPainter {
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final double w = size.width;
|
||||||
|
final double h = size.height;
|
||||||
|
final double basketX = w / 2;
|
||||||
|
|
||||||
|
final Paint whiteStroke = Paint()..color = Colors.white..style = PaintingStyle.stroke..strokeWidth = 2.0;
|
||||||
|
final Paint blackStroke = Paint()..color = Colors.black87..style = PaintingStyle.stroke..strokeWidth = 2.0;
|
||||||
|
|
||||||
|
final double margin = w * 0.10;
|
||||||
|
final double length = h * 0.35;
|
||||||
|
final double larguraDoArco = (w / 2) - margin;
|
||||||
|
final double alturaDoArco = larguraDoArco * 0.30;
|
||||||
|
final double totalArcoHeight = alturaDoArco * 4;
|
||||||
|
|
||||||
|
// 3 PONTOS (BRANCO)
|
||||||
|
canvas.drawLine(Offset(margin, 0), Offset(margin, length), whiteStroke);
|
||||||
|
canvas.drawLine(Offset(w - margin, 0), Offset(w - margin, length), whiteStroke);
|
||||||
|
canvas.drawLine(Offset(0, length), Offset(margin, length), whiteStroke);
|
||||||
|
canvas.drawLine(Offset(w - margin, length), Offset(w, length), whiteStroke);
|
||||||
|
canvas.drawArc(Rect.fromCenter(center: Offset(basketX, length), width: larguraDoArco * 2, height: totalArcoHeight), 0, math.pi, false, whiteStroke);
|
||||||
|
|
||||||
|
// DIVISÕES 45º (BRANCO)
|
||||||
|
double sXL = basketX + (larguraDoArco * math.cos(math.pi * 0.75));
|
||||||
|
double sYL = length + ((totalArcoHeight / 2) * math.sin(math.pi * 0.75));
|
||||||
|
double sXR = basketX + (larguraDoArco * math.cos(math.pi * 0.25));
|
||||||
|
double sYR = length + ((totalArcoHeight / 2) * math.sin(math.pi * 0.25));
|
||||||
|
canvas.drawLine(Offset(sXL, sYL), Offset(0, h * 0.85), whiteStroke);
|
||||||
|
canvas.drawLine(Offset(sXR, sYR), Offset(w, h * 0.85), whiteStroke);
|
||||||
|
|
||||||
|
// GARRAFÃO E MEIO CAMPO (PRETO)
|
||||||
|
final double pW = w * 0.28;
|
||||||
|
final double pH = h * 0.38;
|
||||||
|
canvas.drawRect(Rect.fromLTWH(basketX - pW / 2, 0, pW, pH), blackStroke);
|
||||||
|
final double ftR = pW / 2;
|
||||||
|
canvas.drawArc(Rect.fromCircle(center: Offset(basketX, pH), radius: ftR), 0, math.pi, false, blackStroke);
|
||||||
|
|
||||||
|
// Tracejado
|
||||||
|
const int dashCount = 10;
|
||||||
|
for (int i = 0; i < dashCount; i++) {
|
||||||
|
canvas.drawArc(Rect.fromCircle(center: Offset(basketX, pH), radius: ftR), math.pi + (i * 2 * (math.pi / 20)), math.pi / 20, false, blackStroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.drawArc(Rect.fromCircle(center: Offset(basketX, h), radius: w * 0.12), math.pi, math.pi, false, blackStroke);
|
||||||
|
|
||||||
|
// CESTO
|
||||||
|
canvas.drawCircle(Offset(basketX, h * 0.12), w * 0.02, blackStroke);
|
||||||
|
canvas.drawLine(Offset(basketX - w * 0.08, h * 0.12 - 5), Offset(basketX + w * 0.08, h * 0.12 - 5), blackStroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(CustomPainter old) => false;
|
||||||
|
}
|
||||||
@@ -58,7 +58,6 @@ flutter:
|
|||||||
assets:
|
assets:
|
||||||
- assets/playmaker-logo.png
|
- assets/playmaker-logo.png
|
||||||
- assets/campo.png
|
- assets/campo.png
|
||||||
- assets/playmaker-logos.png
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/to/resolution-aware-images
|
# https://flutter.dev/to/resolution-aware-images
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user