123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/widgets/load_image.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,
- this.hasPic,
- this.hasPicRight,
- this.titleColor = 0,
- this.subwidget,
- this.rightPicIsAsset = false})
- : super(key: key);
- final Function onTap;
- final String title;
- final String content;
- final String hintText;
- final bool isMust;
- final String hasPic;
- final String hasPicRight;
- final TextAlign textAlign;
- final int maxLines;
- final int titleColor;
- final bool hideDiv;
- final bool rightPicIsAsset;
- final Widget subwidget;
- @override
- Widget build(BuildContext context) {
- return InkWell(
- onTap: onTap,
- child: Container(
- padding: const EdgeInsets.fromLTRB(15, 10.0, 15.0, 10.0),
- constraints:
- BoxConstraints(maxHeight: double.infinity, minHeight: 50.0),
- width: double.infinity,
- decoration: BoxDecoration(
- color: ThemeUtils.getTabsBg(context),
- border: this.hideDiv
- ? Border()
- : Border(
- bottom: Divider.createBorderSide(context, width: 0.6),
- )),
- child: Row(
- //为了数字类文字居中
- crossAxisAlignment: maxLines == 1
- ? CrossAxisAlignment.center
- : CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- hasPic != null && hasPic.isNotEmpty
- ? Container(
- padding: EdgeInsets.only(right: 10),
- child: ClipRRect(
- borderRadius: BorderRadius.circular(15),
- child: Container(
- width: 30,
- height: 30,
- color: Color(0xffFAF7FA),
- // padding: EdgeInsets.all(2),
- child: LoadAssetImage(
- hasPic,
- format: 'jpg',
- // fit: BoxFit.cover,
- // width: 100,
- // height: 100,
- ),
- ),
- ),
- )
- : Container(),
- Padding(
- padding: const EdgeInsets.only(right: 5.0),
- child: titleColor == 0
- ? Text(title)
- : Text(
- title,
- style: TextStyle(
- color: Color(titleColor),
- ),
- textAlign: TextAlign.start,
- ),
- ),
- ],
- ),
- Offstage(
- offstage: !this.isMust,
- child: Text(
- "*",
- style: TextStyle(color: Colors.red),
- ),
- ),
- const Spacer(),
- hasPicRight != null && hasPicRight.isNotEmpty
- ? Container(
- padding: EdgeInsets.only(right: 10),
- child: ClipRRect(
- borderRadius: BorderRadius.circular(25),
- child: Container(
- width: 50,
- height: 50,
- color: Color(0xffFAF7FA),
- // padding: EdgeInsets.all(2),
- child: rightPicIsAsset
- ? Image.asset(
- hasPicRight,
- fit: BoxFit.cover,
- )
- : LoadNetworkImage(
- hasPicRight,
- fit: BoxFit.cover,
- // width: 100,
- // height: 100,
- ),
- ),
- ),
- )
- : Expanded(
- flex: 4,
- child: Padding(
- padding: const EdgeInsets.only(right: 8.0, left: 16.0),
- child: Text(content.length == 0 ? hintText : content,
- maxLines: maxLines,
- textAlign:
- maxLines == 1 ? TextAlign.right : textAlign,
- overflow: maxLines == 1
- ? TextOverflow.ellipsis
- : TextOverflow.visible,
- style: TextStyle(
- fontSize: 14, color: Colours.text_gray))),
- ),
- subwidget != null ? subwidget : Container(),
- 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: Icon(
- Icons.arrow_forward_ios,
- size: 14,
- color: Color(0xffcccccc),
- )
- // Images.arrowRight,
- ),
- ))
- ],
- ),
- ),
- );
- }
- }
|