app_drawer.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 'package:yoshi_papas_app/views/venta/venta_screen.dart';
  12. import '../models/usuario_model.dart';
  13. import 'package:provider/provider.dart';
  14. import '../themes/themes.dart';
  15. import '../viewmodels/login_view_model.dart';
  16. import 'widgets_components.dart';
  17. class AppDrawer extends StatelessWidget {
  18. AppDrawer({super.key});
  19. Future<bool> _showExitConfirmationDialog(BuildContext context) async {
  20. bool shouldPop = false;
  21. await showDialog(
  22. context: context,
  23. builder: (context) => AlertDialog(
  24. surfaceTintColor: AppTheme.secondary,
  25. title: const Text('¿Cerrar sesión?'),
  26. content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
  27. actions: [
  28. TextButton(
  29. onPressed: () => Navigator.of(context).pop(false),
  30. child: const Text('Cancelar', style: TextStyle(color: Colors.red)),
  31. ),
  32. TextButton(
  33. onPressed: () {
  34. Navigator.pop(context);
  35. Navigator.pop(context);
  36. Provider.of<LoginViewModel>(context, listen: false).logOut();
  37. Navigator.of(context)
  38. .pushNamedAndRemoveUntil('main', (route) => false);
  39. },
  40. child: const Text('Aceptar'),
  41. ),
  42. ],
  43. ),
  44. );
  45. return shouldPop;
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. String? nombre = Provider.of<LoginViewModel>(context).nombre.toString();
  50. String? correo = Provider.of<LoginViewModel>(context).correo.toString();
  51. //final avm = Provider.of<AdministracionViewModel>(context);
  52. //List<String> permisos = avm.lospermisos;
  53. return Drawer(
  54. surfaceTintColor: Colors.white,
  55. backgroundColor: Colors.white,
  56. child: Column(
  57. children: [
  58. Container(
  59. width: double.infinity,
  60. decoration: BoxDecoration(
  61. color: AppTheme.primary,
  62. ),
  63. padding: EdgeInsets.only(
  64. top: MediaQuery.of(context).padding.top,
  65. ),
  66. child: const Column(
  67. children: [
  68. Padding(
  69. padding: EdgeInsets.all(8.0),
  70. child: Image(
  71. image: AssetImage('assets/JoshiLogoHorizontal.png'),
  72. height: 150,
  73. ),
  74. ),
  75. SizedBox(
  76. height: 10,
  77. ),
  78. // Text(
  79. // nombre.toString(),
  80. // style: const TextStyle(
  81. // fontSize: 18,
  82. // fontWeight: FontWeight.bold,
  83. // ),
  84. // ),
  85. // const SizedBox(
  86. // height: 10,
  87. // ),
  88. // Text(
  89. // correo.toString(),
  90. // style: const TextStyle(
  91. // fontSize: 15,
  92. // fontWeight: FontWeight.bold,
  93. // ),
  94. // ),
  95. SizedBox(
  96. height: 10,
  97. ),
  98. ],
  99. ),
  100. ),
  101. //HEADER
  102. Expanded(
  103. child: ListView(children: [
  104. ListTile(
  105. leading: circulo(const Icon(Icons.restaurant_menu)),
  106. title: const Text('Pedidos'),
  107. onTap: () => {
  108. Navigator.pop(context),
  109. Navigator.of(context).push(
  110. MaterialPageRoute(
  111. builder: (context) => const PedidoScreen(),
  112. ),
  113. ),
  114. },
  115. ),
  116. ListTile(
  117. leading: circulo(const Icon(Icons.menu_book_rounded)),
  118. title: const Text('Productos'),
  119. onTap: () => {
  120. Navigator.pop(context),
  121. Navigator.of(context).push(
  122. MaterialPageRoute(
  123. builder: (context) => ProductoScreen(),
  124. ),
  125. ),
  126. },
  127. ),
  128. ListTile(
  129. leading: circulo(const Icon(Icons.format_list_bulleted_rounded)),
  130. title: const Text('Categoria Producto'),
  131. onTap: () => {
  132. Navigator.pop(context),
  133. Navigator.of(context).push(
  134. MaterialPageRoute(
  135. builder: (context) => CategoriaProductoScreen(),
  136. ),
  137. ),
  138. },
  139. ),
  140. ListTile(
  141. leading: circulo(const Icon(Icons.receipt_long_outlined)),
  142. title: const Text('Pedidos Por Día'),
  143. onTap: () => {
  144. Navigator.pop(context),
  145. Navigator.of(context).push(
  146. MaterialPageRoute(
  147. builder: (context) => VentaScreen(),
  148. ),
  149. ),
  150. },
  151. ),
  152. // ListTile(
  153. // leading: const Icon(Icons.logout),
  154. // title: const Text('Cerrar sesión'),
  155. // onTap: () {
  156. // _showExitConfirmationDialog(context);
  157. // },
  158. // ),
  159. ]))
  160. ],
  161. ),
  162. );
  163. }
  164. }