feat: implement child route management for client and staff modules; enhance routing structure for better navigation
This commit is contained in:
@@ -10,6 +10,14 @@
|
||||
class ClientPaths {
|
||||
ClientPaths._();
|
||||
|
||||
// ==========================================================================
|
||||
// CHILD ROUTE MANAGEMENT
|
||||
// ==========================================================================
|
||||
/// Generate child route based on the given route and parent route
|
||||
///
|
||||
/// This is useful for creating nested routes within modules.
|
||||
static String childRoute(String parent, String child) => child.replaceFirst(parent, '');
|
||||
|
||||
// ==========================================================================
|
||||
// AUTHENTICATION
|
||||
// ==========================================================================
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
class StaffPaths {
|
||||
StaffPaths._();
|
||||
|
||||
// ==========================================================================
|
||||
// CHILD ROUTE MANAGEMENT
|
||||
// ==========================================================================
|
||||
/// Generate child route based on the given route and parent route
|
||||
///
|
||||
/// This is useful for creating nested routes within modules.
|
||||
static String childRoute(String parent, String child) => child.replaceFirst(parent, '');
|
||||
|
||||
// ==========================================================================
|
||||
// AUTHENTICATION
|
||||
// ==========================================================================
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
|
||||
import 'data/repositories_impl/billing_repository_impl.dart';
|
||||
@@ -47,6 +48,6 @@ class BillingModule extends Module {
|
||||
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const BillingPage());
|
||||
r.child(ClientPaths.childRoute(ClientPaths.billing, ClientPaths.billing), child: (_) => const BillingPage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'data/repositories_impl/coverage_repository_impl.dart';
|
||||
import 'domain/repositories/coverage_repository.dart';
|
||||
@@ -31,6 +32,7 @@ class CoverageModule extends Module {
|
||||
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const CoveragePage());
|
||||
r.child(ClientPaths.childRoute(ClientPaths.coverage, ClientPaths.coverage),
|
||||
child: (_) => const CoveragePage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:client_home/client_home.dart';
|
||||
import 'package:client_coverage/client_coverage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:view_orders/view_orders.dart';
|
||||
|
||||
import 'presentation/blocs/client_main_cubit.dart';
|
||||
@@ -21,12 +22,24 @@ class ClientMainModule extends Module {
|
||||
'/',
|
||||
child: (BuildContext context) => const ClientMainPage(),
|
||||
children: <ParallelRoute<dynamic>>[
|
||||
ModuleRoute<dynamic>('/home', module: ClientHomeModule()),
|
||||
ModuleRoute<dynamic>('/coverage', module: CoverageModule()),
|
||||
ModuleRoute<dynamic>('/billing', module: BillingModule()),
|
||||
ModuleRoute<dynamic>('/orders', module: ViewOrdersModule()),
|
||||
ModuleRoute<dynamic>(
|
||||
ClientPaths.childRoute(ClientPaths.main, ClientPaths.home),
|
||||
module: ClientHomeModule(),
|
||||
),
|
||||
ModuleRoute<dynamic>(
|
||||
ClientPaths.childRoute(ClientPaths.main, ClientPaths.coverage),
|
||||
module: CoverageModule(),
|
||||
),
|
||||
ModuleRoute<dynamic>(
|
||||
ClientPaths.childRoute(ClientPaths.main, ClientPaths.billing),
|
||||
module: BillingModule(),
|
||||
),
|
||||
ModuleRoute<dynamic>(
|
||||
ClientPaths.childRoute(ClientPaths.main, ClientPaths.orders),
|
||||
module: ViewOrdersModule(),
|
||||
),
|
||||
ChildRoute<dynamic>(
|
||||
'/reports',
|
||||
ClientPaths.childRoute(ClientPaths.main, ClientPaths.reports),
|
||||
child: (BuildContext context) =>
|
||||
const PlaceholderPage(title: 'Reports'),
|
||||
),
|
||||
|
||||
@@ -21,7 +21,7 @@ class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
newIndex = 1;
|
||||
} else if (path.contains(ClientPaths.home)) {
|
||||
newIndex = 2;
|
||||
} else if (path.contains(ClientPaths.viewOrders)) {
|
||||
} else if (path.contains(ClientPaths.orders)) {
|
||||
newIndex = 3;
|
||||
} else if (path.contains(ClientPaths.reports)) {
|
||||
newIndex = 4;
|
||||
@@ -46,7 +46,7 @@ class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
Modular.to.navigate(ClientPaths.home);
|
||||
break;
|
||||
case 3:
|
||||
Modular.to.navigate(ClientPaths.viewOrders);
|
||||
Modular.to.navigate(ClientPaths.orders);
|
||||
break;
|
||||
case 4:
|
||||
Modular.to.navigate(ClientPaths.reports);
|
||||
|
||||
@@ -59,19 +59,19 @@ class ClientCreateOrderModule extends Module {
|
||||
child: (BuildContext context) => const ClientCreateOrderPage(),
|
||||
);
|
||||
r.child(
|
||||
ClientPaths.createOrderRapid.replaceFirst(ClientPaths.createOrder, ''),
|
||||
ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderRapid),
|
||||
child: (BuildContext context) => const RapidOrderPage(),
|
||||
);
|
||||
r.child(
|
||||
ClientPaths.createOrderOneTime.replaceFirst(ClientPaths.createOrder, ''),
|
||||
ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderOneTime),
|
||||
child: (BuildContext context) => const OneTimeOrderPage(),
|
||||
);
|
||||
r.child(
|
||||
ClientPaths.createOrderRecurring.replaceFirst(ClientPaths.createOrder, ''),
|
||||
ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderRecurring),
|
||||
child: (BuildContext context) => const RecurringOrderPage(),
|
||||
);
|
||||
r.child(
|
||||
ClientPaths.createOrderPermanent.replaceFirst(ClientPaths.createOrder, ''),
|
||||
ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderPermanent),
|
||||
child: (BuildContext context) => const PermanentOrderPage(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
|
||||
import 'src/data/repositories_impl/home_repository_impl.dart';
|
||||
import 'src/domain/repositories/home_repository_interface.dart';
|
||||
import 'src/domain/usecases/get_dashboard_data_usecase.dart';
|
||||
@@ -45,6 +47,6 @@ class ClientHomeModule extends Module {
|
||||
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const ClientHomePage());
|
||||
r.child(ClientPaths.childRoute(ClientPaths.home, ClientPaths.home), child: (_) => const ClientHomePage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
library client_hubs;
|
||||
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart' as firebase;
|
||||
import 'src/data/repositories_impl/hub_repository_impl.dart';
|
||||
@@ -48,6 +49,6 @@ class ClientHubsModule extends Module {
|
||||
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const ClientHubsPage());
|
||||
r.child(ClientPaths.childRoute(ClientPaths.hubs, ClientPaths.hubs), child: (_) => const ClientHubsPage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'src/data/repositories_impl/settings_repository_impl.dart';
|
||||
import 'src/domain/repositories/settings_repository_interface.dart';
|
||||
import 'src/domain/usecases/sign_out_usecase.dart';
|
||||
@@ -26,6 +27,9 @@ class ClientSettingsModule extends Module {
|
||||
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const ClientSettingsPage());
|
||||
r.child(
|
||||
ClientPaths.childRoute(ClientPaths.settings, ClientPaths.settings),
|
||||
child: (_) => const ClientSettingsPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user