| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import 'package:flutter/material.dart';
- import '../../database/database.dart';
- class AppDrawer extends StatelessWidget {
- final Agente? agente;
- final VoidCallback? onDashboard;
- final VoidCallback? onOrders;
- final VoidCallback? onCustomers;
- final VoidCallback? onCatalog;
- final VoidCallback? onPromotions;
- final VoidCallback? onPayments;
- final VoidCallback? onStatistics;
- final VoidCallback? onSync;
- final VoidCallback? onLogout;
- const AppDrawer({
- super.key,
- this.agente,
- this.onDashboard,
- this.onOrders,
- this.onCustomers,
- this.onCatalog,
- this.onPromotions,
- this.onPayments,
- this.onStatistics,
- this.onSync,
- this.onLogout,
- });
- @override
- Widget build(BuildContext context) {
- final theme = Theme.of(context);
- return Drawer(
- child: ListView(
- padding: EdgeInsets.zero,
- children: [
- DrawerHeader(
- decoration: BoxDecoration(color: theme.colorScheme.primaryContainer),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- CircleAvatar(
- radius: 28,
- backgroundColor: theme.colorScheme.primary,
- child: Text(
- agente?.ragioneSociale?.substring(0, 1).toUpperCase() ?? 'A',
- style: TextStyle(
- fontSize: 24,
- color: theme.colorScheme.onPrimary,
- ),
- ),
- ),
- const SizedBox(height: 8),
- Text(
- agente?.ragioneSociale ?? 'Agente',
- style: theme.textTheme.titleMedium?.copyWith(
- color: theme.colorScheme.onPrimaryContainer,
- ),
- ),
- Text(
- 'Cod. ${agente?.codAgente ?? ''}',
- style: theme.textTheme.bodySmall?.copyWith(
- color: theme.colorScheme.onPrimaryContainer.withAlpha(180),
- ),
- ),
- ],
- ),
- ),
- _item(Icons.dashboard_outlined, 'Dashboard', onDashboard),
- _item(Icons.receipt_long_outlined, 'Ordini', onOrders),
- _item(Icons.people_outline, 'Clienti', onCustomers),
- _item(Icons.inventory_2_outlined, 'Catalogo', onCatalog),
- _item(Icons.local_offer_outlined, 'Promozioni', onPromotions),
- _item(Icons.account_balance_wallet_outlined, 'Scadenze', onPayments),
- _item(Icons.bar_chart_outlined, 'Statistiche', onStatistics),
- _item(Icons.sync_outlined, 'Sincronizzazione', onSync),
- const Divider(),
- _item(Icons.logout, 'Logout', onLogout),
- ],
- ),
- );
- }
- Widget _item(IconData icon, String label, VoidCallback? onTap) {
- return ListTile(
- leading: Icon(icon),
- title: Text(label),
- onTap: onTap,
- );
- }
- }
|