vai te lixar github
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/classe/home.config.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import 'package:playmaker/grafico%20de%20pizza/grafico.dart';
|
||||
import 'package:playmaker/pages/gamePage.dart';
|
||||
import 'package:playmaker/pages/teamPage.dart';
|
||||
import 'package:playmaker/controllers/team_controller.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:playmaker/pages/status_page.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
import 'package:playmaker/grafico%20de%20pizza/controllers/contollers_grafico.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
import 'settings_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
@@ -30,24 +30,28 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Já não precisamos calcular o sf aqui!
|
||||
|
||||
final List<Widget> pages = [
|
||||
_buildHomeContent(context), // Passamos só o context
|
||||
_buildHomeContent(context),
|
||||
const GamePage(),
|
||||
const TeamsPage(),
|
||||
const StatusPage(),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // Fundo dinâmico
|
||||
appBar: AppBar(
|
||||
title: Text('PlayMaker', style: TextStyle(fontSize: 20 * context.sf)),
|
||||
backgroundColor: HomeConfig.primaryColor,
|
||||
backgroundColor: AppTheme.primaryRed,
|
||||
foregroundColor: Colors.white,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.person, size: 24 * context.sf),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
// 👇 MAGIA ACONTECE AQUI 👇
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const SettingsScreen()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -62,7 +66,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
|
||||
elevation: 1,
|
||||
// O math.min não é necessário se já tens o sf. Mas podes usar context.sf
|
||||
height: 70 * (context.sf < 1.2 ? context.sf : 1.2),
|
||||
destinations: const [
|
||||
NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home_filled), label: 'Home'),
|
||||
@@ -77,13 +80,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
void _showTeamSelector(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface, // Fundo dinâmico
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20 * context.sf))),
|
||||
builder: (context) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: _teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return const SizedBox(height: 200, child: Center(child: CircularProgressIndicator()));
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return SizedBox(height: 200 * context.sf, child: const Center(child: Text("Nenhuma equipa criada.")));
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return SizedBox(height: 200 * context.sf, child: Center(child: Text("Nenhuma equipa criada.", style: TextStyle(color: Theme.of(context).colorScheme.onSurface))));
|
||||
|
||||
final teams = snapshot.data!;
|
||||
return ListView.builder(
|
||||
@@ -92,7 +96,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
final team = teams[index];
|
||||
return ListTile(
|
||||
title: Text(team['name']),
|
||||
title: Text(team['name'], style: TextStyle(color: Theme.of(context).colorScheme.onSurface)), // Texto dinâmico
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedTeamId = team['id'];
|
||||
@@ -115,6 +119,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget _buildHomeContent(BuildContext context) {
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double cardHeight = wScreen * 0.5;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: _selectedTeamId != null
|
||||
@@ -133,12 +138,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
onTap: () => _showTeamSelector(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(12 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(15 * context.sf), border: Border.all(color: Colors.grey.shade300)),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardTheme.color,
|
||||
borderRadius: BorderRadius.circular(15 * context.sf),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.2))
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [Icon(Icons.shield, color: HomeConfig.primaryColor, size: 24 * context.sf), SizedBox(width: 10 * context.sf), Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold))]),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
Row(children: [
|
||||
Icon(Icons.shield, color: AppTheme.primaryRed, size: 24 * context.sf),
|
||||
SizedBox(width: 10 * context.sf),
|
||||
Text(_selectedTeamName, style: TextStyle(fontSize: 16 * context.sf, fontWeight: FontWeight.bold, color: textColor))
|
||||
]),
|
||||
Icon(Icons.arrow_drop_down, color: textColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -149,9 +162,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
height: cardHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Mais Pontos', playerName: leaders['pts_name'], statValue: leaders['pts_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF1565C0), isHighlighted: true)),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Mais Pontos', playerName: leaders['pts_name'], statValue: leaders['pts_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statPtsBg, isHighlighted: true)),
|
||||
SizedBox(width: 12 * context.sf),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Assistências', playerName: leaders['ast_name'], statValue: leaders['ast_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF2E7D32))),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Assistências', playerName: leaders['ast_name'], statValue: leaders['ast_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statAstBg)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -161,7 +174,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
height: cardHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Rebotes', playerName: leaders['rbs_name'], statValue: leaders['rbs_val'].toString(), statLabel: 'TOTAL', color: const Color(0xFF6A1B9A))),
|
||||
Expanded(child: _buildStatCard(context: context, title: 'Rebotes', playerName: leaders['rbs_name'], statValue: leaders['rbs_val'].toString(), statLabel: 'TOTAL', color: AppTheme.statRebBg)),
|
||||
SizedBox(width: 12 * context.sf),
|
||||
Expanded(
|
||||
child: PieChartCard(
|
||||
@@ -170,8 +183,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
draws: _teamDraws,
|
||||
title: 'DESEMPENHO',
|
||||
subtitle: 'Temporada',
|
||||
backgroundColor: const Color(0xFFC62828),
|
||||
sf: context.sf // Aqui o PieChartCard ainda usa sf, então passamos
|
||||
backgroundColor: AppTheme.statPieBg,
|
||||
sf: context.sf
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -179,7 +192,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
SizedBox(height: 40 * context.sf),
|
||||
|
||||
Text('Histórico de Jogos', style: TextStyle(fontSize: 20 * context.sf, fontWeight: FontWeight.bold, color: Colors.grey[800])),
|
||||
Text('Histórico de Jogos', style: TextStyle(fontSize: 20 * context.sf, fontWeight: FontWeight.bold, color: textColor)),
|
||||
SizedBox(height: 16 * context.sf),
|
||||
|
||||
_selectedTeamName == "Selecionar Equipa"
|
||||
@@ -192,7 +205,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
stream: _supabase.from('games').stream(primaryKey: ['id'])
|
||||
.order('game_date', ascending: false),
|
||||
builder: (context, gameSnapshot) {
|
||||
|
||||
if (gameSnapshot.hasError) return Text("Erro: ${gameSnapshot.error}", style: const TextStyle(color: Colors.red));
|
||||
if (gameSnapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
||||
|
||||
@@ -207,9 +219,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (gamesList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: BorderRadius.circular(14)),
|
||||
decoration: BoxDecoration(color: Theme.of(context).cardTheme.color, borderRadius: BorderRadius.circular(14)),
|
||||
alignment: Alignment.center,
|
||||
child: Text("Ainda não há jogos terminados para $_selectedTeamName.", style: TextStyle(color: Colors.grey)),
|
||||
child: const Text("Ainda não há jogos terminados.", style: TextStyle(color: Colors.grey)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -236,7 +248,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (myScore < oppScore) result = 'D';
|
||||
|
||||
return _buildGameHistoryCard(
|
||||
context: context, // Usamos o context para o sf
|
||||
context: context,
|
||||
opponent: opponent,
|
||||
result: result,
|
||||
myScore: myScore,
|
||||
@@ -252,7 +264,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
SizedBox(height: 20 * context.sf),
|
||||
],
|
||||
),
|
||||
@@ -280,14 +291,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget _buildStatCard({required BuildContext context, required String title, required String playerName, required String statValue, required String statLabel, required Color color, bool isHighlighted = false}) {
|
||||
return Card(
|
||||
elevation: 4, margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14), side: isHighlighted ? const BorderSide(color: Colors.amber, width: 2) : BorderSide.none),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14), side: isHighlighted ? const BorderSide(color: AppTheme.warningAmber, width: 2) : BorderSide.none),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [color.withOpacity(0.9), color])),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final double ch = constraints.maxHeight;
|
||||
final double cw = constraints.maxWidth;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(cw * 0.06),
|
||||
child: Column(
|
||||
@@ -327,13 +337,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}) {
|
||||
bool isWin = result == 'V';
|
||||
bool isDraw = result == 'E';
|
||||
Color statusColor = isWin ? Colors.green : (isDraw ? Colors.yellow.shade700 : Colors.red);
|
||||
Color statusColor = isWin ? AppTheme.successGreen : (isDraw ? AppTheme.warningAmber : AppTheme.oppTeamRed);
|
||||
final bgColor = Theme.of(context).cardTheme.color;
|
||||
final textColor = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 14 * context.sf),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.grey.shade200), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 4))],
|
||||
color: bgColor, borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 4))],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -356,16 +368,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: Text(_selectedTeamName == "Selecionar Equipa" ? "Minha Equipa" : _selectedTeamName, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold), maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Expanded(child: Text(_selectedTeamName == "Selecionar Equipa" ? "Minha Equipa" : _selectedTeamName, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold, color: textColor), maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8 * context.sf, vertical: 4 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('$myScore - $oppScore', style: TextStyle(fontSize: 15 * context.sf, fontWeight: FontWeight.w900, letterSpacing: 1.5, color: Colors.black87)),
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withOpacity(0.05), borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('$myScore - $oppScore', style: TextStyle(fontSize: 15 * context.sf, fontWeight: FontWeight.w900, letterSpacing: 1.5, color: textColor)),
|
||||
),
|
||||
),
|
||||
Expanded(child: Text(opponent, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold), textAlign: TextAlign.right, maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
Expanded(child: Text(opponent, style: TextStyle(fontSize: 14 * context.sf, fontWeight: FontWeight.bold, color: textColor), textAlign: TextAlign.right, maxLines: 1, overflow: TextOverflow.ellipsis)),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -374,10 +386,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(height: 1, color: Colors.grey.shade100, thickness: 1.5),
|
||||
Divider(height: 1, color: Colors.grey.withOpacity(0.1), thickness: 1.5),
|
||||
Container(
|
||||
width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 12 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(16), bottomRight: Radius.circular(16))),
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(16), bottomRight: Radius.circular(16))),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
@@ -413,13 +425,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
children: [
|
||||
Icon(icon, size: 14 * context.sf, color: color),
|
||||
SizedBox(width: 4 * context.sf),
|
||||
Text('$label: ', style: TextStyle(fontSize: 11 * context.sf, color: Colors.grey.shade600, fontWeight: FontWeight.bold)),
|
||||
Text('$label: ', style: TextStyle(fontSize: 11 * context.sf, color: Colors.grey, fontWeight: FontWeight.bold)),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 11 * context.sf,
|
||||
color: isMvp ? Colors.amber.shade900 : Colors.black87,
|
||||
color: isMvp ? AppTheme.warningAmber : Theme.of(context).colorScheme.onSurface,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis
|
||||
|
||||
Reference in New Issue
Block a user