
Removes the dedicated `HomePage` and its associated model files. Configures `ReceptionPage` as the new default landing page after successful login and product form submission. Updates navigation and state management dependencies to direct users to the primary operational interface upon entry.
75 lines
2.2 KiB
Dart
75 lines
2.2 KiB
Dart
import 'package:barcode_scanner/pages/login/login_page_model.dart';
|
|
import 'package:barcode_scanner/provider_container.dart';
|
|
import 'package:barcode_scanner/router/go_router_builder.dart';
|
|
import 'package:barcode_scanner/pages/pages.dart';
|
|
import 'package:flutter/material.dart';
|
|
export 'package:go_router/go_router.dart';
|
|
part 'go_secure_router_builder.g.dart';
|
|
|
|
final appSecureRoutes = $appRoutes;
|
|
|
|
// Groupe des routes sécurisées
|
|
@TypedGoRoute<SecureRoute>(
|
|
path: '/SecurePage',
|
|
routes: [
|
|
TypedGoRoute<ScannerRoute>(path: 'ScannerPage'),
|
|
TypedGoRoute<ProductFormRoute>(path: 'ProductFormPage'),
|
|
TypedGoRoute<ProductListRoute>(path: 'ProductListPage'),
|
|
TypedGoRoute<ProfileRoute>(path: 'ProfilePage'),
|
|
TypedGoRoute<ReceptionRoute>(path: 'ReceptionRoute'),
|
|
],
|
|
)
|
|
class SecureRoute extends GoRouteData with _$SecureRoute {
|
|
const SecureRoute();
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => SizedBox();
|
|
|
|
/// Logique de redirection pour sécuriser les sous-routes
|
|
@override
|
|
String? redirect(BuildContext context, GoRouterState state) {
|
|
final authState = providerContainer
|
|
.read(loginPageModelProvider)
|
|
.status
|
|
.isLogged;
|
|
if (!authState) return SplashRoute().location;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
class ScannerRoute extends GoRouteData with _$ScannerRoute {
|
|
const ScannerRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => ScannerPage();
|
|
}
|
|
|
|
class ProductFormRoute extends GoRouteData with _$ProductFormRoute {
|
|
const ProductFormRoute({required this.id});
|
|
final int id;
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) =>
|
|
ProductFormPage(id: id);
|
|
}
|
|
|
|
class ProductListRoute extends GoRouteData with _$ProductListRoute {
|
|
const ProductListRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => ProductListPage();
|
|
}
|
|
|
|
class ProfileRoute extends GoRouteData with _$ProfileRoute {
|
|
const ProfileRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => ProfilePage();
|
|
}
|
|
|
|
class ReceptionRoute extends GoRouteData with _$ReceptionRoute {
|
|
const ReceptionRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => ReceptionPage();
|
|
}
|