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

Co-authored-by: Azareth-Tr <Azareth-Tr@users.noreply.github.com>
Co-authored-by: eddgranados12 <eddgranados12@users.noreply.github.com>

implementacion de login, vistas, correcion de errores en vista registro, domicilios
This commit is contained in:
shinra32
2026-05-22 23:07:24 -06:00
parent b4ee3e7b49
commit c91b6e2091
52 changed files with 3940 additions and 4368 deletions

View File

@@ -0,0 +1,140 @@
import 'package:flutter/material.dart';
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/driver/driver_shell.dart';
import 'package:recolecta_app/features/driver/screens/driver_collections_screen.dart';
import 'package:recolecta_app/features/driver/screens/driver_home_screen.dart';
import 'package:recolecta_app/features/driver/screens/driver_incident_screen.dart';
import 'package:recolecta_app/features/feedback/feedback_screen.dart';
import 'package:recolecta_app/features/home/citizen_home_screen.dart';
import 'package:recolecta_app/features/home/citizen_shell.dart';
import 'package:recolecta_app/features/separation_guide/screens/category_detail_screen.dart';
import 'package:recolecta_app/features/separation_guide/screens/separation_guide_screen.dart';
import 'package:recolecta_app/core/services/auth_controller.dart';
// Mock Admin Screens
class AdminDashboardScreen extends StatelessWidget {
const AdminDashboardScreen({super.key});
@override
Widget build(BuildContext context) =>
const Scaffold(body: Center(child: Text('Admin Dashboard')));
}
class AdminRouteDetailScreen extends StatelessWidget {
const AdminRouteDetailScreen({super.key, required this.routeId});
final String routeId;
@override
Widget build(BuildContext context) =>
Scaffold(body: Center(child: Text('Admin Route Detail: $routeId')));
}
class AdminReassignScreen extends StatelessWidget {
const AdminReassignScreen({super.key, required this.routeId});
final String routeId;
@override
Widget build(BuildContext context) =>
Scaffold(body: Center(child: Text('Admin Reassign: $routeId')));
}
final routerProvider = Provider<GoRouter>((ref) {
final authState = ref.watch(authControllerProvider);
return GoRouter(
initialLocation: '/login',
redirect: (BuildContext context, GoRouterState state) {
final isAuthenticated = authState.value?.isAuthenticated ?? false;
final role = authState.value?.userRole;
final isLoggingIn = state.matchedLocation == '/login';
if (!isAuthenticated) {
return isLoggingIn ? null : '/login';
}
if (isLoggingIn) {
switch (role) {
case 'admin':
return '/admin';
case 'driver':
return '/driver';
case 'citizen':
return '/home';
default:
return '/login';
}
}
return null;
},
routes: [
GoRoute(path: '/login', builder: (context, state) => const LoginPage()),
ShellRoute(
builder: (context, state, child) => AdminShell(child: child),
routes: [
GoRoute(
path: '/admin',
builder: (context, state) => const AdminDashboardScreen(),
routes: [
GoRoute(
path: 'routes/:routeId',
builder: (context, state) => AdminRouteDetailScreen(
routeId: state.pathParameters['routeId']!,
),
),
GoRoute(
path: 'reassign/:routeId',
builder: (context, state) => AdminReassignScreen(
routeId: state.pathParameters['routeId']!,
),
),
],
),
],
),
ShellRoute(
builder: (context, state, child) => DriverShell(child: child),
routes: [
GoRoute(
path: '/driver',
builder: (context, state) => const DriverHomeScreen(),
),
GoRoute(
path: '/driver/collections',
builder: (context, state) => const DriverCollectionsScreen(),
),
GoRoute(
path: '/driver/incident',
builder: (context, state) => const DriverIncidentScreen(),
),
],
),
ShellRoute(
builder: (context, state, child) => CitizenShell(child: child),
routes: [
GoRoute(
path: '/home',
builder: (context, state) => const CitizenHomeScreen(),
),
GoRoute(
path: '/feedback',
builder: (context, state) => const FeedbackScreen(),
),
GoRoute(
path: '/guide',
builder: (context, state) => const SeparationGuideScreen(),
routes: [
GoRoute(
path: ':categoryId',
builder: (context, state) => CategoryDetailScreen(
categoryId: state.pathParameters['categoryId']!,
),
),
],
),
],
),
],
);
});