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.

82 lines
2.4KB

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