fazer vitoria e derrota

This commit is contained in:
2026-03-10 17:15:10 +00:00
parent d720e09866
commit 49bb371ef4
12 changed files with 940 additions and 742 deletions

View File

@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:playmaker/grafico%20de%20pizza/widgets/grafico_widgets.dart';
import 'package:playmaker/grafico%20de%20pizza/widgets/grafico_widgets.dart'; // Assume que o PieChartWidget está aqui
import 'dados_grafico.dart';
import 'controllers/contollers_grafico.dart';
import 'package:playmaker/classe/home.config.dart';
class PieChartCard extends StatefulWidget {
final PieChartController? controller;
@@ -11,12 +10,21 @@ class PieChartCard extends StatefulWidget {
final Color backgroundColor;
final VoidCallback? onTap;
// Variáveis de escala e tamanho
final double sf;
final double cardWidth;
final double cardHeight;
const PieChartCard({
super.key,
this.controller,
this.title = 'DESEMPENHO',
this.subtitle = 'Vitórias vs Derrotas',
this.onTap, required this.backgroundColor,
this.onTap,
required this.backgroundColor,
this.sf = 1.0,
required this.cardWidth,
required this.cardHeight,
});
@override
@@ -57,6 +65,7 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
@override
Widget build(BuildContext context) {
final data = _controller.chartData;
final double sf = widget.sf;
return AnimatedBuilder(
animation: _animation,
@@ -69,20 +78,20 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
),
);
},
child: Container(
width: HomeConfig.cardwidthPadding,
height: HomeConfig.cardheightPadding,
child: SizedBox( // <-- Força a largura e altura exatas passadas pelo HomeScreen
width: widget.cardWidth,
height: widget.cardHeight,
child: Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(20 * sf),
),
child: InkWell(
onTap: widget.onTap,
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(20 * sf),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(20 * sf),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
@@ -93,55 +102,60 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
),
),
child: Padding(
padding: const EdgeInsets.all(20.0),
padding: EdgeInsets.all(16.0 * sf),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Cabeçalho compacto
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.title,
style: TextStyle(
fontSize: 14, // Pequeno
fontWeight: FontWeight.bold,
color: Colors.white.withOpacity(0.9),
letterSpacing: 1.5,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.title,
style: TextStyle(
fontSize: 12 * sf,
fontWeight: FontWeight.bold,
color: Colors.white.withOpacity(0.9),
letterSpacing: 1.5,
),
),
),
SizedBox(height: 2), // Muito pequeno
Text(
widget.subtitle,
style: TextStyle(
fontSize: 16, // Moderado
fontWeight: FontWeight.bold,
color: Colors.white,
SizedBox(height: 2 * sf),
Text(
widget.subtitle,
style: TextStyle(
fontSize: 14 * sf,
fontWeight: FontWeight.bold,
color: Colors.white,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
],
),
),
Container(
padding: EdgeInsets.all(6), // Pequeno
padding: EdgeInsets.all(6 * sf),
decoration: BoxDecoration(
color: Colors.orange.withOpacity(0.8),
shape: BoxShape.circle,
),
child: Icon(
Icons.pie_chart,
size: 18, // Pequeno
size: 16 * sf,
color: Colors.white,
),
),
],
),
SizedBox(height: 8), // Pequeno espaço
SizedBox(height: 8 * sf),
// Conteúdo principal - COMPACTO E CONTROLADO
// Conteúdo principal
Expanded(
child: Row(
children: [
@@ -153,205 +167,26 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
victoryPercentage: data.victoryPercentage,
defeatPercentage: data.defeatPercentage,
drawPercentage: data.drawPercentage,
size: 130, // Pequeno para caber
size: 120, // O PieChartWidget vai multiplicar isto por `sf` internamente
sf: sf, // <-- Passa a escala para o gráfico
),
),
),
SizedBox(width: 8), // Pequeno espaço
SizedBox(width: 8 * sf),
// Estatísticas - EXTREMAMENTE COMPACTAS
// Estatísticas ultra compactas e sem overflows
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Vitórias - Layout horizontal ultra compacto
Container(
margin: EdgeInsets.only(bottom: 6), // Muito pequeno
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Número
Text(
data.victories.toString(),
style: TextStyle(
fontSize: 26, // Pequeno mas legível
fontWeight: FontWeight.bold,
color: Colors.green,
height: 0.8,
),
),
SizedBox(width: 6), // Pequeno
// Info compacta
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Container(
width: 8,
height: 8,
margin: EdgeInsets.only(right: 4),
decoration: BoxDecoration(
color: Colors.green,
shape: BoxShape.circle,
),
),
Text(
'VIT',
style: TextStyle(
fontSize: 10, // Muito pequeno
color: Colors.white.withOpacity(0.8),
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 2),
Text(
'${(data.victoryPercentage * 100).toStringAsFixed(0)}%',
style: TextStyle(
fontSize: 12, // Pequeno
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
),
// Divisor sutil
Container(
height: 0.5,
color: Colors.white.withOpacity(0.1),
margin: EdgeInsets.symmetric(vertical: 4),
),
// Derrotas
Container(
margin: EdgeInsets.only(bottom: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
data.defeats.toString(),
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: Colors.red,
height: 0.8,
),
),
SizedBox(width: 6),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Container(
width: 8,
height: 8,
margin: EdgeInsets.only(right: 4),
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
Text(
'DER',
style: TextStyle(
fontSize: 10,
color: Colors.white.withOpacity(0.8),
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 2),
Text(
'${(data.defeatPercentage * 100).toStringAsFixed(0)}%',
style: TextStyle(
fontSize: 12,
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
),
// Divisor sutil
Container(
height: 0.5,
color: Colors.white.withOpacity(0.1),
margin: EdgeInsets.symmetric(vertical: 4),
),
// Total
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
data.total.toString(),
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: Colors.white,
height: 0.8,
),
),
SizedBox(width: 6),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Container(
width: 8,
height: 8,
margin: EdgeInsets.only(right: 4),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
),
Text(
'TOT',
style: TextStyle(
fontSize: 10,
color: Colors.white.withOpacity(0.8),
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 2),
Text(
'100%',
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
_buildMiniStatRow("VIT", data.victories.toString(), (data.victoryPercentage * 100).toStringAsFixed(0), Colors.green, sf),
_buildDivider(sf),
_buildMiniStatRow("DER", data.defeats.toString(), (data.defeatPercentage * 100).toStringAsFixed(0), Colors.red, sf),
_buildDivider(sf),
_buildMiniStatRow("TOT", data.total.toString(), "100", Colors.white, sf),
],
),
),
@@ -359,37 +194,40 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
),
),
SizedBox(height: 10), // Espaço controlado
SizedBox(height: 10 * sf),
// Win rate - Sempre visível e não sobreposto
// Win rate - Com FittedBox para não estoirar
Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: EdgeInsets.symmetric(horizontal: 8 * sf, vertical: 6 * sf),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(12 * sf),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
data.victoryPercentage > 0.5
? Icons.trending_up
: Icons.trending_down,
color: data.victoryPercentage > 0.5
? Colors.green
: Colors.red,
size: 18, // Pequeno
),
SizedBox(width: 8),
Text(
'Win Rate: ${(data.victoryPercentage * 100).toStringAsFixed(1)}%',
style: TextStyle(
fontSize: 14, // Pequeno
fontWeight: FontWeight.bold,
color: Colors.white,
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
data.victoryPercentage > 0.5
? Icons.trending_up
: Icons.trending_down,
color: data.victoryPercentage > 0.5
? Colors.green
: Colors.red,
size: 16 * sf,
),
),
],
SizedBox(width: 6 * sf),
Text(
'Win Rate: ${(data.victoryPercentage * 100).toStringAsFixed(1)}%',
style: TextStyle(
fontSize: 12 * sf,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
),
),
],
@@ -401,4 +239,68 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
),
);
}
// Função auxiliar BLINDADA contra overflows
Widget _buildMiniStatRow(String label, String number, String percent, Color color, double sf) {
return Container(
margin: EdgeInsets.only(bottom: 4 * sf),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 28 * sf,
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
number,
style: TextStyle(fontSize: 22 * sf, fontWeight: FontWeight.bold, color: color, height: 1.0),
),
),
),
SizedBox(width: 4 * sf),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
FittedBox(
fit: BoxFit.scaleDown,
child: Row(
children: [
Container(
width: 6 * sf,
height: 6 * sf,
margin: EdgeInsets.only(right: 3 * sf),
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
),
Text(
label,
style: TextStyle(fontSize: 9 * sf, color: Colors.white.withOpacity(0.8), fontWeight: FontWeight.w600),
),
],
),
),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'$percent%',
style: TextStyle(fontSize: 10 * sf, color: color, fontWeight: FontWeight.bold),
),
),
],
),
),
],
),
);
}
Widget _buildDivider(double sf) {
return Container(
height: 0.5,
color: Colors.white.withOpacity(0.1),
margin: EdgeInsets.symmetric(vertical: 3 * sf),
);
}
}