import 'package:flutter/material.dart';
import 'package:tour_travel_agr/helper/components_widget/widget_button.dart';
import 'package:tour_travel_agr/resource/font.dart';
import 'package:tour_travel_agr/resource/style.dart';

Future<dynamic> modalDialogGlobal({
  required BuildContext context,
  Size? size,
  required String title,
  required String contentBody,
  required String buttonText,
  required void Function() tapButton,
  bool isActiveCancelButton = false,
  bool isCustomSecondButton = false,
  String customSecondButtonText = '',
  Widget? navigateToCustomButton,
}) async {
  return showDialog(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext ctxDialog) => AlertDialog(
      shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(15))),
      content: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            style: getBoldStyle(
              color: Colors.black,
              fontFamily: FontConstants.inter,
              fontSize: FontSize.s24,
            ),
          ),
          const SizedBox(
            height: 16,
          ),
          Text(
            contentBody,
            style: getMediumStyle(
              color: Colors.black,
              fontFamily: FontConstants.openSans,
              fontSize: FontSize.s16,
            ),
          ),
          const SizedBox(
            height: 42,
          ),
          InkWell(
            onTap: () {
              tapButton();
            },
            child: CustomButton(
              text: buttonText,
            ),
          ),
          (isActiveCancelButton)
              ? InkWell(
                  onTap: () {
                    Navigator.pop(context);
                  },
                  child: const CustomButton(
                    text: "Cancel",
                    colorButton: Colors.transparent,
                    colorText: Colors.black,
                  ),
                )
              : const SizedBox(),
          (isCustomSecondButton)
              ? Column(
                  children: [
                    const SizedBox(
                      height: 10,
                    ),
                    InkWell(
                      onTap: () {
                        Navigator.pop(context);
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                              builder: (_) => navigateToCustomButton!),
                        );
                      },
                      child: CustomButton(
                        text: customSecondButtonText,
                      ),
                    ),
                  ],
                )
              : const SizedBox()
        ],
      ),
    ),
  );
}
