app_drawer.dart 10 KB

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