✨ Navigation
This commit is contained in:
43
lib/layouts/navigation.dart
Normal file
43
lib/layouts/navigation.dart
Normal file
@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class AgentNavigation extends StatefulWidget {
|
||||
const AgentNavigation({super.key, required this.router});
|
||||
|
||||
final GoRouter router;
|
||||
|
||||
static const items = [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Dashboard',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Account',
|
||||
)
|
||||
];
|
||||
|
||||
static const destinations = ["/", "/account"];
|
||||
|
||||
@override
|
||||
State<AgentNavigation> createState() => _AgentNavigationState();
|
||||
}
|
||||
|
||||
class _AgentNavigationState extends State<AgentNavigation> {
|
||||
int _selected = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigationBar(
|
||||
selectedIndex: _selected,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
destinations: AgentNavigation.items,
|
||||
onDestinationSelected: (index) {
|
||||
widget.router.push(AgentNavigation.destinations[index]);
|
||||
setState(() {
|
||||
_selected = index;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user