import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import '../translations/app_dept.dart'; import '../translations/current_locale_tool.dart'; class CommonItem extends StatelessWidget { CommonItem( {required this.leftTitel, Key? key, this.rightTitle, this.allHeight, this.isHaveDirection = false, this.isHaveLine = false, this.isHaveRightWidget = false, this.isPadding = true, this.setHeight = true, this.rightWidget, this.isTipsImg, this.action, this.leftTitleMaxWidth, // 新增属性 this.tipsImgAction}) : super(key: key); String? leftTitel; String? rightTitle; bool? isHaveDirection; bool? isHaveLine; bool? isHaveRightWidget; Widget? rightWidget; Function()? action; Function()? tipsImgAction; double? allHeight; bool? setHeight; bool? isTipsImg; bool? isPadding; final double? leftTitleMaxWidth; // 新增属性声明 @override Widget build(BuildContext context) { return GestureDetector( onTap: action, child: Container( height: setHeight == true ? allHeight ?? 65.h : null, padding: isPadding == true ? EdgeInsets.only(left: 20.w, right: 10.w) : EdgeInsets.zero, decoration: BoxDecoration( color: Colors.white, border: isHaveLine! ? Border( bottom: BorderSide( color: AppColors.greyLineColor, // 设置边框颜色 width: 2.0.h, // 设置边框宽度 ), ) : null, ), child: Row( children: [ ConstrainedBox( constraints: BoxConstraints( maxWidth: leftTitleMaxWidth ?? 0.6.sw, // 默认最大宽度为屏幕宽度的40% ), child: Text( leftTitel!, style: TextStyle(fontSize: 22.sp), overflow: TextOverflow.ellipsis, // 超出部分显示省略号 maxLines: 3, // 最多显示2行 ), ), SizedBox(width: 6.w), if (isTipsImg == true) GestureDetector( onTap: tipsImgAction, child: Container( width: 50.h, height: 50.h, padding: EdgeInsets.only(right: 10.h, top: 15.h, bottom: 10.h), child: Image.asset( 'images/icon_tips_Q.png', width: 20.w, height: 20.w, ), ), ), if (isHaveRightWidget!) ...[ const Spacer(), rightWidget! ] else Expanded( child: Text( rightTitle ?? '', textAlign: TextAlign.right, overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), ), if (isHaveDirection!) SizedBox(width: 15.w) else Container(), if (isHaveDirection!) if (CurrentLocaleTool.getCurrentLocaleString() == ExtensionLanguageType.fromLanguageType( LanguageType.hebrew) .toString() || CurrentLocaleTool.getCurrentLocaleString() == ExtensionLanguageType.fromLanguageType( LanguageType.arabic) .toString()) Image.asset( 'images/icon_left_grey.png', width: 21.w, height: 21.w, ) else Image.asset( 'images/icon_right_grey.png', width: 12.w, height: 21.w, ) else SizedBox(width: 10.w), if (isHaveDirection!) SizedBox(width: 5.w) else Container(), ], ), ), ); } }