app_drawer.dart 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // ignore_for_file: must_be_immutable
  2. import 'package:flutter/material.dart';
  3. import 'package:yoshi_papas_app/views/categoria_producto/categoria_producto_screen.dart';
  4. import 'package:yoshi_papas_app/views/pedido/pedido_screen.dart';
  5. import 'package:yoshi_papas_app/views/producto/producto_screen.dart';
  6. import 'package:yoshi_papas_app/views/sucursal/sucursal_screen.dart';
  7. import 'package:yoshi_papas_app/views/variable/variable_screen.dart';
  8. import 'package:yoshi_papas_app/views/venta/venta_screen.dart';
  9. import 'package:provider/provider.dart';
  10. import '../themes/themes.dart';
  11. import '../viewmodels/login_view_model.dart';
  12. import '../views/descuento/descuento_screen.dart';
  13. import 'widgets_components.dart';
  14. class AppDrawer extends StatelessWidget {
  15. AppDrawer({super.key});
  16. Future<bool> _showExitConfirmationDialog(BuildContext context) async {
  17. bool shouldPop = false;
  18. await showDialog(
  19. context: context,
  20. builder: (context) => AlertDialog(
  21. surfaceTintColor: AppTheme.secondary,
  22. title: const Text('¿Cerrar sesión?'),
  23. content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
  24. actions: [
  25. TextButton(
  26. onPressed: () => Navigator.of(context).pop(false),
  27. child: const Text('Cancelar', style: TextStyle(color: Colors.red)),
  28. ),
  29. TextButton(
  30. onPressed: () {
  31. Navigator.pop(context);
  32. Navigator.pop(context);
  33. Provider.of<LoginViewModel>(context, listen: false).logOut();
  34. Navigator.of(context)
  35. .pushNamedAndRemoveUntil('main', (route) => false);
  36. },
  37. child: const Text('Aceptar'),
  38. ),
  39. ],
  40. ),
  41. );
  42. return shouldPop;
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. return Drawer(
  47. surfaceTintColor: Colors.white,
  48. backgroundColor: Colors.white,
  49. child: Column(
  50. children: [
  51. Container(
  52. width: double.infinity,
  53. decoration: BoxDecoration(
  54. color: AppTheme.primary,
  55. ),
  56. padding: EdgeInsets.only(
  57. top: MediaQuery.of(context).padding.top,
  58. ),
  59. child: const Column(
  60. children: [
  61. Padding(
  62. padding: EdgeInsets.all(8.0),
  63. child: Image(
  64. image: AssetImage('assets/JoshiLogoHorizontal.png'),
  65. height: 150,
  66. ),
  67. ),
  68. SizedBox(
  69. height: 10,
  70. ),
  71. SizedBox(
  72. height: 10,
  73. ),
  74. ],
  75. ),
  76. ),
  77. // HEADER
  78. Expanded(
  79. child: ListView(
  80. children: [
  81. ListTile(
  82. leading: circulo(const Icon(Icons.restaurant_menu)),
  83. title: const Text('Pedidos'),
  84. onTap: () => {
  85. Navigator.pop(context),
  86. Navigator.of(context).push(
  87. MaterialPageRoute(
  88. builder: (context) => const PedidoScreen(),
  89. ),
  90. ),
  91. },
  92. ),
  93. ListTile(
  94. leading: circulo(const Icon(Icons.menu_book_rounded)),
  95. title: const Text('Productos'),
  96. onTap: () => {
  97. Navigator.pop(context),
  98. Navigator.of(context).push(
  99. MaterialPageRoute(
  100. builder: (context) => ProductoScreen(),
  101. ),
  102. ),
  103. },
  104. ),
  105. ListTile(
  106. leading:
  107. circulo(const Icon(Icons.format_list_bulleted_rounded)),
  108. title: const Text('Categoría Producto'),
  109. onTap: () => {
  110. Navigator.pop(context),
  111. Navigator.of(context).push(
  112. MaterialPageRoute(
  113. builder: (context) => CategoriaProductoScreen(),
  114. ),
  115. ),
  116. },
  117. ),
  118. ListTile(
  119. leading: circulo(const Icon(Icons.receipt_long_outlined)),
  120. title: const Text('Pedidos Por Día'),
  121. onTap: () => {
  122. Navigator.pop(context),
  123. Navigator.of(context).push(
  124. MaterialPageRoute(
  125. builder: (context) => VentaScreen(),
  126. ),
  127. ),
  128. },
  129. ),
  130. ExpansionTile(
  131. leading: circulo(const Icon(Icons.admin_panel_settings)),
  132. title: const Text('Administración'),
  133. children: [
  134. ListTile(
  135. leading: circulo(const Icon(Icons.discount)),
  136. title: const Text('Descuentos'),
  137. onTap: () => {
  138. Navigator.pop(context),
  139. Navigator.of(context).push(
  140. MaterialPageRoute(
  141. builder: (context) => DescuentoScreen(),
  142. ),
  143. ),
  144. },
  145. ),
  146. ListTile(
  147. leading: circulo(const Icon(Icons.discount)),
  148. title: const Text('Variables'),
  149. onTap: () => {
  150. Navigator.pop(context),
  151. Navigator.of(context).push(
  152. MaterialPageRoute(
  153. builder: (context) => VariablesScreen(),
  154. ),
  155. ),
  156. },
  157. ),
  158. ListTile(
  159. leading: circulo(const Icon(Icons.storefront_outlined)),
  160. title: const Text('Sucursales'),
  161. onTap: () => {
  162. Navigator.pop(context),
  163. Navigator.of(context).push(
  164. MaterialPageRoute(
  165. builder: (context) => SucursalesPage(),
  166. ),
  167. ),
  168. },
  169. ),
  170. ],
  171. ),
  172. ],
  173. ),
  174. ),
  175. Padding(
  176. padding: const EdgeInsets.only(bottom: 10),
  177. child: Align(
  178. alignment: Alignment.bottomCenter,
  179. child: Text(
  180. 'v1.24.10.09+1',
  181. style: const TextStyle(fontWeight: FontWeight.w300),
  182. ),
  183. ),
  184. ),
  185. ],
  186. ),
  187. );
  188. }
  189. }