vistas correctas implementadas del mockuoçp

This commit is contained in:
shinra32
2026-05-23 00:58:10 -06:00
parent 3a3178eb3b
commit 0279ad05f4
2 changed files with 48 additions and 30 deletions

View File

@@ -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_collections_screen.dart';
import 'package:recolecta_app/features/driver/screens/driver_home_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/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_home_screen.dart';
import 'package:recolecta_app/features/home/citizen_shell.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/category_detail_screen.dart';
import 'package:recolecta_app/features/separation_guide/screens/separation_guide_screen.dart'; import 'package:recolecta_app/features/separation_guide/screens/separation_guide_screen.dart';
import 'package:recolecta_app/core/services/auth_controller.dart'; import 'package:recolecta_app/core/services/auth_controller.dart';
@@ -72,6 +75,8 @@ final routerProvider = Provider<GoRouter>((ref) {
path: '/register', path: '/register',
builder: (context, state) => const RegisterPage(), builder: (context, state) => const RegisterPage(),
), ),
// ── Admin ─────────────────────────────────────────────────────────────
ShellRoute( ShellRoute(
builder: (context, state, child) => AdminShell(child: child), builder: (context, state, child) => AdminShell(child: child),
routes: [ routes: [
@@ -95,6 +100,8 @@ final routerProvider = Provider<GoRouter>((ref) {
), ),
], ],
), ),
// ── Chofer ────────────────────────────────────────────────────────────
ShellRoute( ShellRoute(
builder: (context, state, child) => DriverShell(child: child), builder: (context, state, child) => DriverShell(child: child),
routes: [ routes: [
@@ -112,6 +119,8 @@ final routerProvider = Provider<GoRouter>((ref) {
), ),
], ],
), ),
// ── Ciudadano — 4 tabs ────────────────────────────────────────────────
ShellRoute( ShellRoute(
builder: (context, state, child) => CitizenShell(child: child), builder: (context, state, child) => CitizenShell(child: child),
routes: [ routes: [
@@ -119,6 +128,19 @@ final routerProvider = Provider<GoRouter>((ref) {
path: '/home', path: '/home',
builder: (context, state) => const CitizenHomeScreen(), 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( GoRoute(
path: '/feedback', path: '/feedback',
builder: (context, state) => const FeedbackScreen(), builder: (context, state) => const FeedbackScreen(),
@@ -137,11 +159,16 @@ final routerProvider = Provider<GoRouter>((ref) {
), ),
], ],
), ),
// ── Pantallas sueltas (sin shell) ─────────────────────────────────────
GoRoute( GoRoute(
path: '/notifications', path: '/notifications',
builder: (context, state) => const NotificationsScreen(), builder: (context, state) => const NotificationsScreen(),
), ),
GoRoute(path: '/quiz', builder: (context, state) => const QuizScreen()), GoRoute(
path: '/quiz',
builder: (context, state) => const QuizScreen(),
),
], ],
); );
}); });

View File

@@ -1,49 +1,40 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.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}); const CitizenShell({super.key, required this.child});
final Widget child; final Widget child;
@override int _currentIndex(BuildContext context) {
State<CitizenShell> createState() => _CitizenShellState(); 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<CitizenShell> { void _onTap(BuildContext context, int index) {
int _currentIndex = 0;
void _onTap(int index) {
setState(() {
_currentIndex = index;
});
switch (index) { switch (index) {
case 0: case 0:
context.go('/home'); context.go('/home');
break;
case 1: case 1:
context.go('/guide'); context.go('/alerts');
break;
case 2: case 2:
context.go('/feedback'); context.go('/house');
break; case 3:
context.go('/profile');
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: widget.child, body: child,
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: AppBottomNav(
currentIndex: _currentIndex, currentIndex: _currentIndex(context),
onTap: _onTap, onTap: (i) => _onTap(context, i),
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',
),
],
), ),
); );
} }