import '../../Entity/angulardata/Test_visa/Test_visaView/Test_visa_entity_list_screen.dart';
import '../../Entity/angulardata/Test_visa/Test_visa_viewModel/Test_visa_view_model_screen.dart';

import '../../Entity/angulardata/Basicp/BasicpView/Basicp_entity_list_screen.dart';
import '../../Entity/angulardata/Basicp/Basicp_viewModel/Basicp_view_model_screen.dart';

import '../../Entity/angulardatatype/Ad8/Ad8View/Ad8_entity_list_screen.dart';
import '../../Entity/angulardatatype/Ad8/Ad8_viewModel/Ad8_view_model_screen.dart';

import '../../Entity/angulardatatype/Ad7/Ad7View/Ad7_entity_list_screen.dart';
import '../../Entity/angulardatatype/Ad7/Ad7_viewModel/Ad7_view_model_screen.dart';

import '../../Entity/angulardatatype/Adv5/Adv5View/Adv5_entity_list_screen.dart';
import '../../Entity/angulardatatype/Adv5/Adv5_viewModel/Adv5_view_model_screen.dart';

import '../../Entity/angulardatatype/Adv4/Adv4View/Adv4_entity_list_screen.dart';
import '../../Entity/angulardatatype/Adv4/Adv4_viewModel/Adv4_view_model_screen.dart';

import '../../Entity/angulardatatype/Adv3/Adv3View/Adv3_entity_list_screen.dart';
import '../../Entity/angulardatatype/Adv3/Adv3_viewModel/Adv3_view_model_screen.dart';

import '../../Entity/angulardatatype/Dv2/Dv2View/Dv2_entity_list_screen.dart';
import '../../Entity/angulardatatype/Dv2/Dv2_viewModel/Dv2_view_model_screen.dart';

import '../../Entity/angulardatatype/Adv1/Adv1View/Adv1_entity_list_screen.dart';
import '../../Entity/angulardatatype/Adv1/Adv1_viewModel/Adv1_view_model_screen.dart';

import '../../Entity/angulardatatype/Basicp3/Basicp3View/Basicp3_entity_list_screen.dart';
import '../../Entity/angulardatatype/Basicp3/Basicp3_viewModel/Basicp3_view_model_screen.dart';

import '../../Entity/angulardatatype/Basicp2/Basicp2View/Basicp2_entity_list_screen.dart';
import '../../Entity/angulardatatype/Basicp2/Basicp2_viewModel/Basicp2_view_model_screen.dart';

import '../../Entity/angulardatatype/Basicp1/Basicp1View/Basicp1_entity_list_screen.dart';
import '../../Entity/angulardatatype/Basicp1/Basicp1_viewModel/Basicp1_view_model_screen.dart';

import 'package:base_project/utils/image_constant.dart';
import 'package:base_project/commans/widgets/custome_drawe_item.dart';
import 'package:base_project/resources/app_colors.dart';
import 'package:base_project/routes/route_names.dart';
import 'package:base_project/utils/managers/user_manager.dart';
import 'package:base_project/view_model/profile/profile_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';

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

  @override
  Widget build(BuildContext context) {
    final email = UserManager().email;
    final userName = UserManager().userName;
    final provider = Provider.of<ProfileViewModel>(context, listen: false);
    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: <Widget>[
          UserAccountsDrawerHeader(
            decoration: const BoxDecoration(
              color: AppColors.primary,
            ),
            currentAccountPicture: CircleAvatar(
              radius: 60,
              backgroundColor: AppColors.primary.withOpacity(0.3),
              backgroundImage: provider.profileImageBytes != null
                  ? MemoryImage(provider.profileImageBytes!)
                  : null,
              child: provider.profileImageBytes != null
                  ? null // Use backgroundImage for the actual image, so child should be null
                  : SvgPicture.asset(
                      ImageConstant.userProfileImg, // Placeholder SVG asset

// AppImages.userProfileImg, // Placeholder SVG asset
                      width: 60, // Adjust to fit the CircleAvatar
                      height: 60,
                    ),
            ),
            accountName: Text("Hello, $userName"),
            accountEmail: Text(email.toString()),
          ),
          DrawerItem(
            color: AppColors.primary,
            icon: Icons.person,
            title: 'Profile',
            onTap: () {
              Navigator.pushNamed(context, RouteNames.profileView);
            },
          ),
          DrawerItem(
            color: AppColors.primary,
            icon: Icons.system_security_update,
            title: 'System Parameters',
            onTap: () {
// Add navigation or other logic here
              Navigator.pushNamed(context, RouteNames.systemParamsView);
            },
          ),
          DrawerItem(
            color: AppColors.primary,
            icon: Icons.password,
            title: 'change password',
            onTap: () {
              Navigator.pushNamed(context, RouteNames.changePasswordView);
            },
          ),

// NEW MENU

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Test_visa',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Test_visaViewModelScreen(),
                    child: test_visa_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Basicp',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => BasicpViewModelScreen(),
                    child: basicp_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Ad8',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Ad8ViewModelScreen(),
                    child: ad8_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Ad7',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Ad7ViewModelScreen(),
                    child: ad7_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Adv5',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Adv5ViewModelScreen(),
                    child: adv5_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Adv4',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Adv4ViewModelScreen(),
                    child: adv4_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Adv3',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Adv3ViewModelScreen(),
                    child: adv3_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Dv2',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Dv2ViewModelScreen(),
                    child: dv2_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Adv1',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Adv1ViewModelScreen(),
                    child: adv1_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Basicp3',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Basicp3ViewModelScreen(),
                    child: basicp3_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Basicp2',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Basicp2ViewModelScreen(),
                    child: basicp2_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            color: AppColors.primary,
            icon: Icons.chat_bubble,
            title: 'Basicp1',
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChangeNotifierProvider(
                    create: (context) => Basicp1ViewModelScreen(),
                    child: basicp_entity_list_screen(),
                  ),
                ),
              );
            },
          ),

          DrawerItem(
            icon: Icons.logout,
            color: Colors.red,
            title: 'Logout',
            onTap: () async {
              await UserManager().clearUser();
              Navigator.pushReplacementNamed(context, RouteNames.splashView);
            },
          ),
        ],
      ),
    );
  }
}
