app_drawer.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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: Column(
  66. children: [
  67. const Padding(
  68. padding: EdgeInsets.all(8.0),
  69. child: Image(
  70. image: AssetImage('assets/JoshiLogoHorizontal.png'),
  71. height: 150,
  72. ),
  73. ),
  74. const 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. const 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: circulo(const Icon(Icons.table_bar)),
  129. title: const Text('Mesas'),
  130. onTap: () => {
  131. Navigator.pop(context),
  132. Navigator.of(context).push(
  133. MaterialPageRoute(
  134. builder: (context) => const HomeScreen(),
  135. ),
  136. ),
  137. },
  138. ),
  139. ListTile(
  140. leading: circulo(const Icon(Icons.local_cafe)),
  141. title: const Text('Productos'),
  142. onTap: () => {
  143. Navigator.pop(context),
  144. Navigator.of(context).push(
  145. MaterialPageRoute(
  146. builder: (context) => const ProductoScreen(),
  147. ),
  148. ),
  149. },
  150. ),
  151. ListTile(
  152. leading: circulo(const Icon(Icons.format_list_bulleted)),
  153. title: const Text('Caregorías de Producto'),
  154. onTap: () => {
  155. Navigator.pop(context),
  156. Navigator.of(context).push(
  157. MaterialPageRoute(
  158. builder: (context) => const CategoriaProductoScreen(),
  159. ),
  160. ),
  161. },
  162. ),
  163. ListTile(
  164. leading:
  165. circulo(const Icon(Icons.switch_access_shortcut_add_sharp)),
  166. title: const Text('Topings'),
  167. onTap: () => {
  168. Navigator.pop(context),
  169. Navigator.of(context).push(
  170. MaterialPageRoute(
  171. builder: (context) => const TopingScreen(),
  172. ),
  173. ),
  174. },
  175. ),
  176. ListTile(
  177. leading: circulo(const Icon(Icons.format_list_bulleted)),
  178. title: const Text('Categorías de Toping'),
  179. onTap: () => {
  180. Navigator.pop(context),
  181. Navigator.of(context).push(
  182. MaterialPageRoute(
  183. builder: (context) => const TopingCategoriaScreen(),
  184. ),
  185. ),
  186. },
  187. ),
  188. ListTile(
  189. leading: circulo(const Icon(Icons.discount)),
  190. title: const Text('Promociones'),
  191. onTap: () => {
  192. Navigator.pop(context),
  193. Navigator.of(context).push(
  194. MaterialPageRoute(
  195. builder: (context) => const HomeScreen(),
  196. ),
  197. ),
  198. },
  199. ),
  200. ListTile(
  201. leading: circulo(const Icon(Icons.photo)),
  202. title: const Text('Contenidos Web'),
  203. onTap: () => {
  204. Navigator.pop(context),
  205. Navigator.of(context).push(
  206. MaterialPageRoute(
  207. builder: (context) => const HomeScreen(),
  208. ),
  209. ),
  210. },
  211. ),
  212. ListTile(
  213. leading: circulo(const Icon(Icons.storefront)),
  214. title: const Text('Sucursales'),
  215. onTap: () => {
  216. Navigator.pop(context),
  217. Navigator.of(context).push(
  218. MaterialPageRoute(
  219. builder: (context) => const HomeScreen(),
  220. ),
  221. ),
  222. },
  223. ),
  224. ListTile(
  225. leading: circulo(const Icon(Icons.groups)),
  226. title: const Text('Clientes'),
  227. onTap: () => {
  228. Navigator.pop(context),
  229. Navigator.of(context).push(
  230. MaterialPageRoute(
  231. builder: (context) => const HomeScreen(),
  232. ),
  233. ),
  234. },
  235. ),
  236. ListTile(
  237. leading: circulo(const Icon(Icons.credit_card_rounded)),
  238. title: const Text('Tarjetas'),
  239. onTap: () => {
  240. Navigator.pop(context),
  241. Navigator.of(context).push(
  242. MaterialPageRoute(
  243. builder: (context) => const HomeScreen(),
  244. ),
  245. ),
  246. },
  247. ),
  248. ListTile(
  249. leading: circulo(const Icon(Icons.point_of_sale)),
  250. title: const Text('Ventas'),
  251. onTap: () => {
  252. Navigator.pop(context),
  253. Navigator.of(context).push(
  254. MaterialPageRoute(
  255. builder: (context) => const HomeScreen(),
  256. ),
  257. ),
  258. },
  259. ),
  260. ExpansionTile(
  261. leading: circulo(const Icon(Icons.circle)),
  262. title: const Text("ADMINISTRACIÓN"),
  263. childrenPadding: const EdgeInsets.only(left: 8),
  264. children: [
  265. ListTile(
  266. leading: circulo(const Icon(Icons.person_add_alt)),
  267. title: const Text('USUARIOS'),
  268. onTap: () => {
  269. Navigator.pop(context),
  270. // Navigator.of(context).push(
  271. // MaterialPageRoute(
  272. // builder: (context) => const UsuariosScreen(),
  273. // ),
  274. // ),
  275. },
  276. ),
  277. ]),
  278. ListTile(
  279. leading: const Icon(Icons.person),
  280. title: const Text('PERFIL'),
  281. onTap: () {
  282. Navigator.push(
  283. context,
  284. MaterialPageRoute(
  285. builder: (context) => const PerfilScreen()));
  286. },
  287. ),
  288. ListTile(
  289. leading: const Icon(Icons.logout),
  290. title: const Text('Cerrar sesión'),
  291. onTap: () {
  292. _showExitConfirmationDialog(context);
  293. },
  294. ),
  295. ]))
  296. ],
  297. ),
  298. );
  299. }
  300. }