123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import '../../mvvm/viewmodels/viewmodels.dart';
- class CustomNavigationRail extends StatefulWidget {
- const CustomNavigationRail({super.key, required selectedIndex});
- @override
- State<CustomNavigationRail> createState() => Custom_NavigationRailState();
- }
- class Custom_NavigationRailState extends State<CustomNavigationRail> {
- int selectedIndex = 0;
- @override
- Widget build(BuildContext context) {
- return NavigationRail(
- minExtendedWidth: 100,
- minWidth: 30,
- backgroundColor: Color.fromARGB(255, 25, 30, 41),
- selectedIndex: selectedIndex,
- onDestinationSelected: (int index) {
- setState(() {
- selectedIndex = index;
- });
- if (index == 3) {
- Provider.of<LoginViewModel>(context, listen: false)
- .showExitConfirmationDialog(context);
- }
- },
- labelType: NavigationRailLabelType.all,
- destinations: const [
- NavigationRailDestination(
- icon: Icon(Icons.home, color: Colors.white),
- selectedIcon: Icon(Icons.home_filled),
- label: Text('Inicio'),
- ),
- NavigationRailDestination(
- icon: Icon(Icons.search),
- selectedIcon: Icon(
- Icons.search_rounded,
- color: Colors.white,
- ),
- label: Text('Buscar'),
- ),
- NavigationRailDestination(
- icon: Icon(Icons.settings),
- selectedIcon: Icon(Icons.settings_rounded, color: Colors.white),
- label: Text('Ajustes'),
- ),
- NavigationRailDestination(
- icon: Icon(Icons.logout),
- selectedIcon: Icon(Icons.logout, color: Colors.white),
- label: Text('Cerrar Sesión'),
- ),
- ],
- );
- }
- }
|