Co-authored-by: MENDOZA BALLARDO GAEL RICARDO <gael-meb123@users.noreply.github.com>
Co-authored-by: Azareth-Tr <Azareth-Tr@users.noreply.github.com>

modificacion de vistas panel admin, login, animaciones y implementacion de mascota
This commit is contained in:
shinra32
2026-05-23 03:58:03 -06:00
parent 45ffba69b2
commit 68d04f3917
33 changed files with 5188 additions and 643 deletions

View File

@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:recolecta_app/features/admin/admin_shell.dart';
import 'package:recolecta_app/features/auth/login_page.dart';
import 'package:recolecta_app/features/splash/splash_screen.dart';
import 'package:recolecta_app/features/auth/register_page.dart';
import 'package:recolecta_app/features/driver/driver_shell.dart';
import 'package:recolecta_app/features/driver/screens/driver_collections_screen.dart';
@@ -43,20 +44,21 @@ final routerProvider = Provider<GoRouter>((ref) {
final authState = ref.watch(authControllerProvider);
return GoRouter(
initialLocation: '/login',
initialLocation: '/splash',
redirect: (BuildContext context, GoRouterState state) {
final isAuthenticated = authState.value?.isAuthenticated ?? false;
final role = authState.value?.userRole;
final isAuthRoute =
final isPublicRoute =
state.matchedLocation == '/splash' ||
state.matchedLocation == '/login' ||
state.matchedLocation == '/register';
if (!isAuthenticated) {
return isAuthRoute ? null : '/login';
return isPublicRoute ? null : '/login';
}
if (isAuthRoute) {
if (isPublicRoute) {
switch (role) {
case 'admin':
return '/admin';
@@ -72,6 +74,10 @@ final routerProvider = Provider<GoRouter>((ref) {
return null;
},
routes: [
GoRoute(
path: '/splash',
builder: (context, state) => const SplashScreen(),
),
GoRoute(path: '/login', builder: (context, state) => const LoginPage()),
GoRoute(
path: '/register',