
Moves product lookup from external API calls to a local ObjectBox database. This improves performance and enables offline product identification during scanning. Removes the standalone scanner page, consolidating barcode scanning functionality directly into the reception flow for a more streamlined user experience. Updates ObjectBox entity fields by removing `final` modifiers, allowing the database to manage and update persisted data effectively. Introduces new methods in the reception scan model to support local product checks, retrieval, and quantity increment for scanned items.
125 lines
3.5 KiB
Dart
125 lines
3.5 KiB
Dart
import 'package:e_scan/pages/login/login_page_model.dart';
|
|
import 'package:e_scan/provider_container.dart';
|
|
import 'package:e_scan/router/go_router_builder.dart';
|
|
import 'package:e_scan/pages/pages.dart';
|
|
import 'package:e_scan/router/router.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<ProductFormRoute>(path: 'ProductFormPage'),
|
|
TypedGoRoute<ProductListRoute>(path: 'ProductListPage'),
|
|
TypedGoRoute<ProfileRoute>(path: 'ProfilePage'),
|
|
TypedGoRoute<ReceptionRoute>(path: 'ReceptionPage'),
|
|
TypedGoRoute<DeliveryRoute>(path: 'DeliveryPage'),
|
|
TypedGoRoute<InventoryRoute>(path: 'InventoryPage'),
|
|
TypedGoRoute<ReceptionDetailsRoute>(path: 'ReceptionDetailsPage'),
|
|
TypedGoRoute<ReceptionScanRoute>(path: 'ReceptionScanPage'),
|
|
],
|
|
)
|
|
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 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
|
|
CustomTransitionPage<void> buildPage(
|
|
BuildContext context,
|
|
GoRouterState state,
|
|
) => buildPageWithDefaultTransition(
|
|
context: context,
|
|
state: state,
|
|
child: ReceptionPage(),
|
|
);
|
|
}
|
|
|
|
class DeliveryRoute extends GoRouteData with _$DeliveryRoute {
|
|
const DeliveryRoute();
|
|
|
|
@override
|
|
CustomTransitionPage<void> buildPage(
|
|
BuildContext context,
|
|
GoRouterState state,
|
|
) => buildPageWithDefaultTransition(
|
|
context: context,
|
|
state: state,
|
|
child: DeliveryPage(),
|
|
);
|
|
}
|
|
|
|
class InventoryRoute extends GoRouteData with _$InventoryRoute {
|
|
const InventoryRoute();
|
|
|
|
@override
|
|
CustomTransitionPage<void> buildPage(
|
|
BuildContext context,
|
|
GoRouterState state,
|
|
) => buildPageWithDefaultTransition(
|
|
context: context,
|
|
state: state,
|
|
child: InventoryPage(),
|
|
);
|
|
}
|
|
|
|
class ReceptionDetailsRoute extends GoRouteData with _$ReceptionDetailsRoute {
|
|
const ReceptionDetailsRoute({required this.receptionId});
|
|
final int receptionId;
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) =>
|
|
ReceptionDetailsPage(receptionId: receptionId);
|
|
}
|
|
|
|
class ReceptionScanRoute extends GoRouteData with _$ReceptionScanRoute {
|
|
const ReceptionScanRoute({required this.receptionId});
|
|
final int receptionId;
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) =>
|
|
ReceptionScanPage(receptionId: receptionId);
|
|
}
|