app_drawer.dart 4.2 KB

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