app_drawer.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // ignore_for_file: must_be_immutable
  2. import 'package:flutter/material.dart';
  3. import 'package:computo_lite/models/models.dart';
  4. import 'package:provider/provider.dart';
  5. import '../themes/themes.dart';
  6. import '../viewmodels/login_view_model.dart';
  7. import 'widgets_components.dart';
  8. class AppDrawer extends StatelessWidget {
  9. AppDrawer({super.key});
  10. Future<bool> _showExitConfirmationDialog(BuildContext context) async {
  11. bool shouldPop = false;
  12. await showDialog(
  13. context: context,
  14. builder: (context) => AlertDialog(
  15. surfaceTintColor: AppTheme.secondary,
  16. title: const Text('¿Cerrar sesión?'),
  17. content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
  18. actions: [
  19. TextButton(
  20. onPressed: () => Navigator.of(context).pop(false),
  21. child: const Text('Cancelar', style: TextStyle(color: Colors.red)),
  22. ),
  23. TextButton(
  24. onPressed: () {
  25. Navigator.pop(context);
  26. Navigator.pop(context);
  27. Provider.of<LoginViewModel>(context, listen: false).logOut();
  28. Navigator.of(context)
  29. .pushNamedAndRemoveUntil('main', (route) => false);
  30. },
  31. child: const Text('Aceptar'),
  32. ),
  33. ],
  34. ),
  35. );
  36. return shouldPop;
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. String? nombre = Provider.of<LoginViewModel>(context).nombre.toString();
  41. String? correo = Provider.of<LoginViewModel>(context).correo.toString();
  42. //final avm = Provider.of<AdministracionViewModel>(context);
  43. //List<String> permisos = avm.lospermisos;
  44. return Drawer(
  45. surfaceTintColor: Colors.white,
  46. backgroundColor: Colors.white,
  47. child: Column(
  48. children: [
  49. Container(
  50. width: double.infinity,
  51. decoration: BoxDecoration(
  52. color: AppTheme.primary,
  53. ),
  54. padding: EdgeInsets.only(
  55. top: MediaQuery.of(context).padding.top,
  56. ),
  57. child: Column(
  58. children: [
  59. const Padding(
  60. padding: EdgeInsets.all(8.0),
  61. child: Image(
  62. image: AssetImage('assets/Elecciones2024.png'),
  63. height: 150,
  64. ),
  65. ),
  66. const SizedBox(
  67. height: 10,
  68. ),
  69. const SizedBox(
  70. height: 10,
  71. ),
  72. Text(
  73. correo.toString(),
  74. style: const TextStyle(
  75. fontSize: 15,
  76. fontWeight: FontWeight.bold,
  77. color: Colors.white),
  78. ),
  79. const SizedBox(
  80. height: 10,
  81. ),
  82. ],
  83. ),
  84. ),
  85. //HEADER
  86. Expanded(
  87. child: ListView(children: [
  88. ListTile(
  89. leading: const Icon(Icons.logout),
  90. title: const Text('Cerrar sesión'),
  91. onTap: () {
  92. _showExitConfirmationDialog(context);
  93. },
  94. ),
  95. ]))
  96. ],
  97. ),
  98. );
  99. }
  100. }