app_drawer.dart 10.0 KB

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