// ignore_for_file: must_be_immutable import 'package:flutter/material.dart'; import 'package:yoshi_papas_app/models/models.dart'; import 'package:yoshi_papas_app/views/categoria_producto/categoria_producto_screen.dart'; import 'package:yoshi_papas_app/views/home/home_screen.dart'; import 'package:yoshi_papas_app/views/perfil/perfil_screen.dart'; import 'package:yoshi_papas_app/views/pedido/pedido_screen.dart'; import 'package:yoshi_papas_app/views/producto/producto_screen.dart'; import 'package:yoshi_papas_app/views/toping/toping_screen.dart'; import 'package:yoshi_papas_app/views/toping_categoria/toping_categoria_screen.dart'; import '../models/usuario_model.dart'; import 'package:provider/provider.dart'; import '../themes/themes.dart'; import '../viewmodels/login_view_model.dart'; import 'widgets_components.dart'; class AppDrawer extends StatelessWidget { AppDrawer({super.key}); Future _showExitConfirmationDialog(BuildContext context) async { bool shouldPop = false; await showDialog( context: context, builder: (context) => AlertDialog( surfaceTintColor: AppTheme.secondary, title: const Text('¿Cerrar sesión?'), content: const Text('¿Estás seguro de que quieres cerrar la sesión?'), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(false), child: const Text('Cancelar', style: TextStyle(color: Colors.red)), ), TextButton( onPressed: () { Navigator.pop(context); Navigator.pop(context); Provider.of(context, listen: false).logOut(); Navigator.of(context) .pushNamedAndRemoveUntil('main', (route) => false); }, child: const Text('Aceptar'), ), ], ), ); return shouldPop; } @override Widget build(BuildContext context) { String? nombre = Provider.of(context).nombre.toString(); String? correo = Provider.of(context).correo.toString(); //final avm = Provider.of(context); //List permisos = avm.lospermisos; return Drawer( surfaceTintColor: Colors.white, backgroundColor: Colors.white, child: Column( children: [ Container( width: double.infinity, decoration: BoxDecoration( color: AppTheme.primary, ), padding: EdgeInsets.only( top: MediaQuery.of(context).padding.top, ), child: const Column( children: [ Padding( padding: EdgeInsets.all(8.0), child: Image( image: AssetImage('assets/JoshiLogoHorizontal.png'), height: 150, ), ), SizedBox( height: 10, ), // Text( // nombre.toString(), // style: const TextStyle( // fontSize: 18, // fontWeight: FontWeight.bold, // ), // ), // const SizedBox( // height: 10, // ), // Text( // correo.toString(), // style: const TextStyle( // fontSize: 15, // fontWeight: FontWeight.bold, // ), // ), SizedBox( height: 10, ), ], ), ), //HEADER Expanded( child: ListView(children: [ // ListTile( // leading: circulo(const Icon(Icons.lunch_dining)), // title: const Text('Inicio'), // onTap: () => { // Navigator.pop(context), // Navigator.of(context).push( // MaterialPageRoute( // builder: (context) => const HomeScreen(), // ), // ), // }, // ), ListTile( leading: circulo(const Icon(Icons.restaurant_menu)), title: const Text('Pedidos'), onTap: () => { Navigator.pop(context), Navigator.of(context).push( MaterialPageRoute( builder: (context) => const PedidoScreen(), ), ), }, ), ListTile( leading: const Icon(Icons.logout), title: const Text('Cerrar sesión'), onTap: () { _showExitConfirmationDialog(context); }, ), ])) ], ), ); } }