change routes with names
This commit is contained in:
@@ -42,10 +42,26 @@ import 'package:flux/features/tickets/ui/ticket_list_screen.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
// Nota: Dovrai creare questi placeholder o file per non avere errori di compilazione
|
||||
// import 'package:flux/features/master_data/master_data_hub_screen.dart';
|
||||
// import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
||||
// import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
||||
const String loginRoute = 'login';
|
||||
const String setPasswordRoute = 'set-password';
|
||||
const String onboardingRoute = 'onboarding';
|
||||
const String homeRoute = 'home';
|
||||
const String masterDataRoute = 'master-data';
|
||||
const String productsRoute = 'products';
|
||||
const String companySettingsRoute = 'company-settings';
|
||||
const String staffRoute = 'staff';
|
||||
const String storesRoute = 'stores';
|
||||
const String providersRoute = 'providers';
|
||||
const String settingsRoute = 'settings';
|
||||
const String themeRoute = 'theme';
|
||||
const String operationsRoute = 'operations';
|
||||
const String customersRoute = 'customers';
|
||||
const String ticketsRoute = 'tickets';
|
||||
const String ticketFormRoute = 'ticket-form';
|
||||
const String operationFormRoute = 'operation-form';
|
||||
const String uploadSuccessRoute = 'upload-success';
|
||||
const String customerFormRoute = 'customer-form';
|
||||
const String uploadRoute = 'upload';
|
||||
|
||||
class AppRouter {
|
||||
static GoRouter createRouter(SessionCubit sessionCubit) {
|
||||
@@ -97,14 +113,17 @@ class AppRouter {
|
||||
// --- ROTTE DI SERVIZIO (FUORI DALLA SHELL) ---
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
builder: (context, state) => const AuthScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/set-password',
|
||||
name: 'set-password',
|
||||
builder: (context, state) => const SetPasswordScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/onboarding',
|
||||
name: 'onboarding',
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => OnboardingCubit(
|
||||
GetIt.I.get<SessionCubit>(),
|
||||
@@ -119,15 +138,21 @@ class AppRouter {
|
||||
builder: (context, state, child) => AppShell(child: child),
|
||||
routes: [
|
||||
// 1. DASHBOARD
|
||||
GoRoute(path: '/', builder: (context, state) => const HomeScreen()),
|
||||
GoRoute(
|
||||
path: '/',
|
||||
name: homeRoute,
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
),
|
||||
|
||||
// 2. HUB ANAGRAFICHE E SOTTO-ROTTE
|
||||
GoRoute(
|
||||
path: '/master-data',
|
||||
name: masterDataRoute,
|
||||
builder: (context, state) => const MasterDataHubScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'products', // Diventa /master-data/products
|
||||
name: 'products',
|
||||
builder: (context, state) {
|
||||
context.read<ProductsCubit>().refreshCubit();
|
||||
|
||||
@@ -136,21 +161,25 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: 'company-settings',
|
||||
name: companySettingsRoute,
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => CompanySettingsCubit(),
|
||||
child: const CompanySettingsScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'staff', // Diventa /master-data/staff
|
||||
path: 'staff',
|
||||
name: staffRoute, // Diventa /master-data/staff
|
||||
builder: (context, state) => const StaffScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'stores', // Diventa /master-data/stores
|
||||
path: storesRoute,
|
||||
name: 'stores', // Diventa /master-data/stores
|
||||
builder: (context, state) => const StoresScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'providers', // Diventa /master-data/providers
|
||||
path: 'providers',
|
||||
name: providersRoute, // Diventa /master-data/providers
|
||||
builder: (context, state) =>
|
||||
const ProvidersMasterDataScreen(),
|
||||
),
|
||||
@@ -160,16 +189,19 @@ class AppRouter {
|
||||
// 3. IMPOSTAZIONI
|
||||
GoRoute(
|
||||
path: '/settings',
|
||||
name: settingsRoute,
|
||||
builder: (context, state) => const SettingsView(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'theme',
|
||||
name: themeRoute,
|
||||
builder: (context, state) => const ThemeSettingsView(),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/operations',
|
||||
name: operationsRoute,
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => OperationListCubit(),
|
||||
child: const OperationListScreen(),
|
||||
@@ -177,11 +209,13 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: '/customers',
|
||||
name: customersRoute,
|
||||
builder: (context, state) =>
|
||||
const CustomersContent(), // O come si chiama il tuo widget della lista!
|
||||
),
|
||||
GoRoute(
|
||||
path: '/tickets',
|
||||
name: ticketsRoute,
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => TicketListCubit(),
|
||||
child: const TicketListScreen(),
|
||||
@@ -194,6 +228,7 @@ class AppRouter {
|
||||
GoRoute(
|
||||
// Il path sarà es. /tickets/form/123 oppure /tickets/form/new
|
||||
path: '/tickets/form/:id',
|
||||
name: ticketFormRoute,
|
||||
builder: (context, state) {
|
||||
// 1. Leggiamo l'ID dall'URL
|
||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||
@@ -230,10 +265,12 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: '/upload-success',
|
||||
name: uploadSuccessRoute,
|
||||
builder: (context, state) => const UploadSuccessScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/customer/:id',
|
||||
path: '/customer/form/:id',
|
||||
name: 'customer-form',
|
||||
builder: (context, state) {
|
||||
final customer = state.extra as CustomerModel;
|
||||
return BlocProvider(
|
||||
@@ -248,6 +285,7 @@ class AppRouter {
|
||||
|
||||
GoRoute(
|
||||
path: '/operations/form/:id',
|
||||
name: operationFormRoute,
|
||||
builder: (context, state) {
|
||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||
final OperationModel? operationFromExtra =
|
||||
@@ -286,6 +324,7 @@ class AppRouter {
|
||||
|
||||
GoRoute(
|
||||
path: '/upload/:type/:id',
|
||||
name: uploadRoute,
|
||||
builder: (context, state) {
|
||||
final typeString = state.pathParameters['type']!;
|
||||
final id = state.pathParameters['id']!;
|
||||
|
||||
Reference in New Issue
Block a user