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

@@ -41,7 +41,7 @@ class _PlacarPageState extends State<PlacarPage> {
super.dispose();
}
// --- BOTÕES FLUTUANTES DE FALTA (MUITO MAIS PEQUENOS AQUI 👇) ---
// --- BOTÕES FLUTUANTES DE FALTA ---
Widget _buildFloatingFoulBtn(String label, Color color, String action, IconData icon, double left, double right, double top, double sf) {
return Positioned(
top: top,
@@ -52,20 +52,20 @@ class _PlacarPageState extends State<PlacarPage> {
feedback: Material(
color: Colors.transparent,
child: CircleAvatar(
radius: 25 * sf, // Era 35
radius: 30 * sf,
backgroundColor: color.withOpacity(0.8),
child: Icon(icon, color: Colors.white, size: 25 * sf) // Era 35
child: Icon(icon, color: Colors.white, size: 30 * sf)
),
),
child: Column(
children: [
CircleAvatar(
radius: 22 * sf, // Era 30
radius: 27 * sf,
backgroundColor: color,
child: Icon(icon, color: Colors.white, size: 26 * sf), // Era 35
child: Icon(icon, color: Colors.white, size: 28 * sf),
),
SizedBox(height: 4 * sf),
Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11 * sf)), // Era 14
SizedBox(height: 5 * sf),
Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12 * sf)),
],
),
),
@@ -80,12 +80,12 @@ class _PlacarPageState extends State<PlacarPage> {
child: FloatingActionButton(
heroTag: heroTag,
backgroundColor: color,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12 * (size / 50))),
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * (size / 50))),
elevation: 5,
onPressed: isLoading ? null : onTap,
child: isLoading
? SizedBox(width: size*0.4, height: size*0.4, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
: Icon(icon, color: Colors.white, size: size * 0.5),
? SizedBox(width: size*0.45, height: size*0.45, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5))
: Icon(icon, color: Colors.white, size: size * 0.55),
),
);
}
@@ -94,9 +94,11 @@ class _PlacarPageState extends State<PlacarPage> {
Widget build(BuildContext context) {
final double wScreen = MediaQuery.of(context).size.width;
final double hScreen = MediaQuery.of(context).size.height;
final double sf = math.min(wScreen / 1280, hScreen / 800);
// 👇 DIVISOR AUMENTADO PARA O 'sf' FICAR MAIS PEQUENO 👇
final double sf = math.min(wScreen / 1150, hScreen / 720);
final double cornerBtnSize = 50 * sf;
final double cornerBtnSize = 48 * sf; // Tamanho ideal (Nem 38 nem 55)
if (_controller.isLoading) {
return Scaffold(
@@ -105,8 +107,8 @@ class _PlacarPageState extends State<PlacarPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("PREPARANDO O PAVILHÃO", style: TextStyle(color: Colors.white24, fontSize: 40 * sf, fontWeight: FontWeight.bold, letterSpacing: 2)),
SizedBox(height: 30 * sf),
Text("PREPARANDO O PAVILHÃO", style: TextStyle(color: Colors.white24, fontSize: 45 * sf, fontWeight: FontWeight.bold, letterSpacing: 2)),
SizedBox(height: 35 * sf),
StreamBuilder(
stream: Stream.periodic(const Duration(seconds: 3)),
builder: (context, snapshot) {
@@ -118,7 +120,7 @@ class _PlacarPageState extends State<PlacarPage> {
"Os jogadores estão a terminar o aquecimento..."
];
String frase = frases[DateTime.now().second % frases.length];
return Text(frase, style: TextStyle(color: Colors.orange.withOpacity(0.7), fontSize: 24 * sf, fontStyle: FontStyle.italic));
return Text(frase, style: TextStyle(color: Colors.orange.withOpacity(0.7), fontSize: 26 * sf, fontStyle: FontStyle.italic));
},
),
],
@@ -130,12 +132,14 @@ class _PlacarPageState extends State<PlacarPage> {
return Scaffold(
backgroundColor: const Color(0xFF266174),
body: SafeArea(
top: false,
bottom: false,
child: Stack(
children: [
// --- O CAMPO ---
Container(
margin: EdgeInsets.only(left: 60 * sf, right: 60 * sf, bottom: 50 * sf),
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.0)),
margin: EdgeInsets.only(left: 65 * sf, right: 65 * sf, bottom: 55 * sf),
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.5)),
child: LayoutBuilder(
builder: (context, constraints) {
final w = constraints.maxWidth;
@@ -151,12 +155,14 @@ class _PlacarPageState extends State<PlacarPage> {
},
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(image: AssetImage('assets/campo.png'), fit: BoxFit.cover, alignment: Alignment(0.0, 0.2)),
),
image: DecorationImage(
image: AssetImage('assets/campo.png'),
fit: BoxFit.fill, // <-- A MÁGICA ESTÁ AQUI
), ),
child: Stack(
children: _controller.matchShots.map((shot) => Positioned(
left: shot.position.dx - (8 * sf), top: shot.position.dy - (8 * sf),
child: CircleAvatar(radius: 8 * sf, backgroundColor: shot.isMake ? Colors.green : Colors.red, child: Icon(shot.isMake ? Icons.check : Icons.close, size: 10 * sf, color: Colors.white)),
left: shot.position.dx - (9 * sf), top: shot.position.dy - (9 * sf),
child: CircleAvatar(radius: 9 * sf, backgroundColor: shot.isMake ? Colors.green : Colors.red, child: Icon(shot.isMake ? Icons.check : Icons.close, size: 11 * sf, color: Colors.white)),
)).toList(),
),
),
@@ -179,27 +185,32 @@ class _PlacarPageState extends State<PlacarPage> {
// --- BOTÕES DE FALTAS ---
if (!_controller.isSelectingShotLocation) ...[
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.38, 0.0, h * 0.30, sf),
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0.0, w * 0.38, h * 0.30, 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),
],
// --- BOTÃO PLAY/PAUSE ---
if (!_controller.isSelectingShotLocation)
Positioned(
top: (h * 0.30) + (100 * sf), left: 0, right: 0,
child: Center(
child: GestureDetector(
onTap: () => _controller.toggleTimer(context),
child: CircleAvatar(radius: 60 * sf, backgroundColor: Colors.grey.withOpacity(0.5), child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 50 * sf)),
),
),
),
if (!_controller.isSelectingShotLocation)
Positioned(
top: (h * 0.32) + (40 * sf),
left: 0, right: 0,
child: Center(
child: GestureDetector(
onTap: () => _controller.toggleTimer(context),
child: CircleAvatar(
radius: 68 * sf,
backgroundColor: Colors.grey.withOpacity(0.5),
child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 58 * sf)
),
),
),
),
// --- PLACAR NO TOPO ---
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
// --- BOTÕES DE AÇÃO ---
if (!_controller.isSelectingShotLocation) Positioned(bottom: 10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
if (!_controller.isSelectingShotLocation) Positioned(bottom: -10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
// --- OVERLAY LANÇAMENTO ---
if (_controller.isSelectingShotLocation)
@@ -207,9 +218,9 @@ class _PlacarPageState extends State<PlacarPage> {
top: h * 0.4, left: 0, right: 0,
child: Center(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 30 * sf, vertical: 15 * sf),
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(10 * sf), border: Border.all(color: Colors.white)),
child: Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 24 * sf, fontWeight: FontWeight.bold)),
padding: EdgeInsets.symmetric(horizontal: 35 * sf, vertical: 18 * sf),
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(11 * sf), border: Border.all(color: Colors.white, width: 1.5 * sf)),
child: Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 27 * sf, fontWeight: FontWeight.bold)),
),
),
),
@@ -220,46 +231,73 @@ class _PlacarPageState extends State<PlacarPage> {
),
// --- BOTÕES LATERAIS ---
if (!_controller.isSelectingShotLocation) ...[
// Topo Esquerdo: Guardar e Sair
Positioned(
top: 20 * sf, left: 10 * sf,
child: Column(
children: [
_buildCornerBtn(heroTag: 'btn_save', icon: Icons.save, color: const Color(0xFF16202C), size: cornerBtnSize, isLoading: _controller.isSaving, onTap: () => _controller.saveGameStats(context)),
SizedBox(height: 15 * sf),
_buildCornerBtn(heroTag: 'btn_exit', icon: Icons.exit_to_app, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () => Navigator.pop(context)),
],
)
),
// Topo Esquerdo: Guardar e Sair (Botão Único)
Positioned(
top: 50 * sf, left: 12 * sf,
child: _buildCornerBtn(
heroTag: 'btn_save_exit',
icon: Icons.save_alt, // Mudei o ícone para dar a ideia de "Guardar e Sair"
color: const Color(0xFFD92C2C), // Mantive vermelho para saberes que é para fechar
size: cornerBtnSize,
isLoading: _controller.isSaving,
onTap: () async {
// 1. Primeiro obriga a guardar os dados na BD
await _controller.saveGameStats(context);
// 2. Só depois de acabar de guardar é que volta para trás (sai da página)
if (context.mounted) {
Navigator.pop(context);
}
}
),
),
// Base Esquerda: Banco Casa
// Base Esquerda: Banco Casa + TIMEOUT DA CASA
Positioned(
bottom: 50 * sf, left: 10 * sf,
bottom: 55 * sf, left: 12 * sf,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (_controller.showMyBench) BenchPlayersList(controller: _controller, isOpponent: false, sf: sf),
SizedBox(height: 10 * sf),
_buildCornerBtn(heroTag: 'btn_sub_home', icon: Icons.swap_horiz, color: const Color(0xFF1E5BB2), size: cornerBtnSize, onTap: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); })
SizedBox(height: 12 * sf),
_buildCornerBtn(heroTag: 'btn_sub_home', icon: Icons.swap_horiz, color: const Color(0xFF1E5BB2), size: cornerBtnSize, onTap: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); }),
SizedBox(height: 12 * sf),
_buildCornerBtn(
heroTag: 'btn_to_home',
icon: Icons.timer,
color: _controller.myTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFF1E5BB2),
size: cornerBtnSize,
onTap: _controller.myTimeoutsUsed >= 3
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa da casa já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
: () => _controller.useTimeout(false)
),
],
),
),
// Base Direita: Banco Visitante
// Base Direita: Banco Visitante + TIMEOUT DO VISITANTE
Positioned(
bottom: 50 * sf, right: 10 * sf,
bottom: 55 * sf, right: 12 * sf,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (_controller.showOppBench) BenchPlayersList(controller: _controller, isOpponent: true, sf: sf),
SizedBox(height: 10 * sf),
_buildCornerBtn(heroTag: 'btn_sub_away', icon: Icons.swap_horiz, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); })
SizedBox(height: 12 * sf),
_buildCornerBtn(heroTag: 'btn_sub_away', icon: Icons.swap_horiz, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); }),
SizedBox(height: 12 * sf),
_buildCornerBtn(
heroTag: 'btn_to_away',
icon: Icons.timer,
color: _controller.opponentTimeoutsUsed >= 3 ? Colors.grey : const Color(0xFFD92C2C),
size: cornerBtnSize,
onTap: _controller.opponentTimeoutsUsed >= 3
? () => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('🛑 A equipa visitante já usou os 3 Timeouts deste período!'), backgroundColor: Colors.red))
: () => _controller.useTimeout(true)
),
],
),
),
],
],
),
),
);