PlayMaker/lib/widgets/home_widgets.dart

208 lines
6.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:playmaker/classe/home.config.dart';
class StatCard extends StatelessWidget {
final String title;
final String playerName;
final String statValue;
final String statLabel;
final Color color;
final IconData icon;
final bool isHighlighted;
final VoidCallback? onTap;
const StatCard({
super.key,
required this.title,
required this.playerName,
required this.statValue,
required this.statLabel,
required this.color,
required this.icon,
this.isHighlighted = false,
this.onTap,
});
@override
Widget build(BuildContext context) {
return Container(
width: HomeConfig.cardwidthPadding,
height: HomeConfig.cardheightPadding,
child: Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
side: isHighlighted
? BorderSide(color: Colors.amber, width: 2)
: BorderSide.none,
),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(20),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
color.withOpacity(0.9),
color.withOpacity(0.7),
],
),
),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Cabeçalho
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title.toUpperCase(),
style: HomeConfig.titleStyle,
),
SizedBox(height: 5),
Text(
playerName,
style: HomeConfig.playerNameStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
if (isHighlighted)
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle,
),
child: Icon(
Icons.star,
size: 20,
color: Colors.white,
),
),
],
),
SizedBox(height: 10),
// Ícone
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: Icon(
icon,
size: 30,
color: Colors.white,
),
),
Spacer(),
// Estatística
Center(
child: Column(
children: [
Text(
statValue,
style: HomeConfig.statValueStyle,
),
SizedBox(height: 5),
Text(
statLabel.toUpperCase(),
style: HomeConfig.statLabelStyle,
),
],
),
),
Spacer(),
// Botão
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Text(
'VER DETALHES',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14,
letterSpacing: 1,
),
),
),
),
],
),
),
),
),
),
);
}
}
class SportGrid extends StatelessWidget {
final List<Widget> children;
final double spacing;
const SportGrid({
super.key,
required this.children,
this.spacing = HomeConfig.cardSpacing,
});
@override
Widget build(BuildContext context) {
if (children.isEmpty) return SizedBox();
return Column(
children: [
// Primeira linha
if (children.length >= 2)
Padding(
padding: EdgeInsets.only(bottom: spacing),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children[0],
SizedBox(width: spacing),
children[1],
],
),
),
// Segunda linha
if (children.length >= 4)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children[2],
SizedBox(width: spacing),
children[3],
],
),
],
);
}
}