39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:solaragent/router.dart';
|
||
|
|
||
|
class AgentNavigation extends StatefulWidget {
|
||
|
const AgentNavigation({super.key});
|
||
|
|
||
|
static const List<(String, NavigationDestination)> destinations = [
|
||
|
('/', NavigationDestination(icon: Icon(Icons.home), label: 'Home')),
|
||
|
('/notifications', NavigationDestination(icon: Icon(Icons.notifications), label: 'Notifications')),
|
||
|
('/account', NavigationDestination(icon: Icon(Icons.account_circle), label: 'Account')),
|
||
|
];
|
||
|
|
||
|
@override
|
||
|
State<AgentNavigation> createState() => _AgentNavigationState();
|
||
|
}
|
||
|
|
||
|
class _AgentNavigationState extends State<AgentNavigation> {
|
||
|
int currentPage = 0;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return NavigationBar(
|
||
|
selectedIndex: currentPage,
|
||
|
destinations: AgentNavigation.destinations
|
||
|
.map(((String, NavigationDestination) e) => e.$2)
|
||
|
.toList(),
|
||
|
onDestinationSelected: (index) {
|
||
|
router.go(AgentNavigation.destinations[index].$1);
|
||
|
setState(() => currentPage = index);
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|