import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:web_panel/utils/spacing.dart';

import '../utils/App_color.dart';

appPopUp({
  required BuildContext context,
  required String titleImage,
  required String titleText,
  required String buttonText,
  required Function()? onTap,
  required Widget popContent,
}) {
  return showDialog(
    context: context,
    builder: (context) {

      return AlertDialog(
        backgroundColor: Color(0xff1F2937),
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              spacing: 2.sp,
              children: [
                Image.asset(titleImage, height: 22, width: 22),
                Text(
                  titleText,
                  style: Theme.of(context).textTheme.titleLarge?.copyWith(
                    color: Colors.white,
                    fontWeight: FontWeight.w700,
                  ),
                ),
              ],
            ),
            Spacing.height(5),
            popContent,
            Spacing.height(5),
            Row(
              spacing: 4.sp,
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                GestureDetector(
                  onTap: () {
                    Navigator.pop(context);
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(
                      horizontal: 3.sp,
                      vertical: 1.sp,
                    ),
                    decoration: BoxDecoration(
                      color: AppColor.buttonColor,

                      // border: Border.all(
                      //   color: AppColor.warning,
                      //   width: 1.5,
                      // ),
                      borderRadius: BorderRadius.circular(1.5.sp),
                    ),
                    child: Text(
                      'Cancel',
                      style: Theme.of(context).textTheme.titleSmall?.copyWith(
                        color: Colors.white,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: onTap,
                  child: Container(
                    padding: EdgeInsets.symmetric(
                      horizontal: 3.sp,
                      vertical: 1.sp,
                    ),
                    decoration: BoxDecoration(
                      color: AppColor.primaryColor,

                      // border: Border.all(
                      //   color: AppColor.warning,
                      //   width: 1.5,
                      // ),
                      borderRadius: BorderRadius.circular(1.5.sp),
                    ),
                    child: Text(
                      buttonText,
                      style: Theme.of(context).textTheme.titleSmall?.copyWith(
                        color: Colors.white,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      );
    },
  );
}
