import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:tp5/ftl/view/ftl_page.dart';
import 'package:tp5/lido/view/lidolist_page.dart';

class NavDrawer extends StatelessWidget {
  const NavDrawer({super.key});

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: <Widget>[
          const DrawerHeader(
            decoration: BoxDecoration(
              color: Colors.black54,
              image: DecorationImage(
                alignment: Alignment.bottomRight,
                fit: BoxFit.fitHeight,
                scale: 0.5,
                image: AssetImage('assets/logo.png'),
              ),
            ),
            child: Text(
              'Menu',
              style: TextStyle(color: Colors.white, fontSize: 25),
            ),
          ),
          ListTile(
            leading: const Icon(Icons.input),
            title: const Text('Crewlink Roster'),
            onTap: () => context.go("/crewlink/roster"),
          ),
          ListTile(
            leading: const Icon(Icons.verified_user),
            title: const Text('Crewlink Crewlist'),
            onTap: () => context.go("/crewlink/crewlist"),
          ),
          ListTile(
            leading: const Icon(Icons.verified_user),
            title: const Text('Flight Time Limitations'),
            onTap: () => context.go("/ftl",
                extra: const FtlPageParams(
                    /*datestart: "01Nov23", dateend: "30Nov23"*/)),
          ),
          ListTile(
            leading: const Icon(Icons.verified_user),
            title: const Text('Lido'),
            onTap: () => context.go("/lido/list",
                extra: const LidolistPageParams(
                    /*datestart: "01Nov23", dateend: "30Nov23"*/)),
          ),
          ListTile(
              leading: const Icon(Icons.verified_user),
              title: const Text('Rosters'),
              onTap: () => context.go("/rosters")),
          ListTile(
              leading: const Icon(Icons.verified_user),
              title: const Text('Fligths List'),
              onTap: () => context.go("/flightslist")),
          ListTile(
            leading: const Icon(Icons.settings),
            title: const Text('Settings'),
            onTap: () => context.go("/settings"),
          ),
          ListTile(
            leading: const Icon(Icons.border_color),
            title: const Text('Feedback'),
            onTap: () => {Navigator.of(context).pop()},
          ),
          ListTile(
            leading: const Icon(Icons.border_color),
            title: const Text('Test'),
            onTap: () => context.go('/test'),
          ),
          ListTile(
            leading: const Icon(Icons.exit_to_app),
            title: const Text('Logout'),
            onTap: () async {
              await Supabase.instance.client.auth.signOut();
              if (context.mounted) {
                context.go('/login-otp');
              }
            },
          ),
        ],
      ),
    );
  }
}
