2026-04-09 19:25:32 +02:00
|
|
|
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';
|
2026-04-10 11:11:55 +02:00
|
|
|
import 'package:flux/features/customers/ui/customers_content.dart';
|
2026-04-10 10:47:56 +02:00
|
|
|
import 'dashboard_content.dart'; // Importiamo il contenuto della dashboard
|
2026-04-09 19:25:32 +02:00
|
|
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
|
|
|
const HomeScreen({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
|
int _selectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return BlocBuilder<SessionBloc, SessionState>(
|
|
|
|
|
builder: (context, state) {
|
|
|
|
|
return LayoutBuilder(
|
|
|
|
|
builder: (context, constraints) {
|
2026-04-10 10:47:56 +02:00
|
|
|
// Se lo schermo è più largo di 900px usiamo il layout Desktop
|
2026-04-09 19:25:32 +02:00
|
|
|
final bool isLargeScreen = constraints.maxWidth > 900;
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
body: Row(
|
|
|
|
|
children: [
|
2026-04-10 10:47:56 +02:00
|
|
|
// --- SIDEBAR (Solo Desktop/Tablet) ---
|
2026-04-09 19:25:32 +02:00
|
|
|
if (isLargeScreen)
|
|
|
|
|
NavigationRail(
|
|
|
|
|
selectedIndex: _selectedIndex,
|
2026-04-10 10:47:56 +02:00
|
|
|
onDestinationSelected: (index) =>
|
|
|
|
|
setState(() => _selectedIndex = index),
|
|
|
|
|
extended: constraints.maxWidth > 1200,
|
|
|
|
|
backgroundColor: context.background,
|
|
|
|
|
selectedIconTheme: IconThemeData(color: context.accent),
|
|
|
|
|
selectedLabelTextStyle: TextStyle(
|
|
|
|
|
color: context.accent,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
unselectedLabelTextStyle: TextStyle(
|
|
|
|
|
color: context.secondaryText,
|
|
|
|
|
),
|
2026-04-09 19:25:32 +02:00
|
|
|
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'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
2026-04-10 10:47:56 +02:00
|
|
|
// --- CONTENUTO DINAMICO ---
|
2026-04-09 19:25:32 +02:00
|
|
|
Expanded(
|
2026-04-10 10:47:56 +02:00
|
|
|
child: _buildPageContent(_selectedIndex, isLargeScreen),
|
2026-04-09 19:25:32 +02:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2026-04-10 10:47:56 +02:00
|
|
|
// --- BOTTOM BAR (Solo Mobile) ---
|
2026-04-09 19:25:32 +02:00
|
|
|
bottomNavigationBar: isLargeScreen
|
|
|
|
|
? null
|
|
|
|
|
: BottomNavigationBar(
|
|
|
|
|
currentIndex: _selectedIndex,
|
|
|
|
|
onTap: (index) => setState(() => _selectedIndex = index),
|
2026-04-10 10:47:56 +02:00
|
|
|
selectedItemColor: context.accent,
|
|
|
|
|
unselectedItemColor: context.secondaryText,
|
2026-04-09 19:25:32 +02:00
|
|
|
items: const [
|
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
|
icon: Icon(Icons.dashboard),
|
|
|
|
|
label: 'Home',
|
|
|
|
|
),
|
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
|
icon: Icon(Icons.people),
|
|
|
|
|
label: 'Clienti',
|
|
|
|
|
),
|
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
|
icon: Icon(Icons.receipt_long),
|
|
|
|
|
label: 'Ops',
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildRailHeader(bool isExtended) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 24),
|
|
|
|
|
child: isExtended
|
|
|
|
|
? Text(
|
|
|
|
|
'FLUX',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 24,
|
|
|
|
|
color: context.accent,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Icon(Icons.bolt, color: context.accent, size: 32),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 10:47:56 +02:00
|
|
|
// Switch tra le sottopagine
|
|
|
|
|
Widget _buildPageContent(int index, bool isLargeScreen) {
|
|
|
|
|
switch (index) {
|
2026-04-09 19:25:32 +02:00
|
|
|
case 0:
|
|
|
|
|
return DashboardContent(isLargeScreen: isLargeScreen);
|
|
|
|
|
case 1:
|
2026-04-10 11:11:55 +02:00
|
|
|
return const CustomersContent();
|
2026-04-10 10:47:56 +02:00
|
|
|
case 2:
|
|
|
|
|
return const Center(child: Text('Pagina Operazioni (Coming Soon)'));
|
2026-04-09 19:25:32 +02:00
|
|
|
default:
|
2026-04-10 10:47:56 +02:00
|
|
|
return DashboardContent(isLargeScreen: isLargeScreen);
|
2026-04-09 19:25:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|