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

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