44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
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;
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|