app_drawer.dart 7.7 KB

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