app_drawer.dart 6.7 KB

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