app_drawer.dart 3.3 KB

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