refined responsive ui for dashboard and start customer work
This commit is contained in:
130
lib/features/home_and_dashboard/ui/home_screen.dart
Normal file
130
lib/features/home_and_dashboard/ui/home_screen.dart
Normal file
@@ -0,0 +1,130 @@
|
||||
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 'dashboard_content.dart'; // Importiamo il contenuto della dashboard
|
||||
|
||||
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) {
|
||||
// Se lo schermo è più largo di 900px usiamo il layout Desktop
|
||||
final bool isLargeScreen = constraints.maxWidth > 900;
|
||||
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
// --- SIDEBAR (Solo Desktop/Tablet) ---
|
||||
if (isLargeScreen)
|
||||
NavigationRail(
|
||||
selectedIndex: _selectedIndex,
|
||||
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,
|
||||
),
|
||||
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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// --- CONTENUTO DINAMICO ---
|
||||
Expanded(
|
||||
child: _buildPageContent(_selectedIndex, isLargeScreen),
|
||||
),
|
||||
],
|
||||
),
|
||||
// --- BOTTOM BAR (Solo Mobile) ---
|
||||
bottomNavigationBar: isLargeScreen
|
||||
? null
|
||||
: BottomNavigationBar(
|
||||
currentIndex: _selectedIndex,
|
||||
onTap: (index) => setState(() => _selectedIndex = index),
|
||||
selectedItemColor: context.accent,
|
||||
unselectedItemColor: context.secondaryText,
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
// Switch tra le sottopagine
|
||||
Widget _buildPageContent(int index, bool isLargeScreen) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return DashboardContent(isLargeScreen: isLargeScreen);
|
||||
case 1:
|
||||
return const Center(child: Text('Pagina Clienti (Coming Soon)'));
|
||||
case 2:
|
||||
return const Center(child: Text('Pagina Operazioni (Coming Soon)'));
|
||||
default:
|
||||
return DashboardContent(isLargeScreen: isLargeScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user