123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- // ignore_for_file: must_be_immutable
- import 'package:flutter/material.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 '../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<bool> _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<LoginViewModel>(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<LoginViewModel>(context).nombre.toString();
- String? correo = Provider.of<LoginViewModel>(context).correo.toString();
- //final avm = Provider.of<AdministracionViewModel>(context);
- //List<String> 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: Column(
- children: [
- const Padding(
- padding: EdgeInsets.all(8.0),
- child: Image(
- image: AssetImage('assets/JoshiLogoHorizontal.png'),
- height: 150,
- ),
- ),
- const 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,
- ),
- ),
- const 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: circulo(const Icon(Icons.table_bar)),
- title: const Text('Mesas'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.local_cafe)),
- title: const Text('Productos'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.format_list_bulleted)),
- title: const Text('Caregorías de Producto'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const CategoriaProductoScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading:
- circulo(const Icon(Icons.switch_access_shortcut_add_sharp)),
- title: const Text('Topings'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.format_list_bulleted)),
- title: const Text('Categorías de Toping'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.discount)),
- title: const Text('Promociones'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.photo)),
- title: const Text('Contenidos Web'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.storefront)),
- title: const Text('Sucursales'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.groups)),
- title: const Text('Clientes'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.credit_card_rounded)),
- title: const Text('Tarjetas'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ListTile(
- leading: circulo(const Icon(Icons.point_of_sale)),
- title: const Text('Ventas'),
- onTap: () => {
- Navigator.pop(context),
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => const HomeScreen(),
- ),
- ),
- },
- ),
- ExpansionTile(
- leading: circulo(const Icon(Icons.circle)),
- title: const Text("ADMINISTRACIÓN"),
- childrenPadding: const EdgeInsets.only(left: 8),
- children: [
- ListTile(
- leading: circulo(const Icon(Icons.person_add_alt)),
- title: const Text('USUARIOS'),
- onTap: () => {
- Navigator.pop(context),
- // Navigator.of(context).push(
- // MaterialPageRoute(
- // builder: (context) => const UsuariosScreen(),
- // ),
- // ),
- },
- ),
- ]),
- ListTile(
- leading: const Icon(Icons.person),
- title: const Text('PERFIL'),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => const PerfilScreen()));
- },
- ),
- ListTile(
- leading: const Icon(Icons.logout),
- title: const Text('Cerrar sesión'),
- onTap: () {
- _showExitConfirmationDialog(context);
- },
- ),
- ]))
- ],
- ),
- );
- }
- }
|