app_drawer.dart 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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/pedido/pedido_screen.dart';
  6. import 'package:conalep_pos/views/producto/producto_screen.dart';
  7. import 'package:conalep_pos/views/venta/venta_screen.dart';
  8. import 'package:flutter/material.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 '../views/descuento/descuento_screen.dart';
  14. import '../views/variable/variable_screen.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: const Column(
  66. children: [
  67. Padding(
  68. padding: EdgeInsets.all(8.0),
  69. child: Image(
  70. image: AssetImage('assets/icono-BN.png'),
  71. height: 150,
  72. ),
  73. ),
  74. SizedBox(
  75. height: 10,
  76. ),
  77. SizedBox(
  78. height: 10,
  79. ),
  80. ],
  81. ),
  82. ),
  83. //HEADER
  84. Expanded(
  85. child: ListView(children: [
  86. // ListTile(
  87. // leading: circulo(const Icon(Icons.lunch_dining)),
  88. // title: const Text('Inicio'),
  89. // onTap: () => {
  90. // Navigator.pop(context),
  91. // Navigator.of(context).push(
  92. // MaterialPageRoute(
  93. // builder: (context) => const HomeScreen(),
  94. // ),
  95. // ),
  96. // },
  97. // ),
  98. ListTile(
  99. leading: circulo(const Icon(Icons.restaurant_menu)),
  100. title: const Text('Pedidos'),
  101. onTap: () => {
  102. Navigator.pop(context),
  103. Navigator.of(context).push(
  104. MaterialPageRoute(
  105. builder: (context) => const PedidoScreen(),
  106. ),
  107. ),
  108. },
  109. ),
  110. ListTile(
  111. leading: circulo(const Icon(Icons.menu_book_rounded)),
  112. title: const Text('Productos'),
  113. onTap: () => {
  114. Navigator.pop(context),
  115. Navigator.of(context).push(
  116. MaterialPageRoute(
  117. builder: (context) => ProductoScreen(),
  118. ),
  119. ),
  120. },
  121. ),
  122. ListTile(
  123. leading: circulo(const Icon(Icons.format_list_bulleted_rounded)),
  124. title: const Text('Categoría Producto'),
  125. onTap: () => {
  126. Navigator.pop(context),
  127. Navigator.of(context).push(
  128. MaterialPageRoute(
  129. builder: (context) => CategoriaProductoScreen(),
  130. ),
  131. ),
  132. },
  133. ),
  134. ListTile(
  135. leading: circulo(const Icon(Icons.receipt_long_outlined)),
  136. title: const Text('Pedidos Por Día'),
  137. onTap: () => {
  138. Navigator.pop(context),
  139. Navigator.of(context).push(
  140. MaterialPageRoute(
  141. builder: (context) => VentaScreen(),
  142. ),
  143. ),
  144. },
  145. ),
  146. // ListTile(
  147. // leading: circulo(const Icon(Icons.point_of_sale_rounded)),
  148. // title: const Text('Corte De Caja'),
  149. // onTap: () => {
  150. // Navigator.pop(context),
  151. // Navigator.of(context).push(
  152. // MaterialPageRoute(
  153. // builder: (context) => CorteCajaScreen(),
  154. // ),
  155. // ),
  156. // },
  157. // ),
  158. ExpansionTile(
  159. leading: circulo(const Icon(Icons.admin_panel_settings)),
  160. title: const Text('Administración'),
  161. children: [
  162. ListTile(
  163. leading: circulo(const Icon(Icons.discount)),
  164. title: const Text('Descuentos'),
  165. onTap: () => {
  166. Navigator.pop(context),
  167. Navigator.of(context).push(
  168. MaterialPageRoute(
  169. builder: (context) => DescuentoScreen(),
  170. ),
  171. ),
  172. },
  173. ),
  174. ListTile(
  175. leading: circulo(const Icon(Icons.discount)),
  176. title: const Text('Variables'),
  177. onTap: () => {
  178. Navigator.pop(context),
  179. Navigator.of(context).push(
  180. MaterialPageRoute(
  181. builder: (context) => VariablesScreen(),
  182. ),
  183. ),
  184. },
  185. ),
  186. ],
  187. ),
  188. // ListTile(
  189. // leading: const Icon(Icons.logout),
  190. // title: const Text('Cerrar sesión'),
  191. // onTap: () {
  192. // _showExitConfirmationDialog(context);
  193. // },
  194. // ),
  195. ])),
  196. const Padding(
  197. padding: EdgeInsets.only(bottom: 10),
  198. child: Align(
  199. alignment: Alignment.bottomCenter,
  200. child: Text(
  201. 'v1.24.08.27',
  202. style: TextStyle(fontWeight: FontWeight.w300),
  203. ),
  204. ))
  205. ],
  206. ),
  207. );
  208. }
  209. }