vai te lixar github
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/grafico%20de%20pizza/widgets/grafico_widgets.dart';
|
||||
import 'dados_grafico.dart';
|
||||
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORT DO TEMA ADICIONADO PARA USARMOS O primaryRed
|
||||
import 'dart:math' as math;
|
||||
|
||||
class PieChartCard extends StatefulWidget {
|
||||
final int victories;
|
||||
@@ -8,7 +10,7 @@ class PieChartCard extends StatefulWidget {
|
||||
final int draws;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final Color backgroundColor;
|
||||
final Color? backgroundColor;
|
||||
final VoidCallback? onTap;
|
||||
final double sf;
|
||||
|
||||
@@ -20,7 +22,7 @@ class PieChartCard extends StatefulWidget {
|
||||
this.title = 'DESEMPENHO',
|
||||
this.subtitle = 'Temporada',
|
||||
this.onTap,
|
||||
required this.backgroundColor,
|
||||
this.backgroundColor,
|
||||
this.sf = 1.0,
|
||||
});
|
||||
|
||||
@@ -59,30 +61,31 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
|
||||
Widget build(BuildContext context) {
|
||||
final data = PieChartData(victories: widget.victories, defeats: widget.defeats, draws: widget.draws);
|
||||
|
||||
return AnimatedBuilder(
|
||||
// 👇 BLINDAGEM DO FUNDO E DO TEXTO PARA MODO CLARO/ESCURO
|
||||
final Color cardColor = widget.backgroundColor ?? Theme.of(context).cardTheme.color ?? (Theme.of(context).brightness == Brightness.dark ? const Color(0xFF1E1E1E) : Colors.white);
|
||||
final Color textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
// O scale pode passar de 1.0 (efeito back), mas a opacidade NÃO
|
||||
scale: 0.95 + (_animation.value * 0.05),
|
||||
child: Opacity(
|
||||
// 👇 AQUI ESTÁ A FIX: Garante que fica entre 0 e 1
|
||||
opacity: _animation.value.clamp(0.0, 1.0),
|
||||
child: child,
|
||||
),
|
||||
child: Opacity(opacity: _animation.value.clamp(0.0, 1.0), child: child),
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
margin: EdgeInsets.zero,
|
||||
elevation: 4,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
elevation: 0, // Ajustado para não ter sombra dupla, já que o tema pode ter
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
side: BorderSide(color: Colors.grey.withOpacity(0.15)), // Borda suave igual ao resto da app
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: widget.onTap,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
gradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [widget.backgroundColor.withOpacity(0.9), widget.backgroundColor.withOpacity(0.7)]),
|
||||
color: cardColor, // 👇 APLICA A COR BLINDADA
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
@@ -90,86 +93,101 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
|
||||
final double cw = constraints.maxWidth;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(cw * 0.06),
|
||||
padding: EdgeInsets.symmetric(horizontal: cw * 0.05, vertical: ch * 0.03),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 👇 TÍTULOS UM POUCO MAIS PRESENTES
|
||||
// --- CABEÇALHO --- (👇 MANTIDO ALINHADO À ESQUERDA)
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(widget.title.toUpperCase(), style: TextStyle(fontSize: ch * 0.06, fontWeight: FontWeight.bold, color: Colors.white.withOpacity(0.9), letterSpacing: 1.0)),
|
||||
child: Text(widget.title.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: ch * 0.045,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.primaryRed, // 👇 USANDO O TEU primaryRed
|
||||
letterSpacing: 1.2
|
||||
)
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(widget.subtitle, style: TextStyle(fontSize: ch * 0.07, fontWeight: FontWeight.bold, color: Colors.white)),
|
||||
Text(widget.subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: ch * 0.055,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.backgroundLight, // 👇 USANDO O TEU backgroundLight
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(height: ch * 0.03),
|
||||
const Expanded(flex: 1, child: SizedBox()),
|
||||
|
||||
// MEIO (GRÁFICO + ESTATÍSTICAS)
|
||||
Expanded(
|
||||
// --- MIOLO (GRÁFICO MAIOR À ESQUERDA + STATS) ---
|
||||
Expanded(
|
||||
flex: 9,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.end, // Changed from spaceBetween to end to push stats more to the right
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
// 1. Lado Esquerdo: Donut Chart
|
||||
// 👇 MUDANÇA AQUI: Gráfico ainda maior! cw * 0.52
|
||||
SizedBox(
|
||||
width: cw * 0.52,
|
||||
height: cw * 0.52,
|
||||
child: PieChartWidget(
|
||||
victoryPercentage: data.victoryPercentage,
|
||||
defeatPercentage: data.defeatPercentage,
|
||||
drawPercentage: data.drawPercentage,
|
||||
sf: widget.sf,
|
||||
sf: widget.sf,
|
||||
),
|
||||
),
|
||||
SizedBox(width: cw * 0.05),
|
||||
|
||||
SizedBox(width: cw * 0.005), // Reduzi o espaço no meio para dar lugar ao gráfico
|
||||
|
||||
// 2. Lado Direito: Números Dinâmicos
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDynStatRow("VIT", data.victories.toString(), (data.victoryPercentage * 100).toStringAsFixed(0), Colors.green, ch),
|
||||
_buildDynStatRow("EMP", data.draws.toString(), (data.drawPercentage * 100).toStringAsFixed(0), Colors.yellow, ch),
|
||||
_buildDynStatRow("DER", data.defeats.toString(), (data.defeatPercentage * 100).toStringAsFixed(0), Colors.red, ch),
|
||||
_buildDynDivider(ch),
|
||||
_buildDynStatRow("TOT", data.total.toString(), "100", Colors.white, ch),
|
||||
],
|
||||
child: FittedBox(
|
||||
alignment: Alignment.centerRight, // Encosta os números à direita
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end, // Alinha os números à direita para ficar arrumado
|
||||
children: [
|
||||
_buildDynStatRow("VIT", data.victories.toString(), (data.victoryPercentage * 100).toStringAsFixed(0), Colors.green, textColor, ch, cw),
|
||||
_buildDynStatRow("EMP", data.draws.toString(), (data.drawPercentage * 100).toStringAsFixed(0), Colors.amber, textColor, ch, cw),
|
||||
_buildDynStatRow("DER", data.defeats.toString(), (data.defeatPercentage * 100).toStringAsFixed(0), Colors.red, textColor, ch, cw),
|
||||
_buildDynDivider(cw, textColor),
|
||||
_buildDynStatRow("TOT", data.total.toString(), "100", textColor, textColor, ch, cw),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 👇 RODAPÉ AJUSTADO
|
||||
SizedBox(height: ch * 0.03),
|
||||
|
||||
const Expanded(flex: 1, child: SizedBox()),
|
||||
|
||||
// --- RODAPÉ: BOTÃO WIN RATE GIGANTE --- (👇 MUDANÇA AQUI: Alinhado à esquerda)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.symmetric(vertical: ch * 0.035),
|
||||
padding: EdgeInsets.symmetric(vertical: ch * 0.025),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white24, // Igual ao fundo do botão detalhes
|
||||
borderRadius: BorderRadius.circular(ch * 0.03), // Borda arredondada
|
||||
color: textColor.withOpacity(0.05), // 👇 Fundo adaptável
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Center(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
data.victoryPercentage >= 0.5 ? Icons.trending_up : Icons.trending_down,
|
||||
color: Colors.green,
|
||||
size: ch * 0.09
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start, // 👇 MUDANÇA AQUI: Letras mais para a esquerda!
|
||||
children: [
|
||||
Icon(Icons.stars, color: Colors.green, size: ch * 0.075),
|
||||
const SizedBox(width: 10),
|
||||
Text('WIN RATE: ${(data.victoryPercentage * 100).toStringAsFixed(1)}%',
|
||||
style: TextStyle(
|
||||
color: AppTheme.backgroundLight,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: 1.0,
|
||||
fontSize: ch * 0.06
|
||||
),
|
||||
SizedBox(width: cw * 0.02),
|
||||
Text(
|
||||
'WIN RATE: ${(data.victoryPercentage * 100).toStringAsFixed(1)}%',
|
||||
style: TextStyle(
|
||||
fontSize: ch * 0.05,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -183,34 +201,39 @@ class _PieChartCardState extends State<PieChartCard> with SingleTickerProviderSt
|
||||
),
|
||||
);
|
||||
}
|
||||
// 👇 PERCENTAGENS SUBIDAS LIGEIRAMENTE (0.10 e 0.045)
|
||||
Widget _buildDynStatRow(String label, String number, String percent, Color color, double ch) {
|
||||
|
||||
// 👇 Ajustei a linha de stats para alinhar melhor agora que os números estão encostados à direita
|
||||
Widget _buildDynStatRow(String label, String number, String percent, Color statColor, Color textColor, double ch, double cw) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: ch * 0.01),
|
||||
padding: EdgeInsets.symmetric(vertical: ch * 0.005),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Número subiu para 0.10
|
||||
Expanded(flex: 2, child: FittedBox(fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, child: Text(number, style: TextStyle(fontSize: ch * 0.10, fontWeight: FontWeight.bold, color: color, height: 1.0)))),
|
||||
SizedBox(width: ch * 0.02),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
|
||||
Row(children: [
|
||||
Container(width: ch * 0.018, height: ch * 0.018, margin: EdgeInsets.only(right: ch * 0.015), decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
|
||||
// Label subiu para 0.045
|
||||
Expanded(child: FittedBox(fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, child: Text(label, style: TextStyle(fontSize: ch * 0.033, color: Colors.white.withOpacity(0.8), fontWeight: FontWeight.w600))))
|
||||
]),
|
||||
// Percentagem subiu para 0.05
|
||||
FittedBox(fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, child: Text('$percent%', style: TextStyle(fontSize: ch * 0.04, color: color, fontWeight: FontWeight.bold))),
|
||||
]),
|
||||
SizedBox(
|
||||
width: cw * 0.12,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label, style: TextStyle(fontSize: ch * 0.045, color: textColor.withOpacity(0.6), fontWeight: FontWeight.bold)), // 👇 TEXTO ADAPTÁVEL (increased from 0.035)
|
||||
Text('$percent%', style: TextStyle(fontSize: ch * 0.05, color: statColor, fontWeight: FontWeight.bold)), // (increased from 0.04)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: cw * 0.03),
|
||||
Text(number, style: TextStyle(fontSize: ch * 0.15, fontWeight: FontWeight.w900, color: statColor, height: 1)), // (increased from 0.125)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDynDivider(double ch) {
|
||||
return Container(height: 0.5, color: Colors.white.withOpacity(0.1), margin: EdgeInsets.symmetric(vertical: ch * 0.01));
|
||||
Widget _buildDynDivider(double cw, Color textColor) {
|
||||
return Container(
|
||||
width: cw * 0.35,
|
||||
height: 1.5,
|
||||
color: textColor.withOpacity(0.2), // 👇 LINHA ADAPTÁVEL
|
||||
margin: const EdgeInsets.symmetric(vertical: 4)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user