You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.5KB

  1. import 'package:farm_tpf/utils/const_color.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_svg/flutter_svg.dart';
  4. class ButtonIconWidget extends StatelessWidget {
  5. final String title;
  6. final TextStyle? titleStyle;
  7. final String? subTitle;
  8. final Function onTap;
  9. final String? leadingIcon;
  10. final String? trailingIcon;
  11. final bool isTopBorder;
  12. final bool isBottomBorder;
  13. ButtonIconWidget(
  14. {required this.title,
  15. required this.onTap,
  16. this.titleStyle,
  17. this.subTitle,
  18. this.leadingIcon,
  19. this.trailingIcon,
  20. this.isBottomBorder = true,
  21. this.isTopBorder = true});
  22. @override
  23. Widget build(BuildContext context) {
  24. return SizedBox(
  25. width: double.infinity,
  26. child: MaterialButton(
  27. padding: const EdgeInsets.all(0),
  28. onPressed: () {
  29. onTap();
  30. },
  31. child: Container(
  32. padding: const EdgeInsets.all(12),
  33. decoration: BoxDecoration(
  34. border: Border(
  35. top: isTopBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none,
  36. bottom: isBottomBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none)),
  37. width: double.infinity,
  38. child: Row(
  39. mainAxisSize: MainAxisSize.max,
  40. children: [
  41. leadingIcon == null
  42. ? const SizedBox()
  43. : SizedBox(
  44. width: 20,
  45. height: 20,
  46. child: SvgPicture.asset(
  47. leadingIcon ?? '',
  48. )),
  49. const SizedBox(width: 4),
  50. Expanded(
  51. child: Column(
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. mainAxisSize: MainAxisSize.min,
  54. children: [
  55. Text(
  56. title,
  57. style: titleStyle ?? const TextStyle(fontSize: 16, fontWeight: FontWeight.w100),
  58. ),
  59. subTitle == null
  60. ? const SizedBox()
  61. : Text(
  62. subTitle ?? '',
  63. style: const TextStyle(fontSize: 14),
  64. )
  65. ],
  66. ),
  67. ),
  68. trailingIcon == null
  69. ? const SizedBox()
  70. : SvgPicture.asset(
  71. trailingIcon ?? '',
  72. )
  73. ],
  74. ),
  75. ),
  76. ),
  77. );
  78. }
  79. }