mamma mia sistemata rail e bottom navigation, bellissime ora
This commit is contained in:
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_bloc.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/features/customers/ui/customers_content.dart';
|
||||
import 'package:flux/features/anagrafiche/master_data_hub_content.dart';
|
||||
import 'dashboard_content.dart'; // Importiamo il contenuto della dashboard
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@@ -14,6 +14,7 @@ class HomeScreen extends StatefulWidget {
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
int _selectedIndex = 0;
|
||||
bool _isRailHovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,53 +28,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
// --- SIDEBAR (Solo Desktop/Tablet) ---
|
||||
// --- SIDEBAR (Desktop) ---
|
||||
if (isLargeScreen)
|
||||
NavigationRail(
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (index) =>
|
||||
setState(() => _selectedIndex = index),
|
||||
extended: constraints.maxWidth > 1200,
|
||||
backgroundColor: context.background,
|
||||
// 1. Definiamo il colore dell'ellisse (l'indicatore)
|
||||
indicatorColor: context.accent.withValues(alpha: 0.2),
|
||||
|
||||
selectedIconTheme: IconThemeData(
|
||||
color: context
|
||||
.accent, // O un colore che stacchi bene dall'ellisse
|
||||
size: 28,
|
||||
),
|
||||
selectedLabelTextStyle: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
// 3. Forza il colore delle ICONE quando NON selezionate
|
||||
unselectedIconTheme: IconThemeData(
|
||||
color: context.secondaryText,
|
||||
size: 24,
|
||||
),
|
||||
unselectedLabelTextStyle: TextStyle(
|
||||
color: context.secondaryText,
|
||||
),
|
||||
leading: _buildRailHeader(constraints.maxWidth > 1200),
|
||||
destinations: const [
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.dashboard_outlined),
|
||||
selectedIcon: Icon(Icons.dashboard),
|
||||
label: Text('Dashboard'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.people_outlined),
|
||||
selectedIcon: Icon(Icons.people),
|
||||
label: Text('Clienti'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.receipt_long_outlined),
|
||||
selectedIcon: Icon(Icons.receipt_long),
|
||||
label: Text('Operazioni'),
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildNavigationRail(constraints.maxWidth > 1200),
|
||||
|
||||
// --- CONTENUTO DINAMICO ---
|
||||
Expanded(
|
||||
@@ -92,15 +49,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.dashboard),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.people),
|
||||
label: 'Clienti',
|
||||
label: 'Dashboard',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.receipt_long),
|
||||
label: 'Ops',
|
||||
label: 'Operazioni',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.folder_shared),
|
||||
label: 'Anagrafiche',
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -111,6 +68,58 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// --- NAVIGATION RAIL (Desktop) ---
|
||||
Widget _buildNavigationRail(bool railAlwaysExtended) {
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _isRailHovered = true),
|
||||
onExit: (_) => setState(() => _isRailHovered = false),
|
||||
child: NavigationRail(
|
||||
// Manteniamo 'extended' dinamico in base alla larghezza per un look Pro
|
||||
extended: railAlwaysExtended ? true : _isRailHovered,
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (index) =>
|
||||
setState(() => _selectedIndex = index),
|
||||
backgroundColor: context.background,
|
||||
indicatorColor: context.accent.withValues(alpha: 0.2),
|
||||
|
||||
// Header con il logo FLUX o l'icona bolt
|
||||
leading: _buildRailHeader(railAlwaysExtended ? true : _isRailHovered),
|
||||
|
||||
selectedIconTheme: IconThemeData(color: context.accent, size: 28),
|
||||
unselectedIconTheme: IconThemeData(
|
||||
color: context.secondaryText,
|
||||
size: 24,
|
||||
),
|
||||
|
||||
selectedLabelTextStyle: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
unselectedLabelTextStyle: TextStyle(color: context.secondaryText),
|
||||
|
||||
destinations: const [
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.dashboard_outlined),
|
||||
selectedIcon: Icon(Icons.dashboard),
|
||||
label: Text('Dashboard'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.receipt_long_outlined),
|
||||
selectedIcon: Icon(Icons.receipt_long),
|
||||
label: Text('Operazioni'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.folder_shared_outlined),
|
||||
selectedIcon: Icon(Icons.folder_shared),
|
||||
label: Text(
|
||||
'Anagrafiche',
|
||||
), // Questo caricherà il MasterDataHubContent
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRailHeader(bool isExtended) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
@@ -133,17 +142,22 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
case 0:
|
||||
return DashboardContent(
|
||||
isLargeScreen: isLargeScreen,
|
||||
// Questo pezzo DEVE puntare al setState dello State della HomeScreen
|
||||
onTabRequested: (targetIndex) {
|
||||
setState(() {
|
||||
_selectedIndex = targetIndex;
|
||||
});
|
||||
},
|
||||
// Se dalla Dashboard clicchi "Clienti", ti porto all'Hub
|
||||
onTabRequested: (idx) => setState(() => _selectedIndex = 2),
|
||||
);
|
||||
case 1:
|
||||
return const CustomersContent();
|
||||
return const Center(child: Text('Operazioni'));
|
||||
case 2:
|
||||
return const Center(child: Text('Pagina Operazioni (Coming Soon)'));
|
||||
// L'unico punto di ingresso per tutte le anagrafiche
|
||||
return MasterDataHubContent(
|
||||
// Qui gestiamo la navigazione "interna" all'hub
|
||||
onOpenPage: (widget) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => widget),
|
||||
);
|
||||
},
|
||||
);
|
||||
default:
|
||||
return DashboardContent(isLargeScreen: isLargeScreen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user