app_drawer.dart 4.8 KB

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