Hibok
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.
 
 
 
 
 
 

110 lines
3.1 KiB

  1. import 'package:flutter/material.dart';
  2. import '../data/constants.dart' show Constants, AppColors;
  3. class FullWidthButton extends StatelessWidget {
  4. static const Hor_Padding = 5.0;
  5. static const Ver_Padding = 10.0;
  6. final String title;
  7. final bool showDivider;
  8. final VoidCallback onPressed;
  9. final String description;
  10. final Color descriptionColor;
  11. final bool showRightIcon;
  12. final int iconCode;
  13. final iconColor;
  14. final Widget extendWidget;
  15. const FullWidthButton(
  16. {@required this.title,
  17. this.description = '',
  18. @required this.onPressed,
  19. this.descriptionColor,
  20. this.showRightIcon: true,
  21. this.showDivider: false,
  22. this.iconCode,
  23. this.iconColor,
  24. this.extendWidget})
  25. : assert(title != null),
  26. assert(onPressed != null);
  27. @override
  28. Widget build(BuildContext context) {
  29. final pureButton = Row(
  30. mainAxisAlignment: MainAxisAlignment.start,
  31. crossAxisAlignment: CrossAxisAlignment.center,
  32. children: <Widget>[
  33. iconCode == null
  34. ? Container()
  35. : Container(
  36. margin: EdgeInsets.only(right: 5,bottom: 3),
  37. child: Icon(
  38. IconData(
  39. iconCode,
  40. fontFamily: 'iconfont',
  41. ),
  42. color: Color(iconColor),
  43. size: 20,
  44. )),
  45. SizedBox(width: Hor_Padding),
  46. Expanded(
  47. child: Text(
  48. title,
  49. textScaleFactor: 1.0,
  50. style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal),
  51. ),
  52. ),
  53. extendWidget != null
  54. ? extendWidget
  55. : Text(
  56. description,
  57. textScaleFactor: 1.0,
  58. textAlign: TextAlign.end,
  59. style: TextStyle(
  60. fontSize: 12,
  61. fontWeight: FontWeight.normal,
  62. color: descriptionColor == null
  63. ? const Color(0xFF818181)
  64. : descriptionColor),
  65. ),
  66. showRightIcon
  67. ? Padding(
  68. padding: EdgeInsets.only(bottom: 1.5),
  69. child: Icon(
  70. IconData(0xe63c, fontFamily: 'iconfont'),
  71. size: 20.0,
  72. color: Color(AppColors.TabIconNormal),
  73. ))
  74. : Padding(padding: EdgeInsets.only(right: 7)),
  75. ],
  76. );
  77. final borderButton = Container(
  78. decoration: BoxDecoration(
  79. border: Border(
  80. bottom: Constants.GreyBorderSide,
  81. ),
  82. ),
  83. padding: EdgeInsets.only(
  84. bottom: Ver_Padding,
  85. ),
  86. child: pureButton,
  87. );
  88. return FlatButton(
  89. onPressed: () {
  90. this.onPressed();
  91. },
  92. padding: EdgeInsets.only(
  93. left: Hor_Padding,
  94. right: Hor_Padding,
  95. top: Ver_Padding,
  96. bottom: showDivider ? 0.0 : Ver_Padding,
  97. ),
  98. color: Colors.white,
  99. child: showDivider ? borderButton : pureButton,
  100. );
  101. }
  102. }