Files
hackathon-innovaflow5.0-cdf…/recolecta_app/lib/features/home/citizen_shell.dart
2026-05-23 00:58:10 -06:00

42 lines
1.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../core/widgets/app_widgets.dart';
class CitizenShell extends StatelessWidget {
const CitizenShell({super.key, required this.child});
final Widget child;
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;
}
void _onTap(BuildContext context, int index) {
switch (index) {
case 0:
context.go('/home');
case 1:
context.go('/alerts');
case 2:
context.go('/house');
case 3:
context.go('/profile');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: child,
bottomNavigationBar: AppBottomNav(
currentIndex: _currentIndex(context),
onTap: (i) => _onTap(context, i),
),
);
}
}