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_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<GoRouter>((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<GoRouter>((ref) {
),
],
),
// ── Chofer ────────────────────────────────────────────────────────────
ShellRoute(
builder: (context, state, child) => DriverShell(child: child),
routes: [
@@ -112,6 +119,8 @@ final routerProvider = Provider<GoRouter>((ref) {
),
],
),
// ── Ciudadano — 4 tabs ────────────────────────────────────────────────
ShellRoute(
builder: (context, state, child) => CitizenShell(child: child),
routes: [
@@ -119,6 +128,19 @@ final routerProvider = Provider<GoRouter>((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<GoRouter>((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(),
),
],
);
});

View File

@@ -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<CitizenShell> 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<CitizenShell> {
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),
),
);
}