import 'package:farm_tpf/utils/const_color.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class ButtonIconWidget extends StatelessWidget {
  final String title;
  final TextStyle? titleStyle;
  final String? subTitle;
  final Function onTap;
  final String? leadingIcon;
  final String? trailingIcon;
  final bool isTopBorder;
  final bool isBottomBorder;
  ButtonIconWidget(
      {required this.title,
      required this.onTap,
      this.titleStyle,
      this.subTitle,
      this.leadingIcon,
      this.trailingIcon,
      this.isBottomBorder = true,
      this.isTopBorder = true});
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      child: MaterialButton(
        padding: const EdgeInsets.all(0),
        onPressed: () {
          onTap();
        },
        child: Container(
          padding: const EdgeInsets.all(12),
          decoration: BoxDecoration(
              border: Border(
                  top: isTopBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none,
                  bottom: isBottomBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none)),
          width: double.infinity,
          child: Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              leadingIcon == null
                  ? const SizedBox()
                  : SizedBox(
                      width: 20,
                      height: 20,
                      child: SvgPicture.asset(
                        leadingIcon ?? '',
                      )),
              const SizedBox(width: 4),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Text(
                      title,
                      style: titleStyle ?? const TextStyle(fontSize: 16, fontWeight: FontWeight.w100),
                    ),
                    subTitle == null
                        ? const SizedBox()
                        : Text(
                            subTitle ?? '',
                            style: const TextStyle(fontSize: 14),
                          )
                  ],
                ),
              ),
              trailingIcon == null
                  ? const SizedBox()
                  : SvgPicture.asset(
                      trailingIcon ?? '',
                    )
            ],
          ),
        ),
      ),
    );
  }
}
