import 'package:flutter/material.dart'; import 'package:liftmanager/res/resources.dart'; import 'package:liftmanager/utils/theme_utils.dart'; class ClickItem extends StatelessWidget { const ClickItem({ Key key, this.onTap, @required this.title, this.content: "", this.hintText:"", this.isMust:false, this.textAlign: TextAlign.start, this.maxLines: 1, this.hideDiv:false }): super(key: key); final Function onTap; final String title; final String content; final String hintText; final bool isMust; final TextAlign textAlign; final int maxLines; final bool hideDiv; @override Widget build(BuildContext context) { bool isDark = ThemeUtils.isDark(context); return InkWell( onTap: onTap, child: Container( padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0), constraints: BoxConstraints( maxHeight: double.infinity, minHeight: 50.0 ), width: double.infinity, decoration: BoxDecoration( color: isDark?Colors.black:Colors.white, border: this.hideDiv?Border():Border( bottom: Divider.createBorderSide(context, width: 0.6), ) ), child: Row( //为了数字类文字居中 crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(right: 5.0), child: Text(title), ), Offstage( offstage: !this.isMust, child: Text("*",style: TextStyle(color: Colors.red),), ), const Spacer(), Expanded( flex: 4, child: Padding( padding: const EdgeInsets.only(right: 8.0, left: 16.0), child: Text( (content == null || content.length==0)?hintText:content, maxLines: maxLines, textAlign: maxLines == 1 ? TextAlign.right : textAlign, overflow: maxLines==1?TextOverflow.ellipsis:TextOverflow.visible, style: Theme.of(context).textTheme.subtitle.copyWith(fontSize: Dimens.font_sp14)) // style: TextStyle(fontSize: 14,color: content.length==0?Colours.text_gray_c:Colors.black)) ), ), Offstage( offstage: onTap == null ? true:false, child: Opacity( // 无点击事件时,隐藏箭头图标 opacity: onTap == null ? 0 : 1, child: Padding( padding: EdgeInsets.only(top: maxLines == 1 ? 0.0 : 2.0), child: Images.arrowRight, ), ) ) ], ), ), ); } }