app_drawer.dart 8.7 KB

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