my_click_item.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import 'package:flutter/material.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import '../utils/dark_theme_util.dart';
  4. import 'my_load_image.dart';
  5. // ignore: slash_for_doc_comments
  6. /**
  7. 默认是左边文本图标等 右边more小箭头
  8. 常用于Me页面的跳转
  9. 模板:
  10. MyClickItem(
  11. title: '测试SP-存和取',
  12. drawablePadding: 0,
  13. onTap: () {
  14. SpUtil.putString("username", "Sky24n");
  15. SpUtil.putString(SPConstant.SP_KEY_TOKEN, "1234");
  16. String? userName = SpUtil.getString("username");
  17. if (!TextUtil.isEmpty(userName)) {
  18. SmartDialog.compatible.showToast('username:$userName');
  19. }
  20. },
  21. backgroundColor: ColorConstants.dividerColor,
  22. ),
  23. */
  24. class MyClickItem extends StatelessWidget {
  25. const MyClickItem({
  26. Key? key,
  27. required this.onTap,
  28. required this.title,
  29. this.title_color = Colors.black,
  30. this.title_size = 16,
  31. this.image_path,
  32. this.image_width = 25,
  33. this.image_height = 25,
  34. this.backgroundColor = Colors.white,
  35. this.paddingTop = 8,
  36. this.padingBottom = 8,
  37. this.paddingLeft = 15,
  38. this.paddingRight = 15,
  39. this.marginTop = 0,
  40. this.marginBottom = 0,
  41. this.marginLeft = 0,
  42. this.marginRight = 0,
  43. this.drawablePadding = 10,
  44. this.border_radius = 0,
  45. this.enableOverlay = true, //是否支持水波纹效果,不过这个效果对比InkWell原生比较克制,推荐开启
  46. this.fontWeight = FontWeight.w400,
  47. }) : super(key: key);
  48. final Function() onTap;
  49. final String? image_path;
  50. final double? image_width;
  51. final double? image_height;
  52. final String title;
  53. final Color title_color;
  54. final double title_size;
  55. final Color backgroundColor;
  56. final double border_radius;
  57. final double paddingLeft, paddingTop, paddingRight, padingBottom;
  58. final double marginLeft, marginTop, marginRight, marginBottom;
  59. final double drawablePadding;
  60. final bool enableOverlay;
  61. final FontWeight fontWeight;
  62. @override
  63. Widget build(BuildContext context) {
  64. return Container(
  65. margin: EdgeInsets.fromLTRB(marginLeft, marginTop, marginRight, marginBottom),
  66. child: Material(
  67. borderRadius: BorderRadius.circular(border_radius),
  68. color: backgroundColor,
  69. child: InkWell(
  70. onTap: onTap,
  71. overlayColor: MaterialStateProperty.resolveWith((states) {
  72. return enableOverlay
  73. ? DarkThemeUtil.multiColors(title_color)?.withOpacity(0.12)
  74. : Colors.transparent;
  75. }),
  76. customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(11)),
  77. child: Padding(
  78. padding: EdgeInsets.fromLTRB(paddingLeft, paddingTop, paddingRight, padingBottom),
  79. child: Row(
  80. children: [
  81. image_path == null
  82. ? const SizedBox()
  83. : MyLoadImage(
  84. image_path!,
  85. width: image_width,
  86. height: image_height,
  87. ),
  88. SizedBox(
  89. width: drawablePadding,
  90. ),
  91. Expanded(
  92. child: Text(
  93. title,
  94. style: TextStyle(color: title_color, fontSize: title_size,fontWeight: fontWeight),
  95. )),
  96. MyLoadImage(
  97. Assets.baseLibBlackBack,
  98. width: 5.5,
  99. height: 9.5,
  100. )
  101. ],
  102. ),
  103. ),
  104. ),
  105. ),
  106. );
  107. }
  108. }