import 'package:flutter/material.dart';
import 'dialog_image_double_button_alert_design_model.dart';
import 'dialog_standard_container.dart';

class DialogImageDoubleButtonAlertSpaceConfig {
  final double? mainTitleTopSpace;
  final double? subTitleTopSpace;
  final double? imageTopSpace;
  final double? contentTopSpace;
  final double? mainButtonTopSpace;
  final double? subButtonTopSpace;
  final double? subButtonBottomSpace;
  DialogImageDoubleButtonAlertSpaceConfig({
    this.mainTitleTopSpace,
    this.subTitleTopSpace,
    this.imageTopSpace,
    this.contentTopSpace,
    this.mainButtonTopSpace,
    this.subButtonTopSpace,
    this.subButtonBottomSpace,
  });
}

class DialogImageDoubleButtonAlertWidget extends StatelessWidget {
  final Color? backgroundColor;
  final String mainTitle;
  final TextStyle? mainTitleTextStyle;
  final Color? mainTitleColor;
  final double? mainTitleFontSize;

  final String subTitle;
  final TextStyle? subTitleTextStyle;
  final Color? subTitleColor;
  final double? subTitleFontSize;

  final Image image;
  final String descriptionText;
  final TextStyle? descriptionTextStyle;
  final Color? descriptionColor;
  final double? descriptionFontSize;
  final double? descriptionTextHeight;

  final Color? upButtonBackgroundColor;
  final Image? upButtonImage;
  final String upButtonText;

  final TextStyle? upButtonTextStyle;
  final Color? upButtonTextColor;
  final double? upButtonTextFontSize;
  final VoidCallback? upButtonCallback;

  final String downButtonText;
  final TextStyle? downButtonTextStyle;
  final Color? downButtonTextColor;
  final double? downButtonTextFontSize;
  final VoidCallback? downButtonCallback;

  final Image? closeImage;
  final VoidCallback? closeCallback;
  final DialogImageDoubleButtonAlertSpaceConfig? spaceConfig;
  const DialogImageDoubleButtonAlertWidget({
    Key? key,
    required this.mainTitle,
    this.mainTitleTextStyle,
    this.mainTitleColor,
    this.mainTitleFontSize,
    required this.subTitle,
    this.subTitleTextStyle,
    required this.image,
    required this.descriptionText,
    this.descriptionTextStyle,
    this.backgroundColor,
    this.closeImage,
    this.closeCallback,
    this.upButtonBackgroundColor,
    this.upButtonTextStyle,
    this.upButtonCallback,
    this.downButtonTextStyle,
    this.downButtonCallback,
    required this.upButtonText,
    this.upButtonImage,
    required this.downButtonText,
    this.subTitleColor,
    this.subTitleFontSize,
    this.descriptionColor,
    this.descriptionFontSize,
    this.descriptionTextHeight,
    this.upButtonTextColor,
    this.upButtonTextFontSize,
    this.downButtonTextColor,
    this.downButtonTextFontSize,
    this.spaceConfig,
  }) : super(key: key);

  DialogImageDoubleButtonAlertDesignSpec get designSpec => DialogImageDoubleButtonAlertDesignSpec.get();
  DialogImageDoubleButtonAlertContentDesignSpec get contentSpec => designSpec.contentSpec;

  @override
  Widget build(BuildContext context) {
    return DialogStandardContainer(
      backgroundColor: backgroundColor,
      closeImage: closeImage,
      closeCallback: closeCallback,
      showCloseImage: true,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Padding(
            padding: spaceConfig?.mainTitleTopSpace != null
                ? EdgeInsets.only(
                    top: spaceConfig!.mainTitleTopSpace!, left: contentSpec.mainTitleInsets.left, right: contentSpec.mainTitleInsets.right)
                : contentSpec.mainTitleInsets,
            child: Text(
              mainTitle,
              style: mainTitleTextStyle ??
                  TextStyle(
                      fontSize: mainTitleFontSize ?? contentSpec.mainTitleFontSize,
                      color: mainTitleColor ?? const Color(0xff000000),
                      fontWeight: FontWeight.w700),
            ),
          ),
          Padding(
            padding: spaceConfig?.subButtonTopSpace != null
                ? EdgeInsets.only(
                    top: spaceConfig!.subButtonTopSpace!, left: contentSpec.subTitleInsets.left, right: contentSpec.subTitleInsets.right)
                : contentSpec.subTitleInsets,
            child: Text(
              subTitle,
              style: subTitleTextStyle ??
                  TextStyle(
                      fontSize: subTitleFontSize ?? contentSpec.subTitleFontSize,
                      color: subTitleColor ?? const Color(0xff6c6d71),
                      fontWeight: FontWeight.w500),
            ),
          ),
          Padding(
            padding: spaceConfig?.imageTopSpace != null
                ? EdgeInsets.only(
                    top: spaceConfig!.imageTopSpace!, left: contentSpec.contentImageInsets.left, right: contentSpec.contentImageInsets.right)
                : contentSpec.contentImageInsets,
            child:
                Container(height: contentSpec.imageContainerHeight, decoration: BoxDecoration(border: Border.all(color: Colors.red)), child: image),
          ),
          Padding(
            padding: spaceConfig?.contentTopSpace != null
                ? EdgeInsets.only(
                    top: spaceConfig!.contentTopSpace!, left: contentSpec.descriptionTextInsets.left, right: contentSpec.descriptionTextInsets.right)
                : contentSpec.descriptionTextInsets,
            child: Text(
              descriptionText,
              style: descriptionTextStyle ??
                  TextStyle(
                      fontSize: descriptionFontSize ?? contentSpec.descriptionTextFontSize,
                      color: descriptionColor ?? const Color(0xff000000),
                      fontWeight: FontWeight.w500,
                      height: descriptionTextHeight ?? 1.43),
              textAlign: TextAlign.center,
            ),
          ),
          Padding(
            padding: EdgeInsets.only(top: spaceConfig?.mainTitleTopSpace ?? contentSpec.upButtonTopSpace),
            child: GestureDetector(
              onTap: () {
                upButtonCallback?.call();
              },
              child: Container(
                  width: contentSpec.upButtonWidth,
                  height: contentSpec.upButtonHeight,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(color: upButtonBackgroundColor ?? const Color(0xff008B54), borderRadius: contentSpec.upButtonRadius),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SizedBox(
                        height: contentSpec.upButtonImageSize.width,
                        width: contentSpec.upButtonImageSize.height,
                        child: upButtonImage ??
                            const Image(
                              image: AssetImage("assets/icons/ic_ad.png", package: "guru_ui"),
                            ),
                      ),
                      SizedBox(
                        width: contentSpec.buttonImageRightSpace,
                      ),
                      Text(
                        upButtonText,
                        style: upButtonTextStyle ??
                            TextStyle(
                              fontSize: contentSpec.upButtonFontSize,
                              color: Colors.white,
                              fontWeight: FontWeight.w600,
                            ),
                        textAlign: TextAlign.center,
                      )
                    ],
                  )),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
                top: spaceConfig?.subButtonTopSpace ?? contentSpec.downButtonTopSpace,
                bottom: spaceConfig?.subButtonBottomSpace ?? contentSpec.downButtonBottomSpace),
            child: GestureDetector(
              onTap: () {
                downButtonCallback?.call();
              },
              child: Text(
                downButtonText,
                style: downButtonTextStyle ??
                    TextStyle(
                        fontSize: upButtonTextFontSize ?? contentSpec.downButtonFontSize,
                        color: downButtonTextColor ?? const Color(0xff008b54),
                        fontWeight: FontWeight.w600),
                textAlign: TextAlign.center,
              ),
            ),
          )
        ],
      ),
    );
  }
}
