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 createState() => Custom_NavigationRailState(); } class Custom_NavigationRailState extends State { int selectedIndex = 0; @override Widget build(BuildContext context) { return NavigationRail( backgroundColor: Color.fromARGB(255, 25, 30, 41), selectedIndex: selectedIndex, onDestinationSelected: (int index) { setState(() { selectedIndex = index; }); if (index == 3) { Provider.of(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'), ), ], ); } }