import 'package:adaptix/adaptix.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:sapaly_shop/features/screens/category/category_screen.dart';
import 'package:sapaly_shop/features/screens/drawer/contacts.dart';
import 'package:sapaly_shop/features/screens/drawer/new_arrival.dart';
import 'package:sapaly_shop/features/screens/drawer/sales.dart';
import 'package:sapaly_shop/features/screens/drawer/shops.dart';
import 'package:url_launcher/url_launcher_string.dart';

import '../../../constants/global_variables.dart';
import '../../../themes/app_theme.dart';
import 'about_us.dart';

class SapalyDrawer extends StatelessWidget {
  SapalyDrawer({super.key});

  List<String> icons = [
    'assets/icons/drawerIcons/category.svg',
    'assets/icons/drawerIcons/info.svg',
    'assets/icons/drawerIcons/sale.svg',
    'assets/icons/drawerIcons/car.svg',
    'assets/icons/drawerIcons/shops.svg',
    'assets/icons/drawerIcons/mail.svg',
  ];

  List<String> iconNames = [
    'Categories',
    'About us',
    'Sales',
    'New arrival',
    'Shops',
    'Contacts',
  ];

  List<Widget> routes = [
    const CategoryScreen(),
    const AboutUsScreen(),
    const SalesScreen(),
    const NewArrivalScreen(),
    const ShopsScreen(),
    const ContactsScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Drawer(
      backgroundColor: AppTheme.whiteColor,
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal: 15.adaptedPx()),
        child: Column(
          children: [
            DrawerHeader(
              padding: EdgeInsets.zero,
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/sapalyLogo.png',
                    width: 60.adaptedPx(),
                    height: 60.adaptedPx(),
                  ),
                  SizedBox(width: 10.adaptedPx()),
                  Text(
                    GlobalVariables.kAppName,
                    style: GoogleFonts.poppins(
                      textStyle: Theme.of(context)
                          .primaryTextTheme
                          .bodyMedium!
                          .copyWith(
                            fontWeight: FontWeight.w600,
                            fontSize: 18.adaptedPx(),
                            color: AppTheme.blackColor,
                          ),
                    ),
                  ),
                ],
              ),
            ),
            Row(
              children: [
                Icon(
                  Icons.account_circle,
                  size: 35.adaptedPx(),
                  color: AppTheme.lightPrimaryColor,
                ),
                SizedBox(width: 10.adaptedPx()),
                Text(
                  'Aman Amanow',
                  softWrap: true,
                  maxLines: 2,
                  style:
                      Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
                            fontWeight: FontWeight.w600,
                            color: AppTheme.blackColor,
                            fontSize: 14.adaptedPx(),
                          ),
                ),
                IconButton(
                  onPressed: () {},
                  color: AppTheme.lightPrimaryColor,
                  icon: const Icon(Icons.sports_baseball_outlined),
                ),
                Text(
                  'En',
                  style:
                      Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
                            fontWeight: FontWeight.w500,
                            color: AppTheme.blackColor,
                            fontSize: 16.adaptedPx(),
                          ),
                ),
              ],
            ),
            ListView.builder(
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              itemCount: icons.length,
              scrollDirection: Axis.vertical,
              itemBuilder: (context, index) {
                return TextButton(
                  style: TextButton.styleFrom(
                    padding: EdgeInsets.symmetric(
                      vertical: GlobalVariables.verticalPadding(context) / 2,
                      horizontal:
                          GlobalVariables.horizontalPadding(context) / 2,
                    ),
                  ),
                  onPressed: () {
                    Navigator.of(context).push(
                        MaterialPageRoute(builder: (context) => routes[index]));
                  },
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SvgPicture.asset(
                        icons[index],
                        color: AppTheme.lightPrimaryColor,
                      ),
                      SizedBox(width: 10.adaptedPx()),
                      Text(
                        iconNames[index],
                        style: Theme.of(context)
                            .primaryTextTheme
                            .bodyMedium
                            ?.copyWith(
                              fontWeight: FontWeight.w500,
                              color: AppTheme.blackColor,
                              fontSize: 16.adaptedPx(),
                            ),
                      ),
                    ],
                  ),
                );
              },
            ),
            const Spacer(),
            TextButton(
              onPressed: () {
                launchUrlString('tel://+99363508564');
                Navigator.of(context).pop();
              },
              child: Row(
                children: [
                  const Icon(Icons.call_outlined),
                  SizedBox(width: 15.adaptedPx()),
                  Text(
                    '+993 63 508564',
                    style:
                        Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
                              fontWeight: FontWeight.w500,
                              color: AppTheme.blackColor,
                              fontSize: 17.adaptedPx(),
                            ),
                  )
                ],
              ),
            ),
            TextButton(
              child: Row(
                children: [
                  const Icon(Icons.call_outlined),
                  SizedBox(width: 15.adaptedPx()),
                  Text(
                    '+993 12 973168',
                    style:
                        Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
                              fontWeight: FontWeight.w500,
                              color: AppTheme.blackColor,
                              fontSize: 17.adaptedPx(),
                            ),
                  )
                ],
              ),
              onPressed: () {
                launchUrlString('tel://+99312973168');
                Navigator.of(context).pop();
              },
            ),
            SizedBox(height: 20.adaptedPx()),
          ],
        ),
      ),
    );
  }
}
