import 'package:flutter/material.dart';
import 'package:guru_ui/widget/alerts/dialog_label_alert_design_model.dart';

class DialogLabelAlertSpaceConfig {
  final double? contentTopSpace;
  final double? buttonTopSpace;
  DialogLabelAlertSpaceConfig({this.contentTopSpace, this.buttonTopSpace});
}

class DialogLabelAlertWidget extends StatelessWidget {
  final Color? backgroundColor;
  final String contentText;
  final TextStyle? contentTextStyle;
  final Color? contentTextColor;
  final double? contentFontSize;
  final double? contentTextHeight;

  final String cancelText;
  final TextStyle? cancelTextStyle;
  final VoidCallback? cancelCallBack;

  final String ackText;
  final TextStyle? ackTextStyle;
  final VoidCallback? ackCallBack;

  final Color? crossLineColor;
  final DialogLabelAlertSpaceConfig? spaceConfig;
  const DialogLabelAlertWidget({
    Key? key,
    required this.contentText,
    required this.cancelText,
    required this.ackText,
    this.backgroundColor = Colors.white,
    this.contentTextColor,
    this.contentFontSize,
    this.contentTextHeight,
    this.contentTextStyle,
    this.cancelTextStyle,
    this.cancelCallBack,
    this.ackTextStyle,
    this.ackCallBack,
    this.crossLineColor,
    this.spaceConfig,
  }) : super(key: key);

  DialogLabelAlertDesignSpec get designSpec => DialogLabelAlertDesignSpec.get();
  DialogLabelAlertContentDesignSpec get contentSpec => designSpec.contentSpec;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: contentSpec.cardRadius,
        ),
        width: contentSpec.measuredSize.width,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Padding(
              padding: spaceConfig?.contentTopSpace != null
                  ? EdgeInsets.only(top: spaceConfig!.contentTopSpace!, left: contentSpec.contentInsets.left, right: contentSpec.contentInsets.right)
                  : contentSpec.contentInsets,
              child: Text(
                contentText,
                style: contentTextStyle ??
                    TextStyle(
                      color: contentTextColor ?? const Color(0xff191b34),
                      fontSize: contentFontSize ?? contentSpec.contentFontSize,
                      fontWeight: FontWeight.w500,
                      height: contentTextHeight ?? 1.5,
                    ),
                textAlign: TextAlign.center,
              ),
            ),
            SizedBox(
              height: spaceConfig?.buttonTopSpace ?? contentSpec.buttonTopSpace,
            ),
            Container(
              color: crossLineColor ?? const Color(0xff000000).withOpacity(0.08),
              height: contentSpec.horizontalLineHeight,
            ),
            SizedBox(
              height: contentSpec.buttonHeight,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Expanded(
                      child: GestureDetector(
                    onTap: () {
                      cancelCallBack?.call();
                    },
                    child: Text(
                      cancelText,
                      style: cancelTextStyle ??
                          TextStyle(
                            color: const Color(0xff000000),
                            fontSize: contentSpec.buttonFontSize,
                            fontWeight: FontWeight.w500,
                          ),
                      textAlign: TextAlign.center,
                    ),
                  )),
                  Container(
                    height: contentSpec.buttonHeight,
                    width: contentSpec.verticalLineWidth,
                    color: crossLineColor ?? const Color(0xff000000).withOpacity(0.08),
                  ),
                  Expanded(
                      child: GestureDetector(
                    onTap: () {
                      ackCallBack?.call();
                    },
                    child: Text(
                      ackText,
                      style: ackTextStyle ??
                          TextStyle(
                            color: const Color(0xffeb0000),
                            fontSize: contentSpec.buttonFontSize,
                            fontWeight: FontWeight.w500,
                          ),
                      textAlign: TextAlign.center,
                    ),
                  )),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
