2026-04-12 21:32:20 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flux/core/theme/theme.dart';
|
2026-04-13 10:00:07 +02:00
|
|
|
import 'package:flux/features/home/ui/dashboard_action_card.dart';
|
2026-04-20 16:52:20 +02:00
|
|
|
import 'package:flux/features/services/utils/service_actions.dart';
|
2026-04-12 21:32:20 +02:00
|
|
|
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,
|
2026-04-20 16:52:20 +02:00
|
|
|
onTap: () => startNewService(context),
|
2026-04-12 21:32:20 +02:00
|
|
|
),
|
|
|
|
|
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: () {},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|