refined responsive ui for dashboard and start customer work
This commit is contained in:
@@ -1,128 +0,0 @@
|
||||
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/home/ui/dashboard_content.dart';
|
||||
|
||||
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) {
|
||||
// Definiamo se siamo su uno schermo "Large" (es. sopra i 900px)
|
||||
final bool isLargeScreen = constraints.maxWidth > 900;
|
||||
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
// --- SIDEBAR (Solo per schermi grandi) ---
|
||||
if (isLargeScreen)
|
||||
NavigationRail(
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (int index) {
|
||||
setState(() => _selectedIndex = index);
|
||||
},
|
||||
extended:
|
||||
constraints.maxWidth >
|
||||
1200, // Si allarga se c'è molto spazio
|
||||
labelType: constraints.maxWidth > 1200
|
||||
? NavigationRailLabelType.none
|
||||
: NavigationRailLabelType.all,
|
||||
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 PRINCIPALE ---
|
||||
Expanded(
|
||||
child: _buildMainContent(context, state, isLargeScreen),
|
||||
),
|
||||
],
|
||||
),
|
||||
// --- BOTTOM NAVIGATION (Solo per Mobile) ---
|
||||
bottomNavigationBar: isLargeScreen
|
||||
? null
|
||||
: BottomNavigationBar(
|
||||
currentIndex: _selectedIndex,
|
||||
onTap: (index) => setState(() => _selectedIndex = index),
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.dashboard),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.people),
|
||||
label: 'Clienti',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.receipt_long),
|
||||
label: 'Ops',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Header per la Sidebar (Logo o Icona)
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent(
|
||||
BuildContext context,
|
||||
SessionState state,
|
||||
bool isLargeScreen,
|
||||
) {
|
||||
// Qui gestiamo lo switch tra le pagine
|
||||
switch (_selectedIndex) {
|
||||
case 0:
|
||||
return DashboardContent(isLargeScreen: isLargeScreen);
|
||||
case 1:
|
||||
return const Center(child: Text('Pagina Clienti')); // La faremo!
|
||||
default:
|
||||
return const DashboardContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user