Solian/lib/widgets/navigation/app_navigation_rail.dart

37 lines
1022 B
Dart
Raw Normal View History

2024-05-18 10:17:16 +00:00
import 'package:flutter/material.dart';
import 'package:solian/router.dart';
import 'package:solian/widgets/navigation/app_navigation.dart';
class AppNavigationRail extends StatefulWidget {
const AppNavigationRail({super.key});
@override
State<AppNavigationRail> createState() => _AppNavigationRailState();
}
class _AppNavigationRailState extends State<AppNavigationRail> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return NavigationRail(
2024-05-23 12:00:26 +00:00
destinations: AppNavigation.destinations
.map(
(e) => NavigationRailDestination(
icon: e.icon,
label: Text(e.label),
),
)
.toList(),
2024-06-01 13:50:24 +00:00
groupAlignment: 0,
2024-05-23 12:00:26 +00:00
labelType: NavigationRailLabelType.all,
2024-05-18 10:17:16 +00:00
selectedIndex: _selectedIndex,
onDestinationSelected: (idx) {
setState(() => _selectedIndex = idx);
2024-05-25 17:21:08 +00:00
AppRouter.instance
.pushReplacementNamed(AppNavigation.destinations[idx].page);
2024-05-18 10:17:16 +00:00
},
);
}
}