ref
This commit is contained in:
74
lib/features/home/ui/dashboard_adaptive_grid.dart
Normal file
74
lib/features/home/ui/dashboard_adaptive_grid.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/features/home/ui/dashboard_action_card.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class DashboardAdaptiveGrid extends StatelessWidget {
|
||||
final bool isLargeScreen;
|
||||
final Function(int)? onTabRequested;
|
||||
const DashboardAdaptiveGrid({
|
||||
super.key,
|
||||
this.isLargeScreen = false,
|
||||
this.onTabRequested,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// Logica Colonne: Mobile 2, Tablet 3, Desktop 4+
|
||||
int crossAxisCount = 2;
|
||||
if (constraints.maxWidth > 1000) {
|
||||
crossAxisCount = 5;
|
||||
} else if (constraints.maxWidth > 700) {
|
||||
crossAxisCount = 3;
|
||||
}
|
||||
|
||||
return GridView.count(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisCount: crossAxisCount,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: isLargeScreen ? 1.3 : 1.5,
|
||||
children: [
|
||||
DashboardActionCard(
|
||||
label: 'Nuova Op',
|
||||
icon: Icons.add_task,
|
||||
color: context.accent,
|
||||
onTap: () {},
|
||||
),
|
||||
DashboardActionCard(
|
||||
label: 'Clienti',
|
||||
icon: Icons.people,
|
||||
color: Colors.orange,
|
||||
onTap: () => onTabRequested?.call(1),
|
||||
),
|
||||
DashboardActionCard(
|
||||
label: 'Prodotti',
|
||||
icon: Icons
|
||||
.phone_android_outlined, // Icona "comoda" e professionale
|
||||
color: context
|
||||
.accent, // O un colore a tua scelta, magari Indigo o Blue
|
||||
onTap: () => context.push(
|
||||
'/products',
|
||||
), // Apre la schermata sopra la Dashboard
|
||||
),
|
||||
DashboardActionCard(
|
||||
label: 'Campagne',
|
||||
icon: Icons.campaign,
|
||||
color: Colors.purple,
|
||||
onTap: () {},
|
||||
),
|
||||
DashboardActionCard(
|
||||
label: 'Report',
|
||||
icon: Icons.analytics,
|
||||
color: Colors.teal,
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user