44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../core/widgets/app_widgets.dart';
|
|
import '../../shared/widgets/eco_floating_button.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,
|
|
floatingActionButton: const EcoFloatingButton(),
|
|
bottomNavigationBar: AppBottomNav(
|
|
currentIndex: _currentIndex(context),
|
|
onTap: (i) => _onTap(context, i),
|
|
),
|
|
);
|
|
}
|
|
}
|