app_drawer.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. // ignore_for_file: must_be_immutable
  2. import 'package:conalep_pos/models/models.dart';
  3. import 'package:conalep_pos/views/categoria_producto/categoria_producto_screen.dart';
  4. import 'package:conalep_pos/views/corte_caja/corte_caja_screen.dart';
  5. import 'package:conalep_pos/views/mesa/mesa_screen.dart';
  6. import 'package:conalep_pos/views/pedido/pedido_screen.dart';
  7. import 'package:conalep_pos/views/pedido_mesa/pedido_mesa_screen.dart';
  8. import 'package:conalep_pos/views/producto/producto_screen.dart';
  9. import 'package:conalep_pos/views/venta/venta_screen.dart';
  10. import 'package:flutter/material.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 '../views/descuento/descuento_screen.dart';
  16. import '../views/variable/variable_screen.dart';
  17. import 'widgets_components.dart';
  18. class AppDrawer extends StatelessWidget {
  19. AppDrawer({super.key});
  20. Future<bool> _showExitConfirmationDialog(BuildContext context) async {
  21. bool shouldPop = false;
  22. await showDialog(
  23. context: context,
  24. builder: (context) => AlertDialog(
  25. surfaceTintColor: AppTheme.secondary,
  26. title: const Text('¿Cerrar sesión?'),
  27. content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
  28. actions: [
  29. TextButton(
  30. onPressed: () => Navigator.of(context).pop(false),
  31. child: const Text('Cancelar', style: TextStyle(color: Colors.red)),
  32. ),
  33. TextButton(
  34. onPressed: () {
  35. Navigator.pop(context);
  36. Navigator.pop(context);
  37. Provider.of<LoginViewModel>(context, listen: false).logOut();
  38. Navigator.of(context)
  39. .pushNamedAndRemoveUntil('main', (route) => false);
  40. },
  41. child: const Text('Aceptar'),
  42. ),
  43. ],
  44. ),
  45. );
  46. return shouldPop;
  47. }
  48. @override
  49. Widget build(BuildContext context) {
  50. String? nombre = Provider.of<LoginViewModel>(context).nombre.toString();
  51. String? correo = Provider.of<LoginViewModel>(context).correo.toString();
  52. //final avm = Provider.of<AdministracionViewModel>(context);
  53. //List<String> permisos = avm.lospermisos;
  54. return Drawer(
  55. surfaceTintColor: Colors.white,
  56. backgroundColor: Colors.white,
  57. child: Column(
  58. children: [
  59. Container(
  60. width: double.infinity,
  61. decoration: BoxDecoration(
  62. color: AppTheme.primary,
  63. ),
  64. padding: EdgeInsets.only(
  65. top: MediaQuery.of(context).padding.top,
  66. ),
  67. child: const Column(
  68. children: [
  69. Padding(
  70. padding: EdgeInsets.all(8.0),
  71. child: Image(
  72. image: AssetImage('assets/icono-BN.png'),
  73. height: 150,
  74. ),
  75. ),
  76. SizedBox(
  77. height: 10,
  78. ),
  79. SizedBox(
  80. height: 10,
  81. ),
  82. ],
  83. ),
  84. ),
  85. //HEADER
  86. Expanded(
  87. child: ListView(children: [
  88. // ListTile(
  89. // leading: circulo(const Icon(Icons.lunch_dining)),
  90. // title: const Text('Inicio'),
  91. // onTap: () => {
  92. // Navigator.pop(context),
  93. // Navigator.of(context).push(
  94. // MaterialPageRoute(
  95. // builder: (context) => const HomeScreen(),
  96. // ),
  97. // ),
  98. // },
  99. // ),
  100. ListTile(
  101. leading: circulo(const Icon(Icons.restaurant_menu)),
  102. title: const Text('Pedidos'),
  103. onTap: () => {
  104. Navigator.pop(context),
  105. Navigator.of(context).push(
  106. MaterialPageRoute(
  107. builder: (context) => const PedidoScreen(),
  108. ),
  109. ),
  110. },
  111. ),
  112. ListTile(
  113. leading: circulo(const Icon(Icons.restaurant_menu)),
  114. title: const Text('Pedidos Mesa'),
  115. onTap: () => {
  116. Navigator.pop(context),
  117. Navigator.of(context).push(
  118. MaterialPageRoute(
  119. builder: (context) => const PedidoMesaScreen(),
  120. ),
  121. ),
  122. },
  123. ),
  124. ListTile(
  125. leading: circulo(const Icon(Icons.menu_book_rounded)),
  126. title: const Text('Productos'),
  127. onTap: () => {
  128. Navigator.pop(context),
  129. Navigator.of(context).push(
  130. MaterialPageRoute(
  131. builder: (context) => ProductoScreen(),
  132. ),
  133. ),
  134. },
  135. ),
  136. ListTile(
  137. leading: circulo(const Icon(Icons.format_list_bulleted_rounded)),
  138. title: const Text('Categoría Producto'),
  139. onTap: () => {
  140. Navigator.pop(context),
  141. Navigator.of(context).push(
  142. MaterialPageRoute(
  143. builder: (context) => CategoriaProductoScreen(),
  144. ),
  145. ),
  146. },
  147. ),
  148. ListTile(
  149. leading: circulo(const Icon(Icons.receipt_long_outlined)),
  150. title: const Text('Pedidos Por Día'),
  151. onTap: () => {
  152. Navigator.pop(context),
  153. Navigator.of(context).push(
  154. MaterialPageRoute(
  155. builder: (context) => VentaScreen(),
  156. ),
  157. ),
  158. },
  159. ),
  160. ListTile(
  161. leading: circulo(const Icon(Icons.point_of_sale_rounded)),
  162. title: const Text('Corte De Caja'),
  163. onTap: () => {
  164. Navigator.pop(context),
  165. Navigator.of(context).push(
  166. MaterialPageRoute(
  167. builder: (context) => CorteCajaScreen(),
  168. ),
  169. ),
  170. },
  171. ),
  172. ExpansionTile(
  173. leading: circulo(const Icon(Icons.admin_panel_settings)),
  174. title: const Text('Administración'),
  175. children: [
  176. ListTile(
  177. leading: circulo(const Icon(Icons.discount)),
  178. title: const Text('Descuentos'),
  179. onTap: () => {
  180. Navigator.pop(context),
  181. Navigator.of(context).push(
  182. MaterialPageRoute(
  183. builder: (context) => DescuentoScreen(),
  184. ),
  185. ),
  186. },
  187. ),
  188. ListTile(
  189. leading: circulo(const Icon(Icons.discount)),
  190. title: const Text('Variables'),
  191. onTap: () => {
  192. Navigator.pop(context),
  193. Navigator.of(context).push(
  194. MaterialPageRoute(
  195. builder: (context) => VariablesScreen(),
  196. ),
  197. ),
  198. },
  199. ),
  200. ListTile(
  201. leading: circulo(const Icon(Icons.table_restaurant)),
  202. title: const Text('Mesas'),
  203. onTap: () => {
  204. Navigator.pop(context),
  205. Navigator.of(context).push(
  206. MaterialPageRoute(
  207. builder: (context) => MesasScreen(),
  208. ),
  209. ),
  210. },
  211. ),
  212. ],
  213. ),
  214. // ListTile(
  215. // leading: const Icon(Icons.logout),
  216. // title: const Text('Cerrar sesión'),
  217. // onTap: () {
  218. // _showExitConfirmationDialog(context);
  219. // },
  220. // ),
  221. ])),
  222. const Padding(
  223. padding: EdgeInsets.only(bottom: 10),
  224. child: Align(
  225. alignment: Alignment.bottomCenter,
  226. child: Text(
  227. 'v1.24.08.22',
  228. style: TextStyle(fontWeight: FontWeight.w300),
  229. ),
  230. ))
  231. ],
  232. ),
  233. );
  234. }
  235. }