corrigir os botoes novos

This commit is contained in:
2026-02-26 10:41:12 +00:00
parent a371dfd589
commit 7aa85ac379
3 changed files with 142 additions and 66 deletions

View File

@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Ícone de Basquete'),
),
body: const Center(
child: Icon(
Icons.sports_basketball,
size: 100.0, // Tamanho do ícone
color: Colors.black, // Cor do ícone (preto, como na imagem)
),
),
),
);
}
}

View File

@@ -336,18 +336,18 @@ class _PlacarPageState extends State<PlacarPage> {
int _myTimeoutsUsed = 0; int _myTimeoutsUsed = 0;
int _opponentTimeoutsUsed = 0; int _opponentTimeoutsUsed = 0;
// MAPA PARA GUARDAR ESTATÍSTICAS INDIVIDUAIS (Key: Nome do Jogador) // MAPA PARA GUARDAR ESTATÍSTICAS (Guarda tudo na memória, mas só mostra Pts, Rbs e Ast no campo)
final Map<String, Map<String, int>> _playerStats = { final Map<String, Map<String, int>> _playerStats = {
"Russell": {"pts": 0, "rbs": 0, "ast": 0}, "Russell": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Reaves": {"pts": 0, "rbs": 0, "ast": 0}, "Reaves": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Davis": {"pts": 0, "rbs": 0, "ast": 0}, "Davis": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"James": {"pts": 0, "rbs": 0, "ast": 0}, "James": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Hachimura": {"pts": 0, "rbs": 0, "ast": 0}, "Hachimura": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Kyle": {"pts": 0, "rbs": 0, "ast": 0}, "Kyle": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Serge": {"pts": 0, "rbs": 0, "ast": 0}, "Serge": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Kawhi": {"pts": 0, "rbs": 0, "ast": 0}, "Kawhi": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Danny": {"pts": 0, "rbs": 0, "ast": 0}, "Danny": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
"Fred": {"pts": 0, "rbs": 0, "ast": 0}, "Fred": {"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0},
}; };
Duration _duration = const Duration(minutes: 10); Duration _duration = const Duration(minutes: 10);
@@ -378,7 +378,6 @@ class _PlacarPageState extends State<PlacarPage> {
setState(() => _isRunning = !_isRunning); setState(() => _isRunning = !_isRunning);
} }
// FUNÇÃO PARA USAR TIME-OUT
void _useTimeout(bool isOpponent) { void _useTimeout(bool isOpponent) {
setState(() { setState(() {
if (isOpponent) { if (isOpponent) {
@@ -386,7 +385,6 @@ class _PlacarPageState extends State<PlacarPage> {
} else { } else {
if (_myTimeoutsUsed < 3) _myTimeoutsUsed++; if (_myTimeoutsUsed < 3) _myTimeoutsUsed++;
} }
// Para o cronómetro automaticamente ao pedir Time-Out
_isRunning = false; _isRunning = false;
_timer?.cancel(); _timer?.cancel();
}); });
@@ -430,7 +428,8 @@ class _PlacarPageState extends State<PlacarPage> {
), ),
Positioned(top: 0, left: 0, right: 0, child: Center(child: _buildTopScoreboard())), Positioned(top: 0, left: 0, right: 0, child: Center(child: _buildTopScoreboard())),
Positioned(bottom: 20, left: 0, right: 0, child: _buildActionButtonsPanel()),
Positioned(bottom: 10, left: 0, right: 0, child: _buildActionButtonsPanel()),
Positioned( Positioned(
bottom: 20, right: 20, bottom: 20, right: 20,
@@ -448,14 +447,12 @@ class _PlacarPageState extends State<PlacarPage> {
List<Widget> _buildTacticalFormation(double w, double h) { List<Widget> _buildTacticalFormation(double w, double h) {
return [ return [
// CASA
Positioned(top: h * 0.25, left: w * 0.02, child: _buildPlayerCard("1", "Russell", false)), Positioned(top: h * 0.25, left: w * 0.02, child: _buildPlayerCard("1", "Russell", false)),
Positioned(top: h * 0.68, left: w * 0.02, child: _buildPlayerCard("15", "Reaves", false)), Positioned(top: h * 0.68, left: w * 0.02, child: _buildPlayerCard("15", "Reaves", false)),
Positioned(top: h * 0.48, left: w * 0.20, child: _buildPlayerCard("3", "Davis", false)), Positioned(top: h * 0.48, left: w * 0.20, child: _buildPlayerCard("3", "Davis", false)),
Positioned(top: h * 0.15, left: w * 0.20, child: _buildPlayerCard("6", "James", false)), Positioned(top: h * 0.15, left: w * 0.20, child: _buildPlayerCard("6", "James", false)),
Positioned(top: h * 0.80, left: w * 0.20, child: _buildPlayerCard("28", "Hachimura", false)), Positioned(top: h * 0.80, left: w * 0.20, child: _buildPlayerCard("28", "Hachimura", false)),
// VISITANTE
Positioned(top: h * 0.25, right: w * 0.02, child: _buildPlayerCard("7", "Kyle", true)), Positioned(top: h * 0.25, right: w * 0.02, child: _buildPlayerCard("7", "Kyle", true)),
Positioned(top: h * 0.68, right: w * 0.02, child: _buildPlayerCard("9", "Serge", true)), Positioned(top: h * 0.68, right: w * 0.02, child: _buildPlayerCard("9", "Serge", true)),
Positioned(top: h * 0.48, right: w * 0.20, child: _buildPlayerCard("2", "Kawhi", true)), Positioned(top: h * 0.48, right: w * 0.20, child: _buildPlayerCard("2", "Kawhi", true)),
@@ -468,13 +465,31 @@ class _PlacarPageState extends State<PlacarPage> {
final teamColor = isOpponent ? const Color(0xFFD92C2C) : const Color(0xFF1E5BB2); final teamColor = isOpponent ? const Color(0xFFD92C2C) : const Color(0xFF1E5BB2);
final stats = _playerStats[name]!; final stats = _playerStats[name]!;
return DragTarget<int>( return DragTarget<String>(
onAcceptWithDetails: (details) { onAcceptWithDetails: (details) {
final action = details.data;
setState(() { setState(() {
// Atualiza Placard Geral if (action.startsWith("add_pts_")) {
if (isOpponent) _opponentScore += details.data; else _myScore += details.data; int pts = int.parse(action.split("_").last);
// ATUALIZA ESTATÍSTICA INDIVIDUAL DO JOGADOR if (isOpponent) _opponentScore += pts; else _myScore += pts;
stats["pts"] = stats["pts"]! + details.data; stats["pts"] = stats["pts"]! + pts;
}
else if (action.startsWith("sub_pts_")) {
int pts = int.parse(action.split("_").last);
if (isOpponent) {
_opponentScore = (_opponentScore - pts < 0) ? 0 : _opponentScore - pts;
} else {
_myScore = (_myScore - pts < 0) ? 0 : _myScore - pts;
}
stats["pts"] = (stats["pts"]! - pts < 0) ? 0 : stats["pts"]! - pts;
}
else if (action == "add_rbs") { stats["rbs"] = stats["rbs"]! + 1; }
else if (action == "add_ast") { stats["ast"] = stats["ast"]! + 1; }
// Guarda STL, TOV e BLK na memória, mas não mostra no ecrã do campo
else if (action == "add_stl") { stats["stl"] = stats["stl"]! + 1; }
else if (action == "add_tov") { stats["tov"] = stats["tov"]! + 1; }
else if (action == "add_blk") { stats["blk"] = stats["blk"]! + 1; }
}); });
}, },
builder: (context, candidateData, rejectedData) { builder: (context, candidateData, rejectedData) {
@@ -502,6 +517,7 @@ class _PlacarPageState extends State<PlacarPage> {
children: [ children: [
Text(name, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87)), Text(name, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87)),
const SizedBox(height: 2), const SizedBox(height: 2),
// MOSTRA APENAS O MAIS IMPORTANTE NO CAMPO
Text( Text(
"${stats["pts"]} Pts | ${stats["rbs"]} Rbs | ${stats["ast"]} Ast", "${stats["pts"]} Pts | ${stats["rbs"]} Rbs | ${stats["ast"]} Ast",
style: const TextStyle(fontSize: 12, color: Colors.grey, fontWeight: FontWeight.w500) style: const TextStyle(fontSize: 12, color: Colors.grey, fontWeight: FontWeight.w500)
@@ -526,7 +542,6 @@ class _PlacarPageState extends State<PlacarPage> {
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
// Passamos os Time-outs usados para a secção da Casa
_buildTeamSection(widget.myTeam, _myScore, _myFouls, _myTimeoutsUsed, const Color(0xFF1E5BB2), false), _buildTeamSection(widget.myTeam, _myScore, _myFouls, _myTimeoutsUsed, const Color(0xFF1E5BB2), false),
const SizedBox(width: 25), const SizedBox(width: 25),
Column( Column(
@@ -537,7 +552,6 @@ class _PlacarPageState extends State<PlacarPage> {
], ],
), ),
const SizedBox(width: 25), const SizedBox(width: 25),
// Passamos os Time-outs usados para a secção Visitante
_buildTeamSection(widget.opponentTeam, _opponentScore, _opponentFouls, _opponentTimeoutsUsed, const Color(0xFFD92C2C), true), _buildTeamSection(widget.opponentTeam, _opponentScore, _opponentFouls, _opponentTimeoutsUsed, const Color(0xFFD92C2C), true),
], ],
), ),
@@ -545,7 +559,6 @@ class _PlacarPageState extends State<PlacarPage> {
} }
Widget _buildTeamSection(String name, int score, int fouls, int timeouts, Color color, bool isOpp) { Widget _buildTeamSection(String name, int score, int fouls, int timeouts, Color color, bool isOpp) {
// AS 3 BOLAS DE TIME-OUT
final timeoutIndicators = Row( final timeoutIndicators = Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: List.generate(3, (index) => Container( children: List.generate(3, (index) => Container(
@@ -553,7 +566,6 @@ class _PlacarPageState extends State<PlacarPage> {
width: 12, height: 12, width: 12, height: 12,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
// Se o index for menor que os usados, fica Amarelo. Se não, fica Cinzento.
color: index < timeouts ? Colors.yellow : Colors.grey.shade600, color: index < timeouts ? Colors.yellow : Colors.grey.shade600,
border: Border.all(color: Colors.black26), border: Border.all(color: Colors.black26),
), ),
@@ -566,7 +578,7 @@ class _PlacarPageState extends State<PlacarPage> {
const SizedBox(height: 4), const SizedBox(height: 4),
Text("FALTAS: $fouls", style: const TextStyle(color: Colors.yellowAccent, fontSize: 12)), Text("FALTAS: $fouls", style: const TextStyle(color: Colors.yellowAccent, fontSize: 12)),
const SizedBox(height: 4), const SizedBox(height: 4),
timeoutIndicators, // Adicionamos os indicadores aqui timeoutIndicators,
] ]
); );
@@ -591,30 +603,64 @@ class _PlacarPageState extends State<PlacarPage> {
child: Text(score.toString(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)), child: Text(score.toString(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
); );
// --- PAINEL EM COLUNAS ORGANIZADAS COM TODOS OS BOTÕES ---
Widget _buildActionButtonsPanel() { Widget _buildActionButtonsPanel() {
return Column( return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Row( // COLUNA 1: T.O Azul, 1, -1, AST
mainAxisAlignment: MainAxisAlignment.center, Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
// Botão Time-Out EQUIPA DA CASA (Azul) _actionBtn("T.O", const Color(0xFF1E5BB2), () => _useTimeout(false), labelSize: 20),
_actionBtn("T.O", const Color(0xFF1E5BB2), () => _useTimeout(false)), const SizedBox(height: 8),
_dragBtn("1", Colors.orange, 1), _dragBtn("1", Colors.orange, "add_pts_1"),
_dragBtn("2", Colors.orange, 2), const SizedBox(height: 8),
_dragBtn("3", Colors.orange, 3), _dragBtn("1", Colors.orange, "sub_pts_1", isX: true),
_actionBtn("ORB", const Color(0xFF1E2A38), () {}, icon: Icons.shopping_basket), const SizedBox(height: 8),
_dragBtn("AST", Colors.blueGrey, "add_ast"),
], ],
), ),
const SizedBox(height: 8), const SizedBox(width: 15),
Row(
mainAxisAlignment: MainAxisAlignment.center, // COLUNA 2: 2, -2, STL (Roubos - guardados na memória)
Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
// Botão Time-Out EQUIPA VISITANTE (Vermelho) _dragBtn("2", Colors.orange, "add_pts_2"),
_actionBtn("T.O", const Color(0xFFD92C2C), () => _useTimeout(true)), const SizedBox(height: 8),
_actionBtn("1", Colors.orange, () {}, isX: true), _dragBtn("2", Colors.orange, "sub_pts_2", isX: true),
_actionBtn("2", Colors.orange, () {}, isX: true), const SizedBox(height: 8),
_actionBtn("3", Colors.orange, () {}, isX: true), _dragBtn("STL", Colors.green, "add_stl"),
_actionBtn("DRB", const Color(0xFF1E2A38), () {}, icon: Icons.shield), ],
),
const SizedBox(width: 15),
// COLUNA 3: 3, -3, TOV (Perdas - guardadas na memória)
Column(
mainAxisSize: MainAxisSize.min,
children: [
_dragBtn("3", Colors.orange, "add_pts_3"),
const SizedBox(height: 8),
_dragBtn("3", Colors.orange, "sub_pts_3", isX: true),
const SizedBox(height: 8),
_dragBtn("TOV", Colors.redAccent, "add_tov"),
],
),
const SizedBox(width: 15),
// COLUNA 4: T.O Vermelho, ORB, DRB, BLK (Desarmes - guardados na memória)
Column(
mainAxisSize: MainAxisSize.min,
children: [
_actionBtn("T.O", const Color(0xFFD92C2C), () => _useTimeout(true), labelSize: 20),
const SizedBox(height: 8),
_dragBtn("ORB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
const SizedBox(height: 8),
_dragBtn("DRB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
const SizedBox(height: 8),
_dragBtn("BLK", Colors.deepPurple, "add_blk"),
], ],
), ),
], ],
@@ -622,42 +668,44 @@ class _PlacarPageState extends State<PlacarPage> {
} }
// BOTÃO ARRASTÁVEL // BOTÃO ARRASTÁVEL
Widget _dragBtn(String label, Color color, int val) { Widget _dragBtn(String label, Color color, String actionData, {IconData? icon, bool isX = false}) {
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4),
child: Draggable<int>( child: Draggable<String>(
data: val, data: actionData,
feedback: _circle(label, color, null, true), feedback: _circle(label, color, icon, true, isX: isX),
childWhenDragging: Opacity(opacity: 0.5, child: _circle(label, color, null, false)), childWhenDragging: Opacity(opacity: 0.5, child: _circle(label, color, icon, false, isX: isX)),
child: _circle(label, color, null, false), child: _circle(label, color, icon, false, isX: isX),
), ),
); );
} }
// BOTÃO CLICÁVEL // BOTÃO CLICÁVEL (Usado para o Time-Out)
Widget _actionBtn(String label, Color color, VoidCallback onTap, {IconData? icon, bool isX = false}) { Widget _actionBtn(String label, Color color, VoidCallback onTap, {IconData? icon, bool isX = false, double labelSize = 24}) {
return GestureDetector( return GestureDetector(
onTap: onTap, onTap: onTap,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4),
child: Stack( child: _circle(label, color, icon, false, fontSize: labelSize, isX: isX),
alignment: Alignment.bottomRight,
children: [
_circle(label, color, icon, false),
if (isX) const Icon(Icons.cancel, color: Colors.red, size: 25),
],
),
), ),
); );
} }
Widget _circle(String label, Color color, IconData? icon, bool isFeed) { // DESENHO DO CÍRCULO
return Container( Widget _circle(String label, Color color, IconData? icon, bool isFeed, {double fontSize = 20, bool isX = false}) {
width: isFeed ? 70 : 60, height: isFeed ? 70 : 60, return Stack(
decoration: BoxDecoration(color: color, shape: BoxShape.circle), alignment: Alignment.bottomRight,
alignment: Alignment.center, children: [
child: icon != null ? Icon(icon, color: Colors.white, size: 35) Container(
: Text(label, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 24, decoration: TextDecoration.none)), width: isFeed ? 70 : 60, height: isFeed ? 70 : 60,
decoration: BoxDecoration(color: color, shape: BoxShape.circle, boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 4)]),
alignment: Alignment.center,
child: icon != null
? Icon(icon, color: Colors.white, size: 35)
: Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: fontSize, decoration: TextDecoration.none)),
),
if (isX) Icon(Icons.cancel, color: Colors.red, size: isFeed ? 30 : 25),
],
); );
} }
} }

View File

@@ -206,6 +206,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
); );
} }
Widget _buildSearch({required String label, required TextEditingController controller}) { Widget _buildSearch({required String label, required TextEditingController controller}) {
return StreamBuilder<List<Map<String, dynamic>>>( return StreamBuilder<List<Map<String, dynamic>>>(
stream: widget.teamController.teamsStream, stream: widget.teamController.teamsStream,