import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';

import '../../theme/colors.dart';

class ShowFillButton extends StatelessWidget {
  String title;
  VoidCallback onPressed;
  Color txtColor;
  double elevation, radius, maxWidth, maxHeight, fontSize, horizontalPadding, horizontalMargin, verticalMargin;
  bool isFlatButton, isBold;
  EdgeInsets? margin;

  ShowFillButton({
    required this.title,
    required this.onPressed,
    this.txtColor = Colors.white,
    this.elevation = 0,
    this.radius = 0,
    this.maxWidth = 88,
    this.maxHeight = 45,
    this.fontSize = 16,
    this.horizontalPadding = 16,
    this.isFlatButton = false,
    this.isBold = true,
    this.horizontalMargin = 0,
    this.verticalMargin = 0,
    this.margin,
  });

  @override
  Widget build(BuildContext context) {
    return isFlatButton
        ? Container(
      child: showButton(),
      height: maxHeight,
      padding: const EdgeInsets.only(
        left: 20,
        right: 20,
      ),
    )
        : Padding(
      padding: margin ?? const EdgeInsets.all(0.0),
      child: ConstrainedBox(
        constraints: BoxConstraints(
          minHeight: maxHeight,
          minWidth: maxWidth,
          maxHeight: maxHeight,
          maxWidth: maxWidth,
        ),
        child: showButton(),
      ),
    );
  }

  Widget showButton() {
    return Container(
      // decoration: isFlatButton ? null : MyColors.gradientButton,
      color: isFlatButton ? null : MyColors.darkPrimaryColor,
      margin: EdgeInsets.symmetric(horizontal: horizontalMargin, vertical: verticalMargin),
      child: MaterialButton(
        onPressed: onPressed,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(radius),
        ),
        child: title.toText(
          fontSize: fontSize,
          isBold: isBold,
          color: txtColor,
          maxLines: 1,
        ),
      ),
    );
  }
}
