From 0279ad05f4e4568133e7d4f1fcc969feb4962e05 Mon Sep 17 00:00:00 2001 From: shinra32 Date: Sat, 23 May 2026 00:58:10 -0600 Subject: [PATCH] =?UTF-8?q?vistas=20correctas=20implementadas=20del=20mock?= =?UTF-8?q?uo=C3=A7p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recolecta_app/lib/core/router/app_router.dart | 31 +++++++++++- .../lib/features/home/citizen_shell.dart | 47 ++++++++----------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/recolecta_app/lib/core/router/app_router.dart b/recolecta_app/lib/core/router/app_router.dart index f5b68a0..3fc5b86 100644 --- a/recolecta_app/lib/core/router/app_router.dart +++ b/recolecta_app/lib/core/router/app_router.dart @@ -8,9 +8,12 @@ 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/home/house_screen.dart'; +import 'package:recolecta_app/features/alerts/alerts_screen.dart'; +import 'package:recolecta_app/features/profile/profile_screen.dart'; +import 'package:recolecta_app/features/feedback/feedback_screen.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'; @@ -72,6 +75,8 @@ final routerProvider = Provider((ref) { path: '/register', builder: (context, state) => const RegisterPage(), ), + + // ── Admin ───────────────────────────────────────────────────────────── ShellRoute( builder: (context, state, child) => AdminShell(child: child), routes: [ @@ -95,6 +100,8 @@ final routerProvider = Provider((ref) { ), ], ), + + // ── Chofer ──────────────────────────────────────────────────────────── ShellRoute( builder: (context, state, child) => DriverShell(child: child), routes: [ @@ -112,6 +119,8 @@ final routerProvider = Provider((ref) { ), ], ), + + // ── Ciudadano — 4 tabs ──────────────────────────────────────────────── ShellRoute( builder: (context, state, child) => CitizenShell(child: child), routes: [ @@ -119,6 +128,19 @@ final routerProvider = Provider((ref) { path: '/home', builder: (context, state) => const CitizenHomeScreen(), ), + GoRoute( + path: '/alerts', + builder: (context, state) => const AlertsScreen(), + ), + GoRoute( + path: '/house', + builder: (context, state) => const MyHouseScreen(), + ), + GoRoute( + path: '/profile', + builder: (context, state) => const ProfileScreen(), + ), + // Rutas secundarias accesibles con el nav bar visible GoRoute( path: '/feedback', builder: (context, state) => const FeedbackScreen(), @@ -137,11 +159,16 @@ final routerProvider = Provider((ref) { ), ], ), + + // ── Pantallas sueltas (sin shell) ───────────────────────────────────── GoRoute( path: '/notifications', builder: (context, state) => const NotificationsScreen(), ), - GoRoute(path: '/quiz', builder: (context, state) => const QuizScreen()), + GoRoute( + path: '/quiz', + builder: (context, state) => const QuizScreen(), + ), ], ); }); diff --git a/recolecta_app/lib/features/home/citizen_shell.dart b/recolecta_app/lib/features/home/citizen_shell.dart index f4a8048..2025c5e 100644 --- a/recolecta_app/lib/features/home/citizen_shell.dart +++ b/recolecta_app/lib/features/home/citizen_shell.dart @@ -1,49 +1,40 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -class CitizenShell extends StatefulWidget { +import '../../core/widgets/app_widgets.dart'; + +class CitizenShell extends StatelessWidget { const CitizenShell({super.key, required this.child}); final Widget child; - @override - State createState() => _CitizenShellState(); -} + int _currentIndex(BuildContext context) { + final location = GoRouterState.of(context).matchedLocation; + if (location.startsWith('/alerts')) return 1; + if (location.startsWith('/house')) return 2; + if (location.startsWith('/profile')) return 3; + return 0; + } -class _CitizenShellState extends State { - int _currentIndex = 0; - - void _onTap(int index) { - setState(() { - _currentIndex = index; - }); + void _onTap(BuildContext context, int index) { switch (index) { case 0: context.go('/home'); - break; case 1: - context.go('/guide'); - break; + context.go('/alerts'); case 2: - context.go('/feedback'); - break; + context.go('/house'); + case 3: + context.go('/profile'); } } @override Widget build(BuildContext context) { return Scaffold( - body: widget.child, - bottomNavigationBar: BottomNavigationBar( - currentIndex: _currentIndex, - onTap: _onTap, - items: const [ - BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Inicio'), - BottomNavigationBarItem(icon: Icon(Icons.menu_book), label: 'Guía'), - BottomNavigationBarItem( - icon: Icon(Icons.feedback), - label: 'Retroalimentación', - ), - ], + body: child, + bottomNavigationBar: AppBottomNav( + currentIndex: _currentIndex(context), + onTap: (i) => _onTap(context, i), ), ); }