import 'package:flutter/material.dart'; import 'package:cs_resources/generated/assets.dart'; import '../utils/dark_theme_util.dart'; import 'my_load_image.dart'; // ignore: slash_for_doc_comments /** 默认是左边文本图标等 右边more小箭头 常用于Me页面的跳转 模板: MyClickItem( title: '测试SP-存和取', drawablePadding: 0, onTap: () { SpUtil.putString("username", "Sky24n"); SpUtil.putString(SPConstant.SP_KEY_TOKEN, "1234"); String? userName = SpUtil.getString("username"); if (!TextUtil.isEmpty(userName)) { SmartDialog.compatible.showToast('username:$userName'); } }, backgroundColor: ColorConstants.dividerColor, ), */ class MyClickItem extends StatelessWidget { const MyClickItem({ Key? key, required this.onTap, required this.title, this.title_color = Colors.black, this.title_size = 16, this.image_path, this.image_width = 25, this.image_height = 25, this.backgroundColor = Colors.white, this.paddingTop = 8, this.padingBottom = 8, this.paddingLeft = 15, this.paddingRight = 15, this.marginTop = 0, this.marginBottom = 0, this.marginLeft = 0, this.marginRight = 0, this.drawablePadding = 10, this.border_radius = 0, this.enableOverlay = true, //是否支持水波纹效果,不过这个效果对比InkWell原生比较克制,推荐开启 this.fontWeight = FontWeight.w400, }) : super(key: key); final Function() onTap; final String? image_path; final double? image_width; final double? image_height; final String title; final Color title_color; final double title_size; final Color backgroundColor; final double border_radius; final double paddingLeft, paddingTop, paddingRight, padingBottom; final double marginLeft, marginTop, marginRight, marginBottom; final double drawablePadding; final bool enableOverlay; final FontWeight fontWeight; @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.fromLTRB(marginLeft, marginTop, marginRight, marginBottom), child: Material( borderRadius: BorderRadius.circular(border_radius), color: backgroundColor, child: InkWell( onTap: onTap, overlayColor: MaterialStateProperty.resolveWith((states) { return enableOverlay ? DarkThemeUtil.multiColors(context,title_color)?.withOpacity(0.12) : Colors.transparent; }), customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(11)), child: Padding( padding: EdgeInsets.fromLTRB(paddingLeft, paddingTop, paddingRight, padingBottom), child: Row( children: [ image_path == null ? const SizedBox() : MyLoadImage( image_path!, width: image_width, height: image_height, ), SizedBox( width: drawablePadding, ), Expanded( child: Text( title, style: TextStyle(color: title_color, fontSize: title_size,fontWeight: fontWeight), )), MyLoadImage( Assets.baseLibBlackBack, width: 5.5, height: 9.5, ) ], ), ), ), ), ); } }