import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gap/gap.dart';

import '../../core/routes/route_name.dart';
import '../../core/routes/routes.dart';
import '../../core/styles/app_color.dart';
import '../../core/styles/app_text.dart';
import '../../core/utils/secure/secure_storage_service.dart';
import 'bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
import 'bloc/bottom_nav_bar/bottom_navigation_event.dart';
import 'text_widget.dart';

buildprofilelogoutdialog(context) {
  SecureStorageService secureStorageService = SecureStorageService();
  return showDialog(
    context: context,
    builder: (context) => Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        AlertDialog(
          insetPadding: const EdgeInsets.symmetric(horizontal: 16),
          backgroundColor: AppColor.plainWhite,
          shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(20)),
            side: BorderSide(
              color: AppColor.plainWhite,
            ),
          ),
          content: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Align(
                alignment: Alignment.center,
                child: CircleAvatar(
                  radius: 25,
                  backgroundColor: AppColor.inactiveBtnColor,
                  child: Center(
                    child: Icon(
                      Icons.logout_rounded,
                      color: AppColor.primaryColor,
                      size: 30,
                    ),
                  ),
                ),
              ),
              Gap(15.h),
              Align(
                alignment: Alignment.center,
                child: Container(
                  margin: const EdgeInsets.symmetric(horizontal: 20),
                  child: TextWidget().text17W700(
                    AppText.areYouSureWantToLogoutText,
                    clr: AppColor.textLabelColor,
                  ),
                ),
              ),
              Gap(21.h),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  GestureDetector(
                    onTap: () {
                      goRouter.pop();
                    },
                    child: Container(
                      height: 48.h,
                      width: 140.w,
                      decoration: BoxDecoration(
                          border: Border.all(
                            color: AppColor.primaryColor2,
                          ),
                          borderRadius: BorderRadius.circular(10.h),
                          color: AppColor.plainWhite),
                      child: Center(
                        child: TextWidget().text18W700(
                          AppText.noText,
                          clr: AppColor.primaryColor2,
                        ),
                      ),
                    ),
                  ),
                  Gap(28.w),
                  GestureDetector(
                    onTap: () async {
                      context.read<BottomNavigationBloc>().add(TabChanged(1));
                      await secureStorageService.write('isLoginedIn', "false");
                      goRouter.goNamed(RouteName.loginScreen, pathParameters: {
                        "fromScreen": "registerStep",
                      });
                    },
                    child: Container(
                      height: 48.h,
                      width: 140.w,
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(10.h),
                          color: AppColor.primaryColor),
                      child: Center(
                        child: TextWidget().text18W700(
                          AppText.yesText,
                          clr: AppColor.plainWhite,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ],
    ),
  );
}
