melhorar o navigation e o separar controlls e widgetes e pages
parent
e16191fa9d
commit
dc3a7840bb
|
|
@ -1,15 +0,0 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
class HomeController {
|
|
||||||
Future<void> loadHomeData() async {
|
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
|
||||||
}
|
|
||||||
|
|
||||||
void refreshData() {
|
|
||||||
loadHomeData();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> getFilterOptions() {
|
|
||||||
return ['Últimos 7 dias', 'Últimos 30 dias', 'Temporada completa'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,173 +1,215 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'widgets/player_stat_card.dart';
|
|
||||||
import 'widgets/wins_losses_chart.dart';
|
|
||||||
import 'widgets/recent_game_card.dart';
|
|
||||||
import 'widgets/game_highlights.dart';
|
|
||||||
import 'widgets/bottom_nav_bar.dart';
|
|
||||||
import '../controllers/home_controller.dart';
|
|
||||||
|
|
||||||
class Home extends StatefulWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
const Home({super.key});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<Home> createState() => _HomeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
|
||||||
final HomeController _controller = HomeController();
|
|
||||||
int _currentIndex = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_controller.loadHomeData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text(
|
title: const Text('PlayMaker'),
|
||||||
'Home',
|
backgroundColor: Colors.orange,
|
||||||
style: TextStyle(
|
foregroundColor: Colors.white,
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
),
|
||||||
),
|
body: SingleChildScrollView(
|
||||||
backgroundColor: Colors.white,
|
child: Padding(
|
||||||
elevation: 0,
|
padding: const EdgeInsets.all(40.0),
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// Team Header
|
// Título
|
||||||
Padding(
|
const Text(
|
||||||
padding: const EdgeInsets.only(top: 8.0, bottom: 16.0),
|
'PLAYMAKER',
|
||||||
child: Text(
|
|
||||||
'TEAM A',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 32,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.grey[700],
|
color: Colors.orange,
|
||||||
|
letterSpacing: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
|
||||||
|
// Botão PRINCIPAL para iniciar jogo
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 250,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
// Navegar para tela de novo jogo
|
||||||
|
print('Iniciar novo jogo!');
|
||||||
|
// Navigator.push(context, MaterialPageRoute(
|
||||||
|
// builder: (context) => NovoJogoScreen()
|
||||||
|
// ));
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.orange,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(25),
|
||||||
|
),
|
||||||
|
elevation: 10,
|
||||||
|
shadowColor: Colors.orange.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
child: const Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.sports_basketball,
|
||||||
|
size: 80,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'NOVO JOGO',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 38,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: Colors.white,
|
||||||
|
letterSpacing: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Best Players Section
|
const SizedBox(height: 40),
|
||||||
|
|
||||||
|
// Texto explicativo
|
||||||
const Text(
|
const Text(
|
||||||
'Melhores Jogadores',
|
'Toque para iniciar uma nova partida',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
color: Colors.grey,
|
||||||
color: Colors.black,
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
|
||||||
|
|
||||||
// Player Stats Cards
|
const SizedBox(height: 50),
|
||||||
Row(
|
|
||||||
children: [
|
// Seção de opções rápidas
|
||||||
Expanded(
|
const Text(
|
||||||
child: PlayerStatCard(
|
'Acesso Rápido',
|
||||||
title: 'Mais Pontos',
|
style: TextStyle(
|
||||||
playerName: 'Michael Jordan',
|
fontSize: 22,
|
||||||
statValue: '34.5',
|
fontWeight: FontWeight.bold,
|
||||||
statType: 'PPG',
|
|
||||||
icon: Icons.sports_basketball,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
|
||||||
child: PlayerStatCard(
|
|
||||||
title: 'Mais Assistências',
|
|
||||||
playerName: 'Magic Johnson',
|
|
||||||
statValue: '12.8',
|
|
||||||
statType: 'APG',
|
|
||||||
icon: Icons.share,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
|
||||||
child: PlayerStatCard(
|
|
||||||
title: 'Mais Rebotes',
|
|
||||||
playerName: 'Dennis Rodman',
|
|
||||||
statValue: '15.3',
|
|
||||||
statType: 'RPG',
|
|
||||||
icon: Icons.vertical_align_center,
|
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Wins vs Losses
|
|
||||||
WinsLossesChart(
|
|
||||||
wins: 12,
|
|
||||||
losses: 5,
|
|
||||||
totalGames: 17,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Recent History
|
|
||||||
const Text(
|
|
||||||
'Histórico Recente',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
|
|
||||||
RecentGameCard(
|
|
||||||
teamA: 'TEAM A',
|
|
||||||
teamB: 'TEAM B',
|
|
||||||
scoreA: 91,
|
|
||||||
scoreB: 88,
|
|
||||||
quarter: '2º',
|
|
||||||
timeLeft: '10:00',
|
|
||||||
date: '13/06/25',
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Game Highlights
|
|
||||||
const Text(
|
|
||||||
'Destaques do Jogo',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
|
|
||||||
GameHighlights(
|
|
||||||
players: [
|
|
||||||
PlayerHighlight(name: 'Fred', stat: '13,0 rebotes'),
|
|
||||||
PlayerHighlight(name: 'Afonso', stat: '20,0 pontos'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Grid de opções
|
||||||
|
GridView.count(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
crossAxisCount: 2,
|
||||||
|
childAspectRatio: 1.3,
|
||||||
|
mainAxisSpacing: 20,
|
||||||
|
crossAxisSpacing: 20,
|
||||||
|
children: [
|
||||||
|
// Estatísticas
|
||||||
|
_buildQuickOption(
|
||||||
|
icon: Icons.insights,
|
||||||
|
title: 'Estatísticas',
|
||||||
|
subtitle: 'Ver desempenho',
|
||||||
|
color: Colors.green,
|
||||||
|
onTap: () {
|
||||||
|
print('Ver estatísticas');
|
||||||
|
// Pode navegar para estatísticas ou mudar para índice 3 no navigation
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Equipas
|
||||||
|
_buildQuickOption(
|
||||||
|
icon: Icons.people,
|
||||||
|
title: 'Minhas Equipas',
|
||||||
|
subtitle: 'Gerir equipas',
|
||||||
|
color: Colors.blue,
|
||||||
|
onTap: () {
|
||||||
|
print('Ver equipas');
|
||||||
|
// Pode navegar para equipas ou mudar para índice 2 no navigation
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Histórico
|
||||||
|
_buildQuickOption(
|
||||||
|
icon: Icons.history,
|
||||||
|
title: 'Histórico',
|
||||||
|
subtitle: 'Jogos anteriores',
|
||||||
|
color: Colors.purple,
|
||||||
|
onTap: () {
|
||||||
|
print('Ver histórico');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Configurações
|
||||||
|
_buildQuickOption(
|
||||||
|
icon: Icons.settings,
|
||||||
|
title: 'Configurações',
|
||||||
|
subtitle: 'Ajustar app',
|
||||||
|
color: Colors.grey,
|
||||||
|
onTap: () {
|
||||||
|
print('Abrir configurações');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomNavBar(
|
);
|
||||||
currentIndex: _currentIndex,
|
}
|
||||||
onTap: (index) {
|
|
||||||
setState(() {
|
// Widget para construir opções rápidas
|
||||||
_currentIndex = index;
|
Widget _buildQuickOption({
|
||||||
});
|
required IconData icon,
|
||||||
},
|
required String title,
|
||||||
|
required String subtitle,
|
||||||
|
required Color color,
|
||||||
|
required VoidCallback onTap,
|
||||||
|
}) {
|
||||||
|
return Card(
|
||||||
|
elevation: 5,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
icon,
|
||||||
|
size: 40,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Text(
|
||||||
|
subtitle,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:playmaker/controllers/home_controller.dart';
|
||||||
|
import 'package:playmaker/pages/home.dart';
|
||||||
import '../widgets/login_widgets.dart';
|
import '../widgets/login_widgets.dart';
|
||||||
import '../../Controllers/login_controller.dart';
|
import '../../Controllers/login_controller.dart';
|
||||||
|
|
||||||
|
|
@ -51,10 +53,11 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
LoginButton(
|
LoginButton(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onLoginSuccess: () {
|
onLoginSuccess: () {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
Navigator.pushReplacement(
|
||||||
const SnackBar(
|
context,
|
||||||
content: Text('Login bem-sucedido!'),
|
MaterialPageRoute(
|
||||||
backgroundColor: Colors.green,
|
builder: (context) => const HomeScreen(),
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// TODO Implement this library.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// TODO Implement this library.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// TODO Implement this library.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// TODO Implement this library.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// TODO Implement this library.
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CustomNavBar extends StatelessWidget {
|
||||||
|
final int selectedIndex;
|
||||||
|
final Function(int) onItemSelected;
|
||||||
|
|
||||||
|
const CustomNavBar({
|
||||||
|
super.key,
|
||||||
|
required this.selectedIndex,
|
||||||
|
required this.onItemSelected,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// Usar NavigationBar (Material 3) ao invés de BottomNavigationBar
|
||||||
|
return NavigationBar(
|
||||||
|
selectedIndex: selectedIndex,
|
||||||
|
onDestinationSelected: onItemSelected,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
|
||||||
|
elevation: 1,
|
||||||
|
height: 70,
|
||||||
|
destinations: const [
|
||||||
|
NavigationDestination(
|
||||||
|
icon: Icon(Icons.home_outlined),
|
||||||
|
selectedIcon: Icon(Icons.home_filled),
|
||||||
|
label: 'Home',
|
||||||
|
),
|
||||||
|
NavigationDestination(
|
||||||
|
icon: Icon(Icons.sports_soccer_outlined),
|
||||||
|
selectedIcon: Icon(Icons.sports_soccer),
|
||||||
|
label: 'Jogo',
|
||||||
|
),
|
||||||
|
NavigationDestination(
|
||||||
|
icon: Icon(Icons.people_outline),
|
||||||
|
selectedIcon: Icon(Icons.people),
|
||||||
|
label: 'Equipas',
|
||||||
|
),
|
||||||
|
NavigationDestination(
|
||||||
|
icon: Icon(Icons.insights_outlined),
|
||||||
|
selectedIcon: Icon(Icons.insights),
|
||||||
|
label: 'Status',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue