app_drawer.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 '../models/usuario_model.dart';
  10. import 'package:provider/provider.dart';
  11. import '../themes/themes.dart';
  12. import '../viewmodels/login_view_model.dart';
  13. import 'widgets_components.dart';
  14. class AppDrawer extends StatelessWidget {
  15. AppDrawer({super.key});
  16. Future<bool> _showExitConfirmationDialog(BuildContext context) async {
  17. bool shouldPop = false;
  18. await showDialog(
  19. context: context,
  20. builder: (context) => AlertDialog(
  21. surfaceTintColor: AppTheme.secondary,
  22. title: const Text('¿Cerrar sesión?'),
  23. content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
  24. actions: [
  25. TextButton(
  26. onPressed: () => Navigator.of(context).pop(false),
  27. child: const Text('Cancelar', style: TextStyle(color: Colors.red)),
  28. ),
  29. TextButton(
  30. onPressed: () {
  31. Navigator.pop(context);
  32. Navigator.pop(context);
  33. Provider.of<LoginViewModel>(context, listen: false).logOut();
  34. Navigator.of(context)
  35. .pushNamedAndRemoveUntil('main', (route) => false);
  36. },
  37. child: const Text('Aceptar'),
  38. ),
  39. ],
  40. ),
  41. );
  42. return shouldPop;
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. String? nombre = Provider.of<LoginViewModel>(context).nombre.toString();
  47. String? correo = Provider.of<LoginViewModel>(context).correo.toString();
  48. //final avm = Provider.of<AdministracionViewModel>(context);
  49. //List<String> permisos = avm.lospermisos;
  50. return Drawer(
  51. surfaceTintColor: Colors.white,
  52. backgroundColor: Colors.white,
  53. child: Column(
  54. children: [
  55. Container(
  56. width: double.infinity,
  57. decoration: BoxDecoration(
  58. color: AppTheme.primary,
  59. ),
  60. padding: EdgeInsets.only(
  61. top: MediaQuery.of(context).padding.top,
  62. ),
  63. child: Column(
  64. children: [
  65. const Padding(
  66. padding: EdgeInsets.all(8.0),
  67. child: Image(
  68. image: AssetImage('assets/JoshiLogoHorizontal.png'),
  69. height: 150,
  70. ),
  71. ),
  72. const SizedBox(
  73. height: 10,
  74. ),
  75. Text(
  76. nombre.toString(),
  77. style: const TextStyle(
  78. fontSize: 18,
  79. fontWeight: FontWeight.bold,
  80. ),
  81. ),
  82. const SizedBox(
  83. height: 10,
  84. ),
  85. Text(
  86. correo.toString(),
  87. style: const TextStyle(
  88. fontSize: 15,
  89. fontWeight: FontWeight.bold,
  90. ),
  91. ),
  92. const SizedBox(
  93. height: 10,
  94. ),
  95. ],
  96. ),
  97. ),
  98. //HEADER
  99. Expanded(
  100. child: ListView(children: [
  101. ListTile(
  102. leading: circulo(const Icon(Icons.lunch_dining)),
  103. title: const Text('Inicio'),
  104. onTap: () => {
  105. Navigator.pop(context),
  106. Navigator.of(context).push(
  107. MaterialPageRoute(
  108. builder: (context) => const HomeScreen(),
  109. ),
  110. ),
  111. },
  112. ),
  113. ListTile(
  114. leading: circulo(const Icon(Icons.restaurant_menu)),
  115. title: const Text('Pedidos'),
  116. onTap: () => {
  117. Navigator.pop(context),
  118. Navigator.of(context).push(
  119. MaterialPageRoute(
  120. builder: (context) => const PedidoScreen(),
  121. ),
  122. ),
  123. },
  124. ),
  125. ListTile(
  126. leading: circulo(const Icon(Icons.table_bar)),
  127. title: const Text('Mesas'),
  128. onTap: () => {
  129. Navigator.pop(context),
  130. Navigator.of(context).push(
  131. MaterialPageRoute(
  132. builder: (context) => const HomeScreen(),
  133. ),
  134. ),
  135. },
  136. ),
  137. ListTile(
  138. leading: circulo(const Icon(Icons.local_cafe)),
  139. title: const Text('Productos'),
  140. onTap: () => {
  141. Navigator.pop(context),
  142. Navigator.of(context).push(
  143. MaterialPageRoute(
  144. builder: (context) => const ProductoScreen(),
  145. ),
  146. ),
  147. },
  148. ),
  149. ListTile(
  150. leading: circulo(const Icon(Icons.format_list_bulleted)),
  151. title: const Text('Caregorías de Producto'),
  152. onTap: () => {
  153. Navigator.pop(context),
  154. Navigator.of(context).push(
  155. MaterialPageRoute(
  156. builder: (context) => const CategoriaProductoScreen(),
  157. ),
  158. ),
  159. },
  160. ),
  161. ListTile(
  162. leading:
  163. circulo(const Icon(Icons.switch_access_shortcut_add_sharp)),
  164. title: const Text('Topings'),
  165. onTap: () => {
  166. Navigator.pop(context),
  167. Navigator.of(context).push(
  168. MaterialPageRoute(
  169. builder: (context) => const HomeScreen(),
  170. ),
  171. ),
  172. },
  173. ),
  174. ListTile(
  175. leading: circulo(const Icon(Icons.format_list_bulleted)),
  176. title: const Text('Categorías de Toping'),
  177. onTap: () => {
  178. Navigator.pop(context),
  179. Navigator.of(context).push(
  180. MaterialPageRoute(
  181. builder: (context) => const HomeScreen(),
  182. ),
  183. ),
  184. },
  185. ),
  186. ListTile(
  187. leading: circulo(const Icon(Icons.discount)),
  188. title: const Text('Promociones'),
  189. onTap: () => {
  190. Navigator.pop(context),
  191. Navigator.of(context).push(
  192. MaterialPageRoute(
  193. builder: (context) => const HomeScreen(),
  194. ),
  195. ),
  196. },
  197. ),
  198. ListTile(
  199. leading: circulo(const Icon(Icons.photo)),
  200. title: const Text('Contenidos Web'),
  201. onTap: () => {
  202. Navigator.pop(context),
  203. Navigator.of(context).push(
  204. MaterialPageRoute(
  205. builder: (context) => const HomeScreen(),
  206. ),
  207. ),
  208. },
  209. ),
  210. ListTile(
  211. leading: circulo(const Icon(Icons.storefront)),
  212. title: const Text('Sucursales'),
  213. onTap: () => {
  214. Navigator.pop(context),
  215. Navigator.of(context).push(
  216. MaterialPageRoute(
  217. builder: (context) => const HomeScreen(),
  218. ),
  219. ),
  220. },
  221. ),
  222. ListTile(
  223. leading: circulo(const Icon(Icons.groups)),
  224. title: const Text('Clientes'),
  225. onTap: () => {
  226. Navigator.pop(context),
  227. Navigator.of(context).push(
  228. MaterialPageRoute(
  229. builder: (context) => const HomeScreen(),
  230. ),
  231. ),
  232. },
  233. ),
  234. ListTile(
  235. leading: circulo(const Icon(Icons.credit_card_rounded)),
  236. title: const Text('Tarjetas'),
  237. onTap: () => {
  238. Navigator.pop(context),
  239. Navigator.of(context).push(
  240. MaterialPageRoute(
  241. builder: (context) => const HomeScreen(),
  242. ),
  243. ),
  244. },
  245. ),
  246. ListTile(
  247. leading: circulo(const Icon(Icons.point_of_sale)),
  248. title: const Text('Ventas'),
  249. onTap: () => {
  250. Navigator.pop(context),
  251. Navigator.of(context).push(
  252. MaterialPageRoute(
  253. builder: (context) => const HomeScreen(),
  254. ),
  255. ),
  256. },
  257. ),
  258. ExpansionTile(
  259. leading: circulo(const Icon(Icons.circle)),
  260. title: const Text("ADMINISTRACIÓN"),
  261. childrenPadding: const EdgeInsets.only(left: 8),
  262. children: [
  263. ListTile(
  264. leading: circulo(const Icon(Icons.person_add_alt)),
  265. title: const Text('USUARIOS'),
  266. onTap: () => {
  267. Navigator.pop(context),
  268. // Navigator.of(context).push(
  269. // MaterialPageRoute(
  270. // builder: (context) => const UsuariosScreen(),
  271. // ),
  272. // ),
  273. },
  274. ),
  275. ]),
  276. ListTile(
  277. leading: const Icon(Icons.person),
  278. title: const Text('PERFIL'),
  279. onTap: () {
  280. Navigator.push(
  281. context,
  282. MaterialPageRoute(
  283. builder: (context) => const PerfilScreen()));
  284. },
  285. ),
  286. ListTile(
  287. leading: const Icon(Icons.logout),
  288. title: const Text('Cerrar sesión'),
  289. onTap: () {
  290. _showExitConfirmationDialog(context);
  291. },
  292. ),
  293. ]))
  294. ],
  295. ),
  296. );
  297. }
  298. }