From ce25fe6499c63e698f5e68629f8a96606f7a3af1 Mon Sep 17 00:00:00 2001 From: 230404 <230404@epvc.pt> Date: Sat, 18 Apr 2026 02:56:44 +0100 Subject: [PATCH] sabado --- lib/controllers/placar_controller.dart | 114 ++- lib/pages/PlacarPage.dart | 974 ++++++++++++++----------- pubspec.lock | 16 +- 3 files changed, 641 insertions(+), 463 deletions(-) diff --git a/lib/controllers/placar_controller.dart b/lib/controllers/placar_controller.dart index f0848fa..54c6da2 100644 --- a/lib/controllers/placar_controller.dart +++ b/lib/controllers/placar_controller.dart @@ -192,7 +192,9 @@ class PlacarController extends ChangeNotifier { "ftm": s['ftm'] ?? 0, "fta": s['fta'] ?? 0, "orb": s['orb'] ?? 0, "drb": s['drb'] ?? 0, "p2m": s['p2m'] ?? 0, "p2a": s['p2a'] ?? 0, "p3m": s['p3m'] ?? 0, "p3a": s['p3a'] ?? 0, "so": s['so'] ?? 0, "il": s['il'] ?? 0, "li": s['li'] ?? 0, - "pa": s['pa'] ?? 0, "tres_s": s['tres_s'] ?? 0, "dr": s['dr'] ?? 0, "min": s['min'] ?? 0, + "pa": s['pa'] ?? 0, "tres_s": s['tres_seg'] ?? 0, "dr": s['dr'] ?? 0, + "min": s['minutos_jogados'] ?? 0, + "sec": (s['minutos_jogados'] ?? 0) * 60, }; } @@ -206,7 +208,8 @@ class PlacarController extends ChangeNotifier { "pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0, "fls": 0, "fgm": 0, "fga": 0, "ftm": 0, "fta": 0, "orb": 0, "drb": 0, "p2m": 0, "p2a": 0, "p3m": 0, "p3a": 0, - "so": 0, "il": 0, "li": 0, "pa": 0, "tres_s": 0, "dr": 0, "min": 0 + "so": 0, "il": 0, "li": 0, "pa": 0, "tres_s": 0, "dr": 0, + "min": 0, "sec": 0 }; if (isMyTeam) { @@ -278,6 +281,21 @@ class PlacarController extends ChangeNotifier { timer = Timer.periodic(const Duration(seconds: 1), (timer) { if (durationNotifier.value.inSeconds > 0) { durationNotifier.value -= const Duration(seconds: 1); + + void addTimeToCourt(List court) { + for (String id in court) { + if (playerStats.containsKey(id)) { + int currentSec = playerStats[id]!["sec"] ?? 0; + playerStats[id]!["sec"] = currentSec + 1; + playerStats[id]!["min"] = (currentSec + 1) ~/ 60; + } + } + } + addTimeToCourt(myCourt); + addTimeToCourt(oppCourt); + + notifyListeners(); + } else { timer.cancel(); isRunning = false; @@ -363,7 +381,6 @@ class PlacarController extends ChangeNotifier { String finalAction = isMake ? "add_pts_$points" : "miss_$points"; commitStat(finalAction, targetPlayer); - notifyListeners(); } @@ -423,6 +440,39 @@ class PlacarController extends ChangeNotifier { isSelectingShotLocation = false; pendingAction = null; pendingPlayerId = null; notifyListeners(); } + void registerFoul(String committerData, String foulType, String victimData) { + bool isOpponent = committerData.startsWith("player_opp_"); + String committerId = committerData.replaceAll("player_my_", "").replaceAll("player_opp_", ""); + final committerStats = playerStats[committerId]!; + final committerName = playerNames[committerId] ?? "Jogador"; + + committerStats["fls"] = committerStats["fls"]! + 1; + if (isOpponent) opponentFouls++; else myFouls++; + + if (foulType == "Desqualificante") { + committerStats["fls"] = 5; + } + + String logText = "cometeu Falta $foulType"; + + if (victimData.isNotEmpty) { + String victimId = victimData.replaceAll("player_my_", "").replaceAll("player_opp_", ""); + final victimStats = playerStats[victimId]!; + final victimName = playerNames[victimId] ?? "Jogador"; + + victimStats["so"] = victimStats["so"]! + 1; + logText += " sobre $victimName ⚠️"; + } else { + logText += " (Equipa/Banco) ⚠️"; + } + + String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}"; + playByPlay.insert(0, "P$currentQuarter - $time: $committerName $logText"); + + _saveLocalBackup(); + notifyListeners(); + } + void commitStat(String action, String playerData) { bool isOpponent = playerData.startsWith("player_opp_"); String playerId = playerData.replaceAll("player_my_", "").replaceAll("player_opp_", ""); @@ -440,6 +490,40 @@ class PlacarController extends ChangeNotifier { if (pts == 1) { stats["ftm"] = stats["ftm"]! + 1; stats["fta"] = stats["fta"]! + 1; } logText = "marcou $pts pontos 🏀"; } + else if (action.startsWith("sub_pts_")) { + int ptsToAnul = int.parse(action.split("_").last); + + int lastShotIndex = matchShots.lastIndexWhere((s) => + s.playerId == playerId && + s.isMake == true && + s.points == ptsToAnul + ); + + if (lastShotIndex != -1) { + matchShots.removeAt(lastShotIndex); + + if (isOpponent) opponentScore -= ptsToAnul; else myScore -= ptsToAnul; + stats["pts"] = stats["pts"]! - ptsToAnul; + + if (ptsToAnul == 2) { + if(stats["fgm"]! > 0) stats["fgm"] = stats["fgm"]! - 1; + if(stats["fga"]! > 0) stats["fga"] = stats["fga"]! - 1; + if(stats["p2m"]! > 0) stats["p2m"] = stats["p2m"]! - 1; + if(stats["p2a"]! > 0) stats["p2a"] = stats["p2a"]! - 1; + } else if (ptsToAnul == 3) { + if(stats["fgm"]! > 0) stats["fgm"] = stats["fgm"]! - 1; + if(stats["fga"]! > 0) stats["fga"] = stats["fga"]! - 1; + if(stats["p3m"]! > 0) stats["p3m"] = stats["p3m"]! - 1; + if(stats["p3a"]! > 0) stats["p3a"] = stats["p3a"]! - 1; + } else if (ptsToAnul == 1) { + if(stats["ftm"]! > 0) stats["ftm"] = stats["ftm"]! - 1; + if(stats["fta"]! > 0) stats["fta"] = stats["fta"]! - 1; + } + logText = "anulou cesto de $ptsToAnul pts ⏪"; + } else { + return; + } + } else if (action == "miss_1") { stats["fta"] = stats["fta"]! + 1; logText = "falhou lance livre ❌"; } else if (action == "miss_2") { stats["fga"] = stats["fga"]! + 1; stats["p2a"] = stats["p2a"]! + 1; logText = "falhou lançamento de 2 ❌"; } else if (action == "miss_3") { stats["fga"] = stats["fga"]! + 1; stats["p3a"] = stats["p3a"]! + 1; logText = "falhou lançamento de 3 ❌"; } @@ -448,21 +532,22 @@ class PlacarController extends ChangeNotifier { else if (action == "add_ast") { stats["ast"] = stats["ast"]! + 1; logText = "fez uma assistência 🤝"; } else if (action == "add_stl") { stats["stl"] = stats["stl"]! + 1; logText = "roubou a bola 🥷"; } else if (action == "add_blk") { stats["blk"] = stats["blk"]! + 1; logText = "fez um desarme (bloco) ✋"; } - else if (action == "add_foul") { - stats["fls"] = stats["fls"]! + 1; - if (isOpponent) opponentFouls++; else myFouls++; - logText = "cometeu falta ⚠️"; - } + else if (action == "add_so") { stats["so"] = stats["so"]! + 1; logText = "sofreu uma falta 🤕"; } else if (action == "add_il") { stats["il"] = stats["il"]! + 1; logText = "intercetou um lançamento 🛑"; } else if (action == "add_li") { stats["li"] = stats["li"]! + 1; logText = "teve o lançamento intercetado 🚫"; } - // Registo avançado de Bolas Perdidas (TOV) else if (action == "add_tov") { stats["tov"] = stats["tov"]! + 1; logText = "fez um passe ruim 🤦"; } else if (action == "add_pa") { stats["pa"] = stats["pa"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "cometeu passos 🚶"; } else if (action == "add_3s") { stats["tres_s"] = stats["tres_s"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "violação de 3 segundos ⏱️"; } else if (action == "add_24s") { stats["tov"] = stats["tov"]! + 1; logText = "violação de 24 segundos ⏱️"; } else if (action == "add_dr") { stats["dr"] = stats["dr"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "fez drible duplo 🏀"; } + + else if (action == "sub_foul") { + if (stats["fls"]! > 0) stats["fls"] = stats["fls"]! - 1; + if (isOpponent) { if (opponentFouls > 0) opponentFouls--; } else { if (myFouls > 0) myFouls--; } + logText = "teve falta anulada 🔄"; + } if (logText.isNotEmpty) { String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}"; @@ -470,6 +555,7 @@ class PlacarController extends ChangeNotifier { } _saveLocalBackup(); + notifyListeners(); } Future saveGameStats(BuildContext context) async { @@ -491,7 +577,9 @@ class PlacarController extends ChangeNotifier { int ast = stats['ast'] ?? 0; int rbs = stats['rbs'] ?? 0; - int minJogados = (stats['min'] ?? 0) > 0 ? stats['min']! : 40; + double minJogados = (stats['sec'] ?? 0) / 60.0; + if (minJogados <= 0) minJogados = 40.0; + int tr = rbs; int br = stats['stl'] ?? 0; int bp = stats['tov'] ?? 0; @@ -530,8 +618,8 @@ class PlacarController extends ChangeNotifier { 'tov': stats['tov'], 'fls': stats['fls'], 'fgm': stats['fgm'], 'fga': stats['fga'], 'ftm': stats['ftm'], 'fta': stats['fta'], 'orb': stats['orb'], 'drb': stats['drb'], 'p2m': stats['p2m'], 'p2a': stats['p2a'], 'p3m': stats['p3m'], 'p3a': stats['p3a'], - 'so': stats['so'], 'il': stats['il'], 'li': stats['li'], 'pa': stats['pa'], 'tres_s': stats['tres_s'], - 'dr': stats['dr'], 'min': stats['min'], + 'so': stats['so'], 'il': stats['il'], 'li': stats['li'], 'pa': stats['pa'], 'tres_seg': stats['tres_s'], + 'dr': stats['dr'], 'minutos_jogados': stats['min'], }); } }); @@ -558,6 +646,4 @@ class PlacarController extends ChangeNotifier { timer?.cancel(); super.dispose(); } - - void registerFoul(String s, String foulType, String t) {} } \ No newline at end of file diff --git a/lib/pages/PlacarPage.dart b/lib/pages/PlacarPage.dart index b3270c0..3d5f9f0 100644 --- a/lib/pages/PlacarPage.dart +++ b/lib/pages/PlacarPage.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:playmaker/widgets/placar_widgets.dart'; import 'dart:math' as math; import '../utils/size_extension.dart'; @@ -95,21 +96,16 @@ class _PlacarPageState extends State { } void _showHeatmap(BuildContext context) { - Map> statsByNames = {}; - _controller.playerStats.forEach((id, stats) { - String nomeDoJogador = _controller.playerNames[id] ?? 'Desconhecido'; - statsByNames[nomeDoJogador] = stats; - }); - showDialog( context: context, builder: (ctx) => HeatmapDialog( shots: _controller.matchShots, myTeamName: _controller.myTeam, oppTeamName: _controller.opponentTeam, - myPlayers: [..._controller.myCourt, ..._controller.myBench].map((id) => _controller.playerNames[id]!).toList(), - oppPlayers: [..._controller.oppCourt, ..._controller.oppBench].map((id) => _controller.playerNames[id]!).toList(), - playerStats: statsByNames, + myPlayersIds: [..._controller.myCourt, ..._controller.myBench], + oppPlayersIds: [..._controller.oppCourt, ..._controller.oppBench], + playerStats: _controller.playerStats, + playerNames: _controller.playerNames, ), ); } @@ -317,77 +313,207 @@ class ActionSubtypeDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return AlertDialog( - backgroundColor: AppTheme.placarDarkSurface, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * sf), side: BorderSide(color: AppTheme.warningAmber, width: 2 * sf)), - title: Text(title, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18 * sf), textAlign: TextAlign.center), - content: Column( - mainAxisSize: MainAxisSize.min, - children: options.entries.map((e) => Padding( - padding: EdgeInsets.only(bottom: 8 * sf), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.grey.shade800, - foregroundColor: Colors.white, - minimumSize: Size(double.infinity, 45 * sf), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8 * sf)), + return Dialog( + backgroundColor: Colors.transparent, + elevation: 0, + child: Container( + width: MediaQuery.of(context).size.width * 0.55, + decoration: BoxDecoration( + color: AppTheme.placarDarkSurface, + borderRadius: BorderRadius.circular(12 * sf), + border: Border.all(color: AppTheme.warningAmber, width: 1.5 * sf), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 12 * sf), + decoration: BoxDecoration( + color: AppTheme.placarListCard, + borderRadius: BorderRadius.vertical(top: Radius.circular(10 * sf)), + ), + child: Stack( + alignment: Alignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Text( + title, + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf), + ), + ), + Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () => Navigator.pop(context), + child: Container( + padding: EdgeInsets.all(4 * sf), + decoration: const BoxDecoration(color: Colors.white24, shape: BoxShape.circle), + child: Icon(Icons.close, color: Colors.white, size: 16 * sf), + ), + ), + ), + ], + ), ), - onPressed: () => onSelected(e.key), - child: Text(e.value, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * sf)), - ), - )).toList(), + Padding( + padding: EdgeInsets.symmetric(vertical: 20 * sf, horizontal: 15 * sf), + child: Wrap( + spacing: 12 * sf, + runSpacing: 15 * sf, + alignment: WrapAlignment.center, + children: options.entries.map((e) => SizedBox( + width: 110 * sf, + height: 60 * sf, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.placarTimerBg, + foregroundColor: Colors.white, + padding: EdgeInsets.all(6 * sf), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8 * sf), + side: BorderSide(color: Colors.white12, width: 1 * sf), + ), + ), + onPressed: () => onSelected(e.key), + child: Text( + e.value, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12 * sf), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + )).toList(), + ), + ), + ], + ), ), ); } } -// NOVO MENU PARA A VÍTIMA DA FALTA: void showFoulVictimDialog(BuildContext context, PlacarController controller, bool isCommitterOpponent, String committerId, String foulType, double sf) { final victimCourt = isCommitterOpponent ? controller.myCourt : controller.oppCourt; - final victimBench = isCommitterOpponent ? controller.myBench : controller.oppBench; final prefixCommitter = isCommitterOpponent ? "player_opp_" : "player_my_"; final prefixVictim = isCommitterOpponent ? "player_my_" : "player_opp_"; final victimsColor = isCommitterOpponent ? AppTheme.myTeamBlue : AppTheme.oppTeamRed; - final possibleVictims = [...victimCourt, ...victimBench].where((id) => !id.startsWith("fake_")).toList(); + final possibleVictims = victimCourt.where((id) => !id.startsWith("fake_")).toList(); showDialog( context: context, barrierDismissible: false, - builder: (ctx) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.surface, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * sf)), - title: Text("Quem sofreu a falta?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, fontSize: 18 * sf)), - content: SingleChildScrollView( + builder: (ctx) => Dialog( + backgroundColor: Colors.transparent, + elevation: 0, + child: Container( + width: MediaQuery.of(context).size.width * 0.60, + decoration: BoxDecoration( + color: AppTheme.placarDarkSurface, + borderRadius: BorderRadius.circular(12 * sf), + border: Border.all(color: AppTheme.warningAmber, width: 1.5 * sf), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - ...possibleVictims.map((id) { - final name = controller.playerNames[id] ?? "Desconhecido"; - final number = controller.playerNumbers[id] ?? "0"; - return ListTile( - leading: CircleAvatar( - backgroundColor: victimsColor, - child: Text(number, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)), - ), - title: Text(name, style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold)), - onTap: () { - Navigator.pop(ctx); - controller.registerFoul("$prefixCommitter$committerId", foulType, "$prefixVictim$id"); - }, - ); - }), - Divider(color: Colors.grey.withOpacity(0.3)), - ListTile( - leading: const CircleAvatar(backgroundColor: Colors.grey, child: Icon(Icons.group, color: Colors.white)), - title: Text("Equipa / Sem Vítima Específica", style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontStyle: FontStyle.italic)), - onTap: () { - Navigator.pop(ctx); - controller.registerFoul("$prefixCommitter$committerId", foulType, ""); - }, - ) + Container( + padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 12 * sf), + decoration: BoxDecoration( + color: AppTheme.placarListCard, + borderRadius: BorderRadius.vertical(top: Radius.circular(10 * sf)), + ), + child: Stack( + alignment: Alignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Text( + "Quem sofreu a falta?", + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf), + ), + ), + Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () => Navigator.pop(ctx), + child: Container( + padding: EdgeInsets.all(4 * sf), + decoration: const BoxDecoration(color: Colors.white24, shape: BoxShape.circle), + child: Icon(Icons.close, color: Colors.white, size: 16 * sf), + ), + ), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 20 * sf, horizontal: 10 * sf), + child: Column( + children: [ + Wrap( + spacing: 10 * sf, + runSpacing: 10 * sf, + alignment: WrapAlignment.center, + children: possibleVictims.map((id) { + final name = controller.playerNames[id] ?? "Desconhecido"; + final number = controller.playerNumbers[id] ?? "0"; + + return InkWell( + onTap: () { + Navigator.pop(ctx); + controller.registerFoul("$prefixCommitter$committerId", foulType, "$prefixVictim$id"); + }, + child: Container( + width: 80 * sf, + padding: EdgeInsets.all(6 * sf), + decoration: BoxDecoration( + color: victimsColor.withOpacity(0.2), + border: Border.all(color: victimsColor, width: 1.5 * sf), + borderRadius: BorderRadius.circular(12 * sf), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CircleAvatar( + backgroundColor: victimsColor, + radius: 16 * sf, + child: Text(number, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * sf)), + ), + SizedBox(height: 6 * sf), + Text(name, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 10 * sf), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis), + ], + ), + ), + ); + }).toList(), + ), + SizedBox(height: 15 * sf), + const Divider(color: Colors.white24), + SizedBox(height: 8 * sf), + ElevatedButton.icon( + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.placarTimerBg, + foregroundColor: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 16 * sf, vertical: 10 * sf), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8 * sf), + side: BorderSide(color: Colors.white12, width: 1 * sf), + ), + ), + icon: Icon(Icons.group, color: Colors.white, size: 16 * sf), + label: Text("Equipa / Sem Vítima Específica", style: TextStyle(fontSize: 12 * sf)), + onPressed: () { + Navigator.pop(ctx); + controller.registerFoul("$prefixCommitter$committerId", foulType, ""); + }, + ) + ], + ), + ), ], ), ), @@ -398,6 +524,7 @@ void showFoulVictimDialog(BuildContext context, PlacarController controller, boo void showAssistDialog(BuildContext context, PlacarController controller, bool isOpponent, String scorerId, double sf) { final teamCourt = isOpponent ? controller.oppCourt : controller.myCourt; final prefix = isOpponent ? "player_opp_" : "player_my_"; + final teamColor = isOpponent ? AppTheme.oppTeamRed : AppTheme.myTeamBlue; final possibleAssistants = teamCourt.where((id) => id != scorerId && !id.startsWith("fake_")).toList(); @@ -406,36 +533,111 @@ void showAssistDialog(BuildContext context, PlacarController controller, bool is showDialog( context: context, barrierDismissible: false, - builder: (ctx) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.surface, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * sf)), - title: Text("Houve Assistência?", style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, fontSize: 18 * sf)), - content: SingleChildScrollView( + builder: (ctx) => Dialog( + backgroundColor: Colors.transparent, + elevation: 0, + child: Container( + width: MediaQuery.of(context).size.width * 0.55, + decoration: BoxDecoration( + color: AppTheme.placarDarkSurface, + borderRadius: BorderRadius.circular(12 * sf), + border: Border.all(color: AppTheme.warningAmber, width: 1.5 * sf), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - ...possibleAssistants.map((id) { - final name = controller.playerNames[id] ?? "Desconhecido"; - final number = controller.playerNumbers[id] ?? "0"; - return ListTile( - leading: CircleAvatar( - backgroundColor: isOpponent ? AppTheme.oppTeamRed : AppTheme.myTeamBlue, - child: Text(number, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)), - ), - title: Text(name, style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold)), - onTap: () { - Navigator.pop(ctx); - controller.commitStat("add_ast", "$prefix$id"); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Assistência: $name'), duration: const Duration(seconds: 1), backgroundColor: AppTheme.successGreen)); - }, - ); - }), - Divider(color: Colors.grey.withOpacity(0.3)), - ListTile( - leading: const CircleAvatar(backgroundColor: Colors.grey, child: Icon(Icons.person_off, color: Colors.white)), - title: Text("Isolado (Sem assistência)", style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontStyle: FontStyle.italic)), - onTap: () => Navigator.pop(ctx), - ) + Container( + padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 12 * sf), + decoration: BoxDecoration( + color: AppTheme.placarListCard, + borderRadius: BorderRadius.vertical(top: Radius.circular(10 * sf)), + ), + child: Stack( + alignment: Alignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Text( + "Houve Assistência?", + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf), + ), + ), + Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () => Navigator.pop(ctx), + child: Container( + padding: EdgeInsets.all(4 * sf), + decoration: const BoxDecoration(color: Colors.white24, shape: BoxShape.circle), + child: Icon(Icons.close, color: Colors.white, size: 16 * sf), + ), + ), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 20 * sf, horizontal: 10 * sf), + child: Column( + children: [ + Wrap( + spacing: 10 * sf, + runSpacing: 10 * sf, + alignment: WrapAlignment.center, + children: possibleAssistants.map((id) { + final name = controller.playerNames[id] ?? "Desconhecido"; + final number = controller.playerNumbers[id] ?? "0"; + + return InkWell( + onTap: () { + Navigator.pop(ctx); + controller.commitStat("add_ast", "$prefix$id"); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Assistência: $name'), duration: const Duration(seconds: 1), backgroundColor: AppTheme.successGreen)); + }, + child: Container( + width: 75 * sf, + padding: EdgeInsets.all(6 * sf), + decoration: BoxDecoration( + color: teamColor.withOpacity(0.2), + border: Border.all(color: teamColor, width: 1.5 * sf), + borderRadius: BorderRadius.circular(12 * sf), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CircleAvatar( + backgroundColor: teamColor, + radius: 16 * sf, + child: Text(number, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * sf)), + ), + SizedBox(height: 6 * sf), + Text(name, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 10 * sf), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis), + ], + ), + ), + ); + }).toList(), + ), + SizedBox(height: 15 * sf), + const Divider(color: Colors.white24), + SizedBox(height: 8 * sf), + ElevatedButton.icon( + style: ElevatedButton.styleFrom( + backgroundColor: AppTheme.placarTimerBg, + foregroundColor: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 16 * sf, vertical: 10 * sf), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8 * sf), + side: BorderSide(color: Colors.white12, width: 1 * sf), + ), + ), + icon: Icon(Icons.person_off, color: Colors.white, size: 16 * sf), + label: Text("Isolado (Sem assistência)", style: TextStyle(fontSize: 12 * sf)), + onPressed: () => Navigator.pop(ctx), + ) + ], + ), + ), ], ), ), @@ -443,6 +645,168 @@ void showAssistDialog(BuildContext context, PlacarController controller, bool is ); } +class PlayerCourtCard extends StatelessWidget { + final PlacarController controller; + final String playerId; + final bool isOpponent; + final double sf; + + const PlayerCourtCard({super.key, required this.controller, required this.playerId, required this.isOpponent, required this.sf}); + + @override + Widget build(BuildContext context) { + final teamColor = isOpponent ? AppTheme.oppTeamRed : AppTheme.myTeamBlue; + + final realName = controller.playerNames[playerId] ?? "Erro"; + final stats = controller.playerStats[playerId]!; + final number = controller.playerNumbers[playerId]!; + final prefix = isOpponent ? "player_opp_" : "player_my_"; + + return Draggable( + data: "$prefix$playerId", + feedback: Material( + color: Colors.transparent, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration(color: teamColor.withOpacity(0.9), borderRadius: BorderRadius.circular(6)), + child: Text(realName, style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold)), + ), + ), + childWhenDragging: Opacity(opacity: 0.5, child: _playerCardUI(number, realName, stats, teamColor, false, false, sf)), + child: DragTarget( + onAcceptWithDetails: (details) { + final action = details.data; + + if (action == "add_pts_2" || action == "add_pts_3" || action == "miss_2" || action == "miss_3") { + bool isMake = action.startsWith("add_"); + bool is3Pt = action.endsWith("_3"); + showDialog( + context: context, + builder: (ctx) => ZoneMapDialog( + playerName: realName, + isMake: isMake, + is3PointAction: is3Pt, + onZoneSelected: (zone, points, relX, relY) { + Navigator.pop(ctx); + controller.registerShotFromPopup(context, action, "$prefix$playerId", zone, points, relX, relY); + if (isMake) showAssistDialog(context, controller, isOpponent, playerId, sf); + }, + ), + ); + } + else if (action == "add_tov") { + showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( + title: "Escolha o tipo de turnover", + options: { + "add_3s": "3\nsegundos", + "add_24s": "Relógio de\nlançamento\n(24s)", + "add_pa": "Passos", + "add_dr": "Drible duplo", + "add_tov": "Passe ruim", + }, + onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, + sf: sf, + )); + } + else if (action == "add_stl") { + showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( + title: "Ação Defensiva", + options: {"add_stl": "Roubo de Bola\n(BR)", "add_il": "Interceção\nLançamento (IL)"}, + onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, + sf: sf, + )); + } + else if (action == "add_blk") { + showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( + title: "Ação de Desarme / Bloco", + options: {"add_blk": "Fez o Desarme\n(BLK)", "add_li": "Sofreu o Desarme\n(LI)"}, + onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, + sf: sf, + )); + } + else if (action == "add_foul") { + showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( + title: "Escolha o tipo de falta pessoal", + options: { + "Defensiva": "Falta\ndefensiva", + "Ofensiva": "Falta\nofensiva", + "Técnica": "Falta\ntécnica", + "Antidesportiva": "Falta\nantidesportiva", + "Desqualificante": "Falta\ndesqualificante" + }, + onSelected: (foulType) { + Navigator.pop(ctx); + showFoulVictimDialog(context, controller, isOpponent, playerId, foulType, sf); + }, + sf: sf, + )); + } + else if (action.startsWith("add_") || action.startsWith("sub_") || action.startsWith("miss_")) { + controller.handleActionDrag(context, action, "$prefix$playerId"); + } + else if (action.startsWith("bench_")) { + controller.handleSubbing(context, action, playerId, isOpponent); + } + }, + builder: (context, candidateData, rejectedData) { + 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_"))); + + return _playerCardUI(number, realName, stats, teamColor, isSubbing, isActionHover, sf); + }, + ), + ); + } + + Widget _playerCardUI(String number, String displayNameStr, Map stats, Color teamColor, bool isSubbing, bool isActionHover, double sf) { + bool isFouledOut = stats["fls"]! >= 5; + Color bgColor = isFouledOut ? Colors.red.shade100 : Colors.white; + Color borderColor = isFouledOut ? AppTheme.actionMiss : Colors.transparent; + + if (isSubbing) { bgColor = Colors.blue.shade50; borderColor = AppTheme.myTeamBlue; } + else if (isActionHover && !isFouledOut) { bgColor = Colors.orange.shade50; borderColor = AppTheme.actionPoints; } + + int fgm = stats["fgm"]!; int fga = stats["fga"]!; + String fgPercent = fga > 0 ? ((fgm / fga) * 100).toStringAsFixed(0) : "0"; + String displayName = displayNameStr.length > 12 ? "${displayNameStr.substring(0, 10)}..." : displayNameStr; + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 4), + decoration: BoxDecoration(color: bgColor, borderRadius: BorderRadius.circular(8), border: Border.all(color: borderColor, width: 1.5), boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 4, offset: Offset(0, 2))]), + child: ClipRRect( + borderRadius: BorderRadius.circular(6 * sf), + child: IntrinsicHeight( + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + padding: EdgeInsets.symmetric(horizontal: 10 * sf), + color: isFouledOut ? Colors.grey[700] : teamColor, + alignment: Alignment.center, + child: Text(number, style: TextStyle(color: Colors.white, fontSize: 18 * sf, fontWeight: FontWeight.bold)), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8 * sf, vertical: 4 * sf), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(displayName, style: TextStyle(fontSize: 14 * sf, fontWeight: FontWeight.bold, color: isFouledOut ? AppTheme.actionMiss : Colors.black87, decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none)), + SizedBox(height: 1.5 * sf), + Text("${stats["pts"]} Pts | FG: $fgm/$fga ($fgPercent%)", style: TextStyle(fontSize: 10 * sf, color: isFouledOut ? AppTheme.actionMiss : Colors.grey[700], fontWeight: FontWeight.w600)), + Text("${stats["ast"]} Ast | ${stats["orb"]! + stats["drb"]!} Rbs | ${stats["fls"]} Fls", style: TextStyle(fontSize: 10 * sf, color: isFouledOut ? AppTheme.actionMiss : Colors.grey[500], fontWeight: FontWeight.w600)), + ], + ), + ), + ], + ), + ), + ), + ); + } +} + class TopScoreboard extends StatelessWidget { final PlacarController controller; final double sf; @@ -503,7 +867,16 @@ class TopScoreboard extends StatelessWidget { Column( crossAxisAlignment: isOpp ? CrossAxisAlignment.start : CrossAxisAlignment.end, children: [ - Text(name.toUpperCase(), style: TextStyle(color: Colors.white, fontSize: 16 * sf, fontWeight: FontWeight.w900, letterSpacing: 1.0 * sf)), + SizedBox( + width: 130 * sf, + child: Text( + name.toUpperCase(), + style: TextStyle(color: Colors.white, fontSize: 16 * sf, fontWeight: FontWeight.w900, letterSpacing: 1.0 * sf), + overflow: TextOverflow.ellipsis, + maxLines: 1, + textAlign: isOpp ? TextAlign.left : TextAlign.right, + ), + ), SizedBox(height: 3 * sf), Text("FALTAS: $displayFouls", style: TextStyle(color: displayFouls >= 5 ? AppTheme.actionMiss : AppTheme.warningAmber, fontSize: 11 * sf, fontWeight: FontWeight.bold)), ], @@ -604,320 +977,24 @@ class BenchPopup extends StatelessWidget { } } -class PlayerCourtCard extends StatelessWidget { - final PlacarController controller; - final String playerId; - final bool isOpponent; - final double sf; - - const PlayerCourtCard({super.key, required this.controller, required this.playerId, required this.isOpponent, required this.sf}); - - @override - Widget build(BuildContext context) { - final teamColor = isOpponent ? AppTheme.oppTeamRed : AppTheme.myTeamBlue; - - final realName = controller.playerNames[playerId] ?? "Erro"; - final stats = controller.playerStats[playerId]!; - final number = controller.playerNumbers[playerId]!; - final prefix = isOpponent ? "player_opp_" : "player_my_"; - - return Draggable( - data: "$prefix$playerId", - feedback: Material( - color: Colors.transparent, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), - decoration: BoxDecoration(color: teamColor.withOpacity(0.9), borderRadius: BorderRadius.circular(6)), - child: Text(realName, style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold)), - ), - ), - childWhenDragging: Opacity(opacity: 0.5, child: _playerCardUI(number, realName, stats, teamColor, false, false, sf)), - child: DragTarget( - onAcceptWithDetails: (details) { - final action = details.data; - - if (action == "add_pts_2" || action == "add_pts_3" || action == "miss_2" || action == "miss_3") { - bool isMake = action.startsWith("add_"); - bool is3Pt = action.endsWith("_3"); - showDialog( - context: context, - builder: (ctx) => ZoneMapDialog( - playerName: realName, - isMake: isMake, - is3PointAction: is3Pt, - onZoneSelected: (zone, points, relX, relY) { - Navigator.pop(ctx); - controller.registerShotFromPopup(context, action, "$prefix$playerId", zone, points, relX, relY); - if (isMake) showAssistDialog(context, controller, isOpponent, playerId, sf); - }, - ), - ); - } - else if (action == "add_tov") { - showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( - title: "Tipo de Bola Perdida (BP)", - options: { - "add_tov": "Passe Ruim", - "add_pa": "Passos", - "add_dr": "Drible Duplo / Transporte", - "add_3s": "3 Segundos", - "add_24s": "24 Segundos" - }, - onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, - sf: sf, - )); - } - else if (action == "add_stl") { - showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( - title: "Ação Defensiva", - options: {"add_stl": "Roubo de Bola (BR)", "add_il": "Interceção Lançamento (IL)"}, - onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, - sf: sf, - )); - } - else if (action == "add_blk") { - showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( - title: "Ação de Desarme / Bloco", - options: {"add_blk": "Fez o Desarme (BLK)", "add_li": "Sofreu o Desarme (LI)"}, - onSelected: (val) { Navigator.pop(ctx); controller.commitStat(val, "$prefix$playerId"); }, - sf: sf, - )); - } - // O NOVO FLUXO COMPLETO PARA A FALTA: - else if (action == "add_foul") { - showDialog(context: context, builder: (ctx) => ActionSubtypeDialog( - title: "Tipo de Falta", - options: { - "Defensiva": "Falta Defensiva", - "Ofensiva": "Falta Ofensiva", - "Técnica": "Falta Técnica", - "Antidesportiva": "Falta Antidesportiva", - "Desqualificante": "Falta Desqualificante" - }, - onSelected: (foulType) { - Navigator.pop(ctx); - showFoulVictimDialog(context, controller, isOpponent, playerId, foulType, sf); - }, - sf: sf, - )); - } - else if (action.startsWith("add_") || action.startsWith("sub_") || action.startsWith("miss_")) { - controller.handleActionDrag(context, action, "$prefix$playerId"); - } - else if (action.startsWith("bench_")) { - controller.handleSubbing(context, action, playerId, isOpponent); - } - }, - builder: (context, candidateData, rejectedData) { - 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_"))); - - return _playerCardUI(number, realName, stats, teamColor, isSubbing, isActionHover, sf); - }, - ), - ); - } - - Widget _playerCardUI(String number, String displayNameStr, Map stats, Color teamColor, bool isSubbing, bool isActionHover, double sf) { - bool isFouledOut = stats["fls"]! >= 5; - Color bgColor = isFouledOut ? Colors.red.shade100 : Colors.white; - Color borderColor = isFouledOut ? AppTheme.actionMiss : Colors.transparent; - - if (isSubbing) { bgColor = Colors.blue.shade50; borderColor = AppTheme.myTeamBlue; } - else if (isActionHover && !isFouledOut) { bgColor = Colors.orange.shade50; borderColor = AppTheme.actionPoints; } - - int fgm = stats["fgm"]!; int fga = stats["fga"]!; - String fgPercent = fga > 0 ? ((fgm / fga) * 100).toStringAsFixed(0) : "0"; - String displayName = displayNameStr.length > 12 ? "${displayNameStr.substring(0, 10)}..." : displayNameStr; - - return Container( - padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 4), - decoration: BoxDecoration(color: bgColor, borderRadius: BorderRadius.circular(8), border: Border.all(color: borderColor, width: 1.5), boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 4, offset: Offset(0, 2))]), - child: ClipRRect( - borderRadius: BorderRadius.circular(6 * sf), - child: IntrinsicHeight( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - padding: EdgeInsets.symmetric(horizontal: 10 * sf), - color: isFouledOut ? Colors.grey[700] : teamColor, - alignment: Alignment.center, - child: Text(number, style: TextStyle(color: Colors.white, fontSize: 18 * sf, fontWeight: FontWeight.bold)), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8 * sf, vertical: 4 * sf), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(displayName, style: TextStyle(fontSize: 14 * sf, fontWeight: FontWeight.bold, color: isFouledOut ? AppTheme.actionMiss : Colors.black87, decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none)), - SizedBox(height: 1.5 * sf), - Text("${stats["pts"]} Pts | FG: $fgm/$fga ($fgPercent%)", style: TextStyle(fontSize: 10 * sf, color: isFouledOut ? AppTheme.actionMiss : Colors.grey[700], fontWeight: FontWeight.w600)), - Text("${stats["ast"]} Ast | ${stats["orb"]! + stats["drb"]!} Rbs | ${stats["fls"]} Fls", style: TextStyle(fontSize: 10 * sf, color: isFouledOut ? AppTheme.actionMiss : Colors.grey[500], fontWeight: FontWeight.w600)), - ], - ), - ), - ], - ), - ), - ), - ); - } -} - -class ActionButtonsPanel extends StatelessWidget { - final PlacarController controller; - final double sf; - - const ActionButtonsPanel({super.key, required this.controller, required this.sf}); - - @override - Widget build(BuildContext context) { - final double baseSize = 58 * sf; - final double feedSize = 73 * sf; - final double gap = 5 * sf; - - return Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - _columnBtn([ - _dragAndTargetBtn("M1", AppTheme.actionMiss, "miss_1", baseSize, feedSize, sf), - _dragAndTargetBtn("1", AppTheme.actionPoints, "add_pts_1", baseSize, feedSize, sf), - _dragAndTargetBtn("1", AppTheme.actionPoints, "sub_pts_1", baseSize, feedSize, sf, isX: true), - _dragAndTargetBtn("STL", AppTheme.actionSteal, "add_stl", baseSize, feedSize, sf), - ], gap), - SizedBox(width: gap * 1), - _columnBtn([ - _dragAndTargetBtn("M2", AppTheme.actionMiss, "miss_2", baseSize, feedSize, sf), - _dragAndTargetBtn("2", AppTheme.actionPoints, "add_pts_2", baseSize, feedSize, sf), - _dragAndTargetBtn("2", AppTheme.actionPoints, "sub_pts_2", baseSize, feedSize, sf, isX: true), - _dragAndTargetBtn("AST", AppTheme.actionAssist, "add_ast", baseSize, feedSize, sf), - ], gap), - SizedBox(width: gap * 1), - _columnBtn([ - _dragAndTargetBtn("M3", AppTheme.actionMiss, "miss_3", baseSize, feedSize, sf), - _dragAndTargetBtn("3", AppTheme.actionPoints, "add_pts_3", baseSize, feedSize, sf), - _dragAndTargetBtn("3", AppTheme.actionPoints, "sub_pts_3", baseSize, feedSize, sf, isX: true), - _dragAndTargetBtn("TOV", AppTheme.actionMiss, "add_tov", baseSize, feedSize, sf), - ], gap), - SizedBox(width: gap * 1), - _columnBtn([ - _dragAndTargetBtn("ORB", AppTheme.actionRebound, "add_orb", baseSize, feedSize, sf, icon: Icons.sports_basketball), - _dragAndTargetBtn("DRB", AppTheme.actionRebound, "add_drb", baseSize, feedSize, sf, icon: Icons.sports_basketball), - _dragAndTargetBtn("BLK", AppTheme.actionBlock, "add_blk", baseSize, feedSize, sf, icon: Icons.front_hand), - ], gap), - ], - ); - } - - Widget _columnBtn(List children, double gap) { - return Column( - 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}) { - return Draggable( - data: actionData, - feedback: _circle(label, color, icon, true, baseSize, feedSize, sf, isX: isX), - childWhenDragging: Opacity( - opacity: 0.5, - child: _circle(label, color, icon, false, baseSize, feedSize, sf, isX: isX) - ), - child: DragTarget( - onAcceptWithDetails: (details) {}, - builder: (context, candidateData, rejectedData) { - bool isHovered = candidateData.any((data) => data != null && data.startsWith("player_")); - return Transform.scale( - scale: isHovered ? 1.15 : 1.0, - child: Container( - 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}) { - double size = isFeed ? feedSize : baseSize; - Widget content; - bool isPointBtn = label == "1" || label == "2" || label == "3" || label == "M1" || label == "M2" || label == "M3"; - bool isBlkBtn = label == "BLK"; - - if (isPointBtn) { - content = Stack( - alignment: Alignment.center, - children: [ - Container(width: size * 0.75, height: size * 0.75, decoration: const BoxDecoration(color: Colors.black, shape: BoxShape.circle)), - Icon(Icons.sports_basketball, color: color, size: size * 0.9), - Stack( - 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: size * 0.38, fontWeight: FontWeight.w900, color: Colors.black, decoration: TextDecoration.none)), - ], - ), - ], - ); - } else if (isBlkBtn) { - content = Stack( - alignment: Alignment.center, - children: [ - Icon(Icons.front_hand, color: const Color.fromARGB(207, 56, 52, 52), size: size * 0.75), - Stack( - alignment: Alignment.center, - 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: size * 0.28, fontWeight: FontWeight.w900, color: Colors.white, decoration: TextDecoration.none)), - ], - ), - ], - ); - } else if (icon != null) { - content = Icon(icon, color: Colors.white, size: size * 0.5); - } else { - content = Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: size * 0.35, decoration: TextDecoration.none)); - } - - return Stack( - clipBehavior: Clip.none, - alignment: Alignment.bottomRight, - children: [ - Container( - width: size, height: size, - decoration: (isPointBtn || isBlkBtn) - ? const BoxDecoration(color: Colors.transparent) - : BoxDecoration(gradient: RadialGradient(colors: [color.withOpacity(0.7), color], radius: 0.8), shape: BoxShape.circle, boxShadow: [BoxShadow(color: Colors.black38, blurRadius: 6 * sf, offset: Offset(0, 3 * sf))]), - alignment: Alignment.center, - 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))), - ], - ); - } -} - class HeatmapDialog extends StatefulWidget { final List shots; final String myTeamName; final String oppTeamName; - final List myPlayers; - final List oppPlayers; + final List myPlayersIds; + final List oppPlayersIds; final Map> playerStats; + final Map playerNames; const HeatmapDialog({ super.key, required this.shots, required this.myTeamName, required this.oppTeamName, - required this.myPlayers, - required this.oppPlayers, + required this.myPlayersIds, + required this.oppPlayersIds, required this.playerStats, + required this.playerNames, }); @override @@ -927,7 +1004,7 @@ class HeatmapDialog extends StatefulWidget { class _HeatmapDialogState extends State { bool _isMapVisible = false; String _selectedTeam = ''; - String _selectedPlayer = ''; + String _selectedPlayerId = ''; @override Widget build(BuildContext context) { @@ -988,7 +1065,7 @@ class _HeatmapDialogState extends State { Expanded( child: _buildTeamColumn( teamName: widget.myTeamName, - players: widget.myPlayers, + playerIds: widget.myPlayersIds, teamColor: AppTheme.myTeamBlue, ), ), @@ -996,7 +1073,7 @@ class _HeatmapDialogState extends State { Expanded( child: _buildTeamColumn( teamName: widget.oppTeamName, - players: widget.oppPlayers, + playerIds: widget.oppPlayersIds, teamColor: AppTheme.oppTeamRed, ), ), @@ -1008,8 +1085,8 @@ class _HeatmapDialogState extends State { ); } - Widget _buildTeamColumn({required String teamName, required List players, required Color teamColor}) { - List realPlayers = players.where((p) => !p.startsWith("Sem ")).toList(); + Widget _buildTeamColumn({required String teamName, required List playerIds, required Color teamColor}) { + List realPlayerIds = playerIds.where((id) => !id.startsWith("fake_")).toList(); return Container( decoration: BoxDecoration( @@ -1021,7 +1098,7 @@ class _HeatmapDialogState extends State { InkWell( onTap: () => setState(() { _selectedTeam = teamName; - _selectedPlayer = 'Todos'; + _selectedPlayerId = 'Todos'; _isMapVisible = true; }), child: Container( @@ -1046,21 +1123,22 @@ class _HeatmapDialogState extends State { ), Expanded( child: ListView.separated( - itemCount: realPlayers.length, + itemCount: realPlayerIds.length, separatorBuilder: (context, index) => const Divider(height: 1, color: Colors.black12), itemBuilder: (context, index) { - String p = realPlayers[index]; - int pts = widget.playerStats[p]?['pts'] ?? 0; + String pId = realPlayerIds[index]; + String pName = widget.playerNames[pId] ?? 'Desconhecido'; + int pts = widget.playerStats[pId]?['pts'] ?? 0; return ListTile( dense: true, visualDensity: VisualDensity.compact, leading: Icon(Icons.person, color: teamColor), - title: Text(p, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: Colors.black87)), + title: Text(pName, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: Colors.black87)), trailing: Text("$pts Pts", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: teamColor)), onTap: () => setState(() { _selectedTeam = teamName; - _selectedPlayer = p; + _selectedPlayerId = pId; _isMapVisible = true; }), ); @@ -1074,15 +1152,15 @@ class _HeatmapDialogState extends State { Widget _buildMapScreen(Color headerColor) { List filteredShots = widget.shots.where((s) { - if (_selectedPlayer != 'Todos') return s.playerName == _selectedPlayer; - if (_selectedTeam == widget.myTeamName) return widget.myPlayers.contains(s.playerName); - if (_selectedTeam == widget.oppTeamName) return widget.oppPlayers.contains(s.playerName); + if (_selectedPlayerId != 'Todos') return s.playerId == _selectedPlayerId; + if (_selectedTeam == widget.myTeamName) return widget.myPlayersIds.contains(s.playerId); + if (_selectedTeam == widget.oppTeamName) return widget.oppPlayersIds.contains(s.playerId); return true; }).toList(); - String titleText = _selectedPlayer == 'Todos' + String titleText = _selectedPlayerId == 'Todos' ? "MAPA GERAL: ${_selectedTeam.toUpperCase()}" - : "MAPA: ${_selectedPlayer.toUpperCase()}"; + : "MAPA: ${widget.playerNames[_selectedPlayerId]?.toUpperCase() ?? ''}"; return Column( children: [ @@ -1261,46 +1339,51 @@ class BoxScoreDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return Dialog( - backgroundColor: AppTheme.placarDarkSurface, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - child: Container( - width: MediaQuery.of(context).size.width * 0.9, - height: MediaQuery.of(context).size.height * 0.9, - padding: const EdgeInsets.all(16), - child: DefaultTabController( - length: 2, - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return AnimatedBuilder( + animation: controller, + builder: (context, child) { + return Dialog( + backgroundColor: AppTheme.placarDarkSurface, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: Container( + width: MediaQuery.of(context).size.width * 0.9, + height: MediaQuery.of(context).size.height * 0.9, + padding: const EdgeInsets.all(16), + child: DefaultTabController( + length: 2, + child: Column( children: [ - const Text("BOX SCORE", style: TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold)), - IconButton(icon: const Icon(Icons.close, color: Colors.white), onPressed: () => Navigator.pop(context)) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text("BOX SCORE", style: TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold)), + IconButton(icon: const Icon(Icons.close, color: Colors.white), onPressed: () => Navigator.pop(context)) + ], + ), + TabBar( + indicatorColor: AppTheme.warningAmber, + labelColor: Colors.white, + unselectedLabelColor: Colors.white54, + tabs: [ + Tab(text: controller.myTeam.toUpperCase()), + Tab(text: controller.opponentTeam.toUpperCase()), + ], + ), + const SizedBox(height: 10), + Expanded( + child: TabBarView( + children: [ + _buildStatsTable(controller.myCourt + controller.myBench, controller), + _buildStatsTable(controller.oppCourt + controller.oppBench, controller), + ], + ), + ), ], ), - TabBar( - indicatorColor: AppTheme.warningAmber, - labelColor: Colors.white, - unselectedLabelColor: Colors.white54, - tabs: [ - Tab(text: controller.myTeam.toUpperCase()), - Tab(text: controller.opponentTeam.toUpperCase()), - ], - ), - const SizedBox(height: 10), - Expanded( - child: TabBarView( - children: [ - _buildStatsTable(controller.myCourt + controller.myBench, controller), - _buildStatsTable(controller.oppCourt + controller.oppBench, controller), - ], - ), - ), - ], + ), ), - ), - ), + ); + } ); } @@ -1313,6 +1396,7 @@ class BoxScoreDialog extends StatelessWidget { headingRowColor: WidgetStateProperty.all(Colors.black26), columns: const [ DataColumn(label: Text('JOGADOR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))), + DataColumn(label: Text('MIN', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))), DataColumn(label: Text('PTS', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))), DataColumn(label: Text('REB', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))), DataColumn(label: Text('AST', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))), @@ -1331,11 +1415,19 @@ class BoxScoreDialog extends StatelessWidget { rows: teamPlayers.where((id) => !id.startsWith("fake_")).map((id) { final name = ctrl.playerNames[id] ?? "---"; final s = ctrl.playerStats[id]!; + + int totalSecs = s['sec'] ?? 0; + int minutes = totalSecs ~/ 60; + int seconds = totalSecs % 60; + String timeStr = '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + final rebs = s['orb']! + s['drb']!; final fgText = "${s['fgm']}/${s['fga']}"; + return DataRow( cells: [ DataCell(Text(name, style: const TextStyle(color: Colors.white))), + DataCell(Text(timeStr, style: const TextStyle(color: Colors.white70))), DataCell(Text(s['pts'].toString(), style: const TextStyle(color: AppTheme.warningAmber, fontWeight: FontWeight.bold))), DataCell(Text(rebs.toString(), style: const TextStyle(color: Colors.white))), DataCell(Text(s['ast'].toString(), style: const TextStyle(color: Colors.white))), diff --git a/pubspec.lock b/pubspec.lock index 0daf6be..d5e3b37 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -109,10 +109,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" clock: dependency: transitive description: @@ -468,18 +468,18 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.18" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: @@ -873,10 +873,10 @@ packages: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.9" typed_data: dependency: transitive description: