fazer vitoria e derrota

This commit is contained in:
2026-03-10 17:15:10 +00:00
parent d720e09866
commit 49bb371ef4
12 changed files with 940 additions and 742 deletions

View File

@@ -3,6 +3,7 @@ import '../controllers/game_controller.dart';
import '../controllers/team_controller.dart';
import '../models/game_model.dart';
import '../widgets/game_widgets.dart';
import 'dart:math' as math; // <-- IMPORTANTE: Para o cálculo da escala
class GamePage extends StatefulWidget {
const GamePage({super.key});
@@ -17,10 +18,15 @@ class _GamePageState extends State<GamePage> {
@override
Widget build(BuildContext context) {
// 👇 CÁLCULO DA ESCALA (sf) PARA SE ADAPTAR A QUALQUER ECRÃ 👇
final double wScreen = MediaQuery.of(context).size.width;
final double hScreen = MediaQuery.of(context).size.height;
final double sf = math.min(wScreen, hScreen) / 400;
return Scaffold(
backgroundColor: const Color(0xFFF5F7FA),
appBar: AppBar(
title: const Text("Jogos", style: TextStyle(fontWeight: FontWeight.bold)),
title: Text("Jogos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * sf)),
backgroundColor: Colors.white,
elevation: 0,
),
@@ -39,15 +45,15 @@ class _GamePageState extends State<GamePage> {
}
if (gameSnapshot.hasError) {
return Center(child: Text("Erro: ${gameSnapshot.error}"));
return Center(child: Text("Erro: ${gameSnapshot.error}", style: TextStyle(fontSize: 14 * sf)));
}
if (!gameSnapshot.hasData || gameSnapshot.data!.isEmpty) {
return const Center(child: Text("Nenhum jogo registado."));
return Center(child: Text("Nenhum jogo registado.", style: TextStyle(fontSize: 16 * sf)));
}
return ListView.builder(
padding: const EdgeInsets.all(16),
padding: EdgeInsets.all(16 * sf),
itemCount: gameSnapshot.data!.length,
itemBuilder: (context, index) {
final game = gameSnapshot.data![index];
@@ -65,7 +71,6 @@ class _GamePageState extends State<GamePage> {
}
}
// Agora já passamos as imagens para o cartão!
return GameResultCard(
gameId: game.id,
myTeam: game.myTeam,
@@ -74,8 +79,9 @@ class _GamePageState extends State<GamePage> {
opponentScore: game.opponentScore,
status: game.status,
season: game.season,
myTeamLogo: myLogo, // <-- IMAGEM DA TUA EQUIPA
opponentTeamLogo: oppLogo, // <-- IMAGEM DA EQUIPA ADVERSÁRIA
myTeamLogo: myLogo,
opponentTeamLogo: oppLogo,
sf: sf, // <-- Passamos a escala para o Cartão
);
},
);
@@ -85,18 +91,19 @@ class _GamePageState extends State<GamePage> {
),
floatingActionButton: FloatingActionButton(
backgroundColor: const Color(0xFFE74C3C),
child: const Icon(Icons.add, color: Colors.white),
onPressed: () => _showCreateDialog(context),
child: Icon(Icons.add, color: Colors.white, size: 24 * sf),
onPressed: () => _showCreateDialog(context, sf),
),
);
}
void _showCreateDialog(BuildContext context) {
void _showCreateDialog(BuildContext context, double sf) {
showDialog(
context: context,
builder: (context) => CreateGameDialogManual(
teamController: teamController,
gameController: gameController,
sf: sf, // <-- Passamos a escala para o Pop-up
),
);
}