import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:flutter/material.dart';

class BorderedButton extends StatelessWidget {
  final String text;
  final Function handler;
  final Color color;
  final bool hasBorder;
  final Color borderColor;
  final Color backgroundColor;
  final double vPadding;
  final double hPadding;

  BorderedButton(
    this.text, {
    this.handler,
    this.color,
    this.hasBorder = false,
    this.borderColor,
    this.backgroundColor,
    this.vPadding = 0,
    this.hPadding = 0,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 4, vertical: 4),
      child: ButtonTheme(
        //adds padding inside the button
        materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
        //limits the touch area to the button area
        minWidth: 0,
        //wraps child's width
        height: 0,
        //wraps child's height
        child: RaisedButton(
          materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
          padding: EdgeInsets.symmetric(horizontal: 12, vertical: vPadding),
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(4.0),
              side: BorderSide(color: hasBorder ? borderColor : Colors.white, width: 0.8),),
          color: backgroundColor ?? Colors.white,
          textColor: color ?? Color(0xffc4aa54),
          disabledTextColor: color ?? Colors.black,
          disabledColor: backgroundColor ?? Colors.white,
          onPressed: handler,
          child: Text(
            text,
            textAlign: TextAlign.center,
            style: TextStyle(
                fontSize: SizeConfig.textMultiplier * 1.6,
                fontWeight: FontWeight.normal),
          ),
        ), //your original button
      ),
    );
  }
}
