
Replaces the mocked login flow with an actual API call to an authentication endpoint. Updates the `AuthStruct` schema to align with the new API response, including fields for `accessToken`, `dbName`, `uid`, `name`, and `username`. Introduces a `UserConnectedProvider` service for managing the storage and retrieval of authenticated user details, centralizing this logic and replacing prior direct local storage methods. Integrates the new authentication process and user storage service into the login, reception, and profile pages for a unified experience. Adjusts the splash screen duration to reflect the real-time nature of the authentication check.
32 lines
1.2 KiB
Dart
32 lines
1.2 KiB
Dart
import 'package:barcode_scanner/components/loading_progress_component.dart';
|
|
import 'package:barcode_scanner/pages/login/login_page_model.dart';
|
|
import 'package:barcode_scanner/router/go_router_builder.dart';
|
|
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
|
|
import 'package:barcode_scanner/themes/app_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
class SplashPage extends ConsumerWidget {
|
|
const SplashPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
Future.delayed(Durations.short1).then((value) {
|
|
final authViewModel = ref.watch(loginPageModelProvider);
|
|
if (authViewModel.status.isLogged) {
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
ReceptionRoute().go(context);
|
|
});
|
|
} else if (authViewModel.status.isLogOut) {
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
LoginRoute().go(context);
|
|
});
|
|
}
|
|
});
|
|
return Scaffold(
|
|
backgroundColor: AppTheme.of(context).primaryBackground,
|
|
body: Center(child: LoadingProgressComponent()),
|
|
);
|
|
}
|
|
}
|