quero que ao voltar para o jogo ele esteja igual quando eu sai
This commit is contained in:
@@ -3,10 +3,12 @@ import 'package:playmaker/pages/PlacarPage.dart'; // Garante que o import está
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
|
||||
// --- CARD DE EXIBIÇÃO DO JOGO (Mantém-se quase igual) ---
|
||||
// --- CARD DE EXIBIÇÃO DO JOGO ---
|
||||
class GameResultCard extends StatelessWidget {
|
||||
final String gameId;
|
||||
final String myTeam, opponentTeam, myScore, opponentScore, status, season;
|
||||
final String? myTeamLogo; // NOVA VARIÁVEL
|
||||
final String? opponentTeamLogo; // NOVA VARIÁVEL
|
||||
|
||||
const GameResultCard({
|
||||
super.key,
|
||||
@@ -17,6 +19,8 @@ class GameResultCard extends StatelessWidget {
|
||||
required this.opponentScore,
|
||||
required this.status,
|
||||
required this.season,
|
||||
this.myTeamLogo, // ADICIONADO AO CONSTRUTOR
|
||||
this.opponentTeamLogo, // ADICIONADO AO CONSTRUTOR
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -32,18 +36,29 @@ class GameResultCard extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: _buildTeamInfo(myTeam, const Color(0xFFE74C3C))),
|
||||
// Passamos a imagem para a função
|
||||
Expanded(child: _buildTeamInfo(myTeam, const Color(0xFFE74C3C), myTeamLogo)),
|
||||
_buildScoreCenter(context, gameId),
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.black87)),
|
||||
// Passamos a imagem para a função
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.black87, opponentTeamLogo)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTeamInfo(String name, Color color) {
|
||||
// ATUALIZADO para desenhar a imagem
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl) {
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(backgroundColor: color, child: const Icon(Icons.shield, color: Colors.white)),
|
||||
CircleAvatar(
|
||||
backgroundColor: color,
|
||||
backgroundImage: (logoUrl != null && logoUrl.isNotEmpty)
|
||||
? NetworkImage(logoUrl)
|
||||
: null,
|
||||
child: (logoUrl == null || logoUrl.isEmpty)
|
||||
? const Icon(Icons.shield, color: Colors.white)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
|
||||
@@ -102,10 +117,10 @@ class GameResultCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// --- POPUP DE CRIAÇÃO (MODIFICADO PARA SUPABASE) ---
|
||||
// --- POPUP DE CRIAÇÃO ---
|
||||
class CreateGameDialogManual extends StatefulWidget {
|
||||
final TeamController teamController;
|
||||
final GameController gameController; // Recebemos o controller do jogo
|
||||
final GameController gameController;
|
||||
|
||||
const CreateGameDialogManual({
|
||||
super.key,
|
||||
@@ -122,7 +137,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
final TextEditingController _myTeamController = TextEditingController();
|
||||
final TextEditingController _opponentController = TextEditingController();
|
||||
|
||||
bool _isLoading = false; // Para mostrar loading no botão
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -150,7 +165,6 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Usamos Autocomplete para equipas (Assumindo que TeamController já é Supabase)
|
||||
_buildSearch(label: "Minha Equipa", controller: _myTeamController),
|
||||
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 8), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey))),
|
||||
@@ -171,7 +185,6 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
if (_myTeamController.text.isNotEmpty && _opponentController.text.isNotEmpty) {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
// 1. CRIAR NO SUPABASE E OBTER O ID REAL
|
||||
String? newGameId = await widget.gameController.createGame(
|
||||
_myTeamController.text,
|
||||
_opponentController.text,
|
||||
@@ -181,10 +194,8 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
setState(() => _isLoading = false);
|
||||
|
||||
if (newGameId != null && context.mounted) {
|
||||
// 2. Fechar Popup
|
||||
Navigator.pop(context);
|
||||
|
||||
// 3. Ir para o Placar com o ID real do banco
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
@@ -206,29 +217,70 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ATUALIZADO para usar Map e mostrar a imagem na lista de pesquisa
|
||||
Widget _buildSearch({required String label, required TextEditingController controller}) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: widget.teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
List<String> teamList = snapshot.hasData
|
||||
? snapshot.data!.map((t) => t['name'].toString()).toList()
|
||||
: [];
|
||||
List<Map<String, dynamic>> teamList = snapshot.hasData ? snapshot.data! : [];
|
||||
|
||||
return Autocomplete<String>(
|
||||
optionsBuilder: (val) {
|
||||
if (val.text.isEmpty) return const Iterable<String>.empty();
|
||||
return teamList.where((t) => t.toLowerCase().contains(val.text.toLowerCase()));
|
||||
return Autocomplete<Map<String, dynamic>>(
|
||||
displayStringForOption: (Map<String, dynamic> option) => option['name'].toString(),
|
||||
|
||||
optionsBuilder: (TextEditingValue val) {
|
||||
if (val.text.isEmpty) return const Iterable<Map<String, dynamic>>.empty();
|
||||
return teamList.where((t) =>
|
||||
t['name'].toString().toLowerCase().contains(val.text.toLowerCase()));
|
||||
},
|
||||
onSelected: (String selection) {
|
||||
controller.text = selection;
|
||||
|
||||
onSelected: (Map<String, dynamic> selection) {
|
||||
controller.text = selection['name'].toString();
|
||||
},
|
||||
|
||||
optionsViewBuilder: (context, onSelected, options) {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4.0,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: ConstrainedBox(
|
||||
// Ajuste do tamanho máximo do pop-up de sugestões
|
||||
constraints: BoxConstraints(maxHeight: 250, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: options.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final option = options.elementAt(index);
|
||||
final String name = option['name'].toString();
|
||||
final String? imageUrl = option['image_url'];
|
||||
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
backgroundImage: (imageUrl != null && imageUrl.isNotEmpty)
|
||||
? NetworkImage(imageUrl)
|
||||
: null,
|
||||
child: (imageUrl == null || imageUrl.isEmpty)
|
||||
? const Icon(Icons.shield, color: Colors.grey)
|
||||
: null,
|
||||
),
|
||||
title: Text(name, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
onTap: () {
|
||||
onSelected(option);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
fieldViewBuilder: (ctx, txtCtrl, node, submit) {
|
||||
// Sincronizar o controller interno do Autocomplete com o nosso controller externo
|
||||
if (txtCtrl.text.isEmpty && controller.text.isNotEmpty) {
|
||||
txtCtrl.text = controller.text;
|
||||
}
|
||||
// Importante: Guardar o valor escrito mesmo que não selecionado da lista
|
||||
txtCtrl.addListener(() {
|
||||
controller.text = txtCtrl.text;
|
||||
});
|
||||
|
||||
337
lib/widgets/placar_widgets.dart
Normal file
337
lib/widgets/placar_widgets.dart
Normal file
@@ -0,0 +1,337 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/controllers/placar_controller.dart';
|
||||
|
||||
// --- PLACAR SUPERIOR ---
|
||||
class TopScoreboard extends StatelessWidget {
|
||||
final PlacarController controller;
|
||||
const TopScoreboard({super.key, required this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 30),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF16202C),
|
||||
borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(15), bottomRight: Radius.circular(15)),
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildTeamSection(controller.myTeam, controller.myScore, controller.myFouls, controller.myTimeoutsUsed, const Color(0xFF1E5BB2), false),
|
||||
const SizedBox(width: 25),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 6),
|
||||
decoration: BoxDecoration(color: const Color(0xFF2C3E50), borderRadius: BorderRadius.circular(6)),
|
||||
child: Text(controller.formatTime(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, fontFamily: 'monospace')),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text("PERÍODO ${controller.currentQuarter}", style: const TextStyle(color: Colors.orangeAccent, fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 25),
|
||||
_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) {
|
||||
final timeoutIndicators = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(3, (index) => Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 3),
|
||||
width: 12, height: 12,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: index < timeouts ? Colors.yellow : Colors.grey.shade600, border: Border.all(color: Colors.black26)),
|
||||
)),
|
||||
);
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: isOpp
|
||||
? [
|
||||
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]),
|
||||
const SizedBox(width: 15),
|
||||
Text(name.toUpperCase(), style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold))
|
||||
]
|
||||
: [
|
||||
Text(name.toUpperCase(), style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(width: 15),
|
||||
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])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scoreBox(int score, Color color) => Container(
|
||||
width: 50, height: 40,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(6)),
|
||||
child: Text(score.toString(), style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
);
|
||||
}
|
||||
|
||||
// --- BANCO DE SUPLENTES ---
|
||||
class BenchPlayersList extends StatelessWidget {
|
||||
final PlacarController controller;
|
||||
final bool isOpponent;
|
||||
const BenchPlayersList({super.key, required this.controller, required this.isOpponent});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bench = isOpponent ? controller.oppBench : controller.myBench;
|
||||
final teamColor = isOpponent ? const Color(0xFFD92C2C) : const Color(0xFF1E5BB2);
|
||||
final prefix = isOpponent ? "bench_opp_" : "bench_my_";
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: bench.map((playerName) {
|
||||
final num = controller.playerNumbers[playerName] ?? "0";
|
||||
final int fouls = controller.playerStats[playerName]?["fls"] ?? 0;
|
||||
final bool isFouledOut = fouls >= 5;
|
||||
|
||||
Widget avatarUI = Container(
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: isFouledOut ? Colors.grey.shade700 : teamColor,
|
||||
child: Text(num, style: TextStyle(color: isFouledOut ? Colors.red.shade300 : Colors.white, fontSize: 14, decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none)),
|
||||
),
|
||||
);
|
||||
|
||||
if (isFouledOut) {
|
||||
return GestureDetector(
|
||||
onTap: () => ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('🛑 $playerName não pode voltar (Expulso).'), backgroundColor: Colors.red)),
|
||||
child: avatarUI,
|
||||
);
|
||||
}
|
||||
|
||||
return Draggable<String>(
|
||||
data: "$prefix$playerName",
|
||||
feedback: Material(color: Colors.transparent, child: CircleAvatar(backgroundColor: teamColor, child: Text(num, style: const TextStyle(color: Colors.white)))),
|
||||
childWhenDragging: const Opacity(opacity: 0.5, child: SizedBox(width: 40, height: 40)),
|
||||
child: avatarUI,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- CARTÃO DO JOGADOR NO CAMPO ---
|
||||
class PlayerCourtCard extends StatelessWidget {
|
||||
final PlacarController controller;
|
||||
final String name;
|
||||
final bool isOpponent;
|
||||
|
||||
const PlayerCourtCard({super.key, required this.controller, required this.name, required this.isOpponent});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final teamColor = isOpponent ? const Color(0xFFD92C2C) : const Color(0xFF1E5BB2);
|
||||
final stats = controller.playerStats[name]!;
|
||||
final number = controller.playerNumbers[name]!;
|
||||
final prefix = isOpponent ? "player_opp_" : "player_my_";
|
||||
|
||||
return Draggable<String>(
|
||||
data: "$prefix$name",
|
||||
feedback: Material(
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(color: teamColor.withOpacity(0.9), borderRadius: BorderRadius.circular(8)),
|
||||
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)),
|
||||
child: DragTarget<String>(
|
||||
onAcceptWithDetails: (details) {
|
||||
final action = details.data;
|
||||
if (action.startsWith("add_") || action.startsWith("sub_") || action.startsWith("miss_")) {
|
||||
controller.handleActionDrag(context, action, "$prefix$name");
|
||||
}
|
||||
else if (action.startsWith("bench_")) {
|
||||
controller.handleSubbing(context, action, name, 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, name, stats, teamColor, isSubbing, isActionHover);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _playerCardUI(String number, String name, Map<String, int> stats, Color teamColor, bool isSubbing, bool isActionHover) {
|
||||
bool isFouledOut = stats["fls"]! >= 5;
|
||||
Color bgColor = isFouledOut ? Colors.red.shade100 : Colors.white;
|
||||
Color borderColor = isFouledOut ? Colors.redAccent : Colors.transparent;
|
||||
|
||||
if (isSubbing) { bgColor = Colors.blue.shade50; borderColor = Colors.blue; }
|
||||
else if (isActionHover && !isFouledOut) { bgColor = Colors.orange.shade50; borderColor = Colors.orange; }
|
||||
|
||||
int fgm = stats["fgm"]!;
|
||||
int fga = stats["fga"]!;
|
||||
String fgPercent = fga > 0 ? ((fgm / fga) * 100).toStringAsFixed(0) : "0";
|
||||
String displayName = name.length > 12 ? "${name.substring(0, 10)}..." : name;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor, borderRadius: BorderRadius.circular(12), border: Border.all(color: borderColor, width: 2),
|
||||
boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 6, offset: Offset(0, 3))],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 40, height: 40,
|
||||
decoration: BoxDecoration(color: isFouledOut ? Colors.grey : teamColor, borderRadius: BorderRadius.circular(8)),
|
||||
alignment: Alignment.center,
|
||||
child: Text(number, style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(displayName, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: isFouledOut ? Colors.red : Colors.black87, decoration: isFouledOut ? TextDecoration.lineThrough : TextDecoration.none)),
|
||||
const SizedBox(height: 1),
|
||||
Text("${stats["pts"]} Pts | FG: $fgm/$fga ($fgPercent%)", style: TextStyle(fontSize: 11, color: isFouledOut ? Colors.red : Colors.grey[700], fontWeight: FontWeight.w600)),
|
||||
Text("${stats["ast"]} Ast | ${stats["rbs"]} Rbs | ${stats["fls"]} Fls", style: TextStyle(fontSize: 11, color: isFouledOut ? Colors.red : Colors.grey, fontWeight: FontWeight.w500)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- PAINEL DE BOTÕES DE AÇÃO ---
|
||||
class ActionButtonsPanel extends StatelessWidget {
|
||||
final PlacarController controller;
|
||||
const ActionButtonsPanel({super.key, required this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
_columnBtn([
|
||||
_actionBtn("T.O", const Color(0xFF1E5BB2), () => controller.useTimeout(false), labelSize: 20),
|
||||
_dragAndTargetBtn("1", Colors.orange, "add_pts_1"),
|
||||
_dragAndTargetBtn("1", Colors.orange, "sub_pts_1", isX: true),
|
||||
_dragAndTargetBtn("STL", Colors.green, "add_stl"),
|
||||
|
||||
]),
|
||||
const SizedBox(width: 15),
|
||||
_columnBtn([
|
||||
_dragAndTargetBtn("M2", Colors.redAccent, "miss_2"),
|
||||
_dragAndTargetBtn("2", Colors.orange, "add_pts_2"),
|
||||
_dragAndTargetBtn("2", Colors.orange, "sub_pts_2", isX: true),
|
||||
_dragAndTargetBtn("AST", Colors.blueGrey, "add_ast"),
|
||||
]),
|
||||
const SizedBox(width: 15),
|
||||
_columnBtn([
|
||||
_dragAndTargetBtn("M3", Colors.redAccent, "miss_3"),
|
||||
_dragAndTargetBtn("3", Colors.orange, "add_pts_3"),
|
||||
_dragAndTargetBtn("3", Colors.orange, "sub_pts_3", isX: true),
|
||||
_dragAndTargetBtn("TOV", Colors.redAccent, "add_tov"),
|
||||
]),
|
||||
const SizedBox(width: 15),
|
||||
_columnBtn([
|
||||
_actionBtn("T.O", const Color(0xFFD92C2C), () => controller.useTimeout(true), labelSize: 20),
|
||||
_dragAndTargetBtn("ORB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
|
||||
_dragAndTargetBtn("DRB", const Color(0xFF1E2A38), "add_rbs", icon: Icons.sports_basketball),
|
||||
|
||||
_dragAndTargetBtn("BLK", Colors.deepPurple, "add_blk", icon: Icons.front_hand),
|
||||
]),
|
||||
const SizedBox(width: 15),
|
||||
_columnBtn([
|
||||
])
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Mantenha os métodos _columnBtn, _dragAndTargetBtn, _actionBtn e _circle exatamente como estão
|
||||
Widget _columnBtn(List<Widget> children) => Column(mainAxisSize: MainAxisSize.min, children: children.map((c) => Padding(padding: const EdgeInsets.only(bottom: 8), child: c)).toList());
|
||||
|
||||
Widget _dragAndTargetBtn(String label, Color color, String actionData, {IconData? icon, bool isX = false}) {
|
||||
return Draggable<String>(
|
||||
data: actionData,
|
||||
feedback: _circle(label, color, icon, true, isX: isX),
|
||||
childWhenDragging: Opacity(opacity: 0.5, child: _circle(label, color, icon, false, isX: isX)),
|
||||
child: DragTarget<String>(
|
||||
onAcceptWithDetails: (details) {
|
||||
final playerData = details.data;
|
||||
// Requer um BuildContext, não acessível diretamente no Stateless, então não fazemos nada aqui.
|
||||
// O target real está no PlayerCourtCard!
|
||||
},
|
||||
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: const [BoxShadow(color: Colors.white, blurRadius: 10, spreadRadius: 3)]) : null, child: _circle(label, color, icon, false, isX: isX)),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionBtn(String label, Color color, VoidCallback onTap, {IconData? icon, bool isX = false, double labelSize = 24}) {
|
||||
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;
|
||||
bool isPointBtn = label == "1" || label == "2" || label == "3" || label == "M2" || label == "M3";
|
||||
bool isBlkBtn = label == "BLK";
|
||||
|
||||
if (isPointBtn) {
|
||||
content = Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
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: isFeed ? 65 : 55),
|
||||
Stack(
|
||||
children: [
|
||||
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: isFeed ? 26 : 22, 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: isFeed ? 55 : 45),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
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: isFeed ? 18 : 16, fontWeight: FontWeight.w900, color: Colors.white, decoration: TextDecoration.none)),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (icon != null) {
|
||||
content = Icon(icon, color: Colors.white, size: 30);
|
||||
} else {
|
||||
content = Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: fontSize, decoration: TextDecoration.none));
|
||||
}
|
||||
|
||||
return Stack(
|
||||
clipBehavior: Clip.none, alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
Container(
|
||||
width: isFeed ? 70 : 60, height: isFeed ? 70 : 60,
|
||||
decoration: (isPointBtn || isBlkBtn) ? const BoxDecoration(color: Colors.transparent) : BoxDecoration(gradient: RadialGradient(colors: [color.withOpacity(0.7), color], radius: 0.8), shape: BoxShape.circle, boxShadow: const [BoxShadow(color: Colors.black38, blurRadius: 6, offset: Offset(0, 3))]),
|
||||
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: isFeed ? 28 : 24))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user