melhorar os icon de jogo

This commit is contained in:
2026-04-21 17:18:44 +01:00
parent cc753b395d
commit bc93bb748f
6 changed files with 281 additions and 192 deletions

View File

@@ -1,27 +1,237 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:playmaker/classe/theme.dart';
import 'package:playmaker/controllers/placar_controller.dart';
import 'package:flutter/material.dart';
import 'package:playmaker/classe/theme.dart';
import 'package:playmaker/controllers/placar_controller.dart';
void main() {
runApp(const MyApp());
// ============================================================================
// 4. PAINEL DE BOTÕES DE ACÇÃO (DRAG & DROP)
// ============================================================================
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("O", AppTheme.actionRebound, "add_orb", baseSize, feedSize, sf),
_dragAndTargetBtn("D", AppTheme.actionRebound, "add_drb", baseSize, feedSize, sf),
_dragAndTargetBtn("BLK", AppTheme.actionBlock, "add_blk", baseSize, feedSize, sf),
], gap),
],
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
Widget _columnBtn(List<Widget> children, double gap) {
return Column(
mainAxisSize: MainAxisSize.min,
children: children.map((c) => Padding(padding: EdgeInsets.only(bottom: gap), child: c)).toList()
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Ícone de Basquete'),
Widget _dragAndTargetBtn(String label, Color color, String actionData, double baseSize, double feedSize, double sf, {IconData? icon, bool isX = false}) {
return Draggable<String>(
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<String>(
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 isRebBtn = label == "O" || label == "D";
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)),
],
),
body: const Center(
child: Icon(
Icons.sports_basketball,
size: 100.0, // Tamanho do ícone
color: Colors.black, // Cor do ícone (preto, como na imagem)
],
);
}
else if (isRebBtn) {
content = Stack(
children: [
Center(
child: SizedBox(
width: size * 0.80,
height: size * 0.80,
child: CustomPaint(painter: HoopIconPainter()),
),
),
),
Positioned(
top: size * -0.05, // Mantido no topo conforme solicitado
right: size * 0.05,
child: Stack(
children: [
Text(label, style: TextStyle(
fontSize: size * 0.48, // Tamanho aumentado conforme código anterior
fontWeight: FontWeight.w900,
foreground: Paint()..style = PaintingStyle.stroke..strokeWidth = size * 0.07..color = Colors.black,
decoration: TextDecoration.none
)),
Text(label, style: TextStyle(
fontSize: size * 0.48, // Tamanho aumentado conforme código anterior
fontWeight: FontWeight.w900,
color: Colors.white,
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 {
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 || isRebBtn)
? 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))),
],
);
}
}
// =====================================================================
// PAINTER DA CESTA (MAIOR E PRETO)
// =====================================================================
class HoopIconPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final double w = size.width;
final double h = size.height;
final Paint paint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = w * 0.08
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round;
// 1. Tabela Grande
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTRB(w * 0.02, h * 0.02, w * 0.98, h * 0.70),
Radius.circular(w * 0.05)
),
paint
);
// 2. Quadrado do Alvo
canvas.drawRect(
Rect.fromLTRB(w * 0.28, h * 0.30, w * 0.72, h * 0.70),
paint
);
// 3. Aro (Laranja)
final Paint rimPaint = Paint()
..color = Colors.orange
..style = PaintingStyle.stroke
..strokeWidth = w * 0.09
..strokeCap = StrokeCap.round;
canvas.drawLine(
Offset(w * 0.20, h * 0.75),
Offset(w * 0.80, h * 0.75),
rimPaint
);
// 4. Rede
final Paint netPaint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = w * 0.05;
canvas.drawLine(Offset(w * 0.25, h * 0.75), Offset(w * 0.40, h * 0.98), netPaint);
canvas.drawLine(Offset(w * 0.75, h * 0.75), Offset(w * 0.60, h * 0.98), netPaint);
canvas.drawLine(Offset(w * 0.40, h * 0.75), Offset(w * 0.30, h * 0.98), netPaint);
canvas.drawLine(Offset(w * 0.60, h * 0.75), Offset(w * 0.70, h * 0.98), netPaint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}