app_drawer.dart 6.2 KB

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