
Refactors the login page and model for improved separation of concerns. Moves navigation logic from the model to the page using success callbacks. Integrates a dedicated primary button component for the login action, showing loading state. Adds a new secure route for a product form page and updates the scanner page to navigate to it when viewing scanned product details. Simplifies the callback signature for viewing product details in the scanned product component. Also includes minor adjustments to the splash screen delay and theme definition.
52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
import 'dart:async';
|
|
import 'package:barcode_scanner/pages/pages.dart';
|
|
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
export 'package:go_router/go_router.dart';
|
|
|
|
part 'go_router_builder.g.dart';
|
|
|
|
final appRoutes = $appRoutes;
|
|
|
|
const String _loginPage = 'LoginPage';
|
|
const String _splashPage = 'SplashPage';
|
|
const String _notFound = 'not_found';
|
|
|
|
@TypedGoRoute<SplashRoute>(path: '/$_splashPage')
|
|
class SplashRoute extends GoRouteData with _$SplashRoute {
|
|
const SplashRoute();
|
|
|
|
// @override
|
|
// String? redirect(BuildContext context, GoRouterState state) {
|
|
// final isLogged = providerContainer
|
|
// .read(loginPageModelProvider)
|
|
// .status
|
|
// .isLogged;
|
|
// if (isLogged) {
|
|
// return HomeRoute().location;
|
|
// } else {
|
|
// return LoginRoute().location;
|
|
// }
|
|
// }
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => SplashPage();
|
|
}
|
|
|
|
@TypedGoRoute<LoginRoute>(path: '/$_loginPage')
|
|
class LoginRoute extends GoRouteData with _$LoginRoute {
|
|
const LoginRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => LoginPage();
|
|
}
|
|
|
|
@TypedGoRoute<NotFoundRoute>(path: '/$_notFound')
|
|
class NotFoundRoute extends GoRouteData with _$NotFoundRoute {
|
|
const NotFoundRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => SizedBox();
|
|
}
|