123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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 OptionsItem extends StatelessWidget {
- const OptionsItem({
- Key key,
- this.onTap,
- @required this.title,
- this.content: "",
- this.isEdit: false,
- this.value: -1,
- }) : super(key: key);
- final Function onTap;
- final String title;
- final String content;
- final bool isEdit;
- final int value; //-1未选 0 不需要 1勾 2叉
- @override
- Widget build(BuildContext context) {
- bool isDark = ThemeUtils.isDark(context);
- return InkWell(
- 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?Colours.dark_bg_gray:Colors.white,
- borderRadius: BorderRadius.circular(6),
- ),
- child: Row(
- //为了数字类文字居中
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Expanded(
- flex: 1,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- "${title}",
- style: TextStyle(fontSize: 15, color: isDark?Colors.white:Color(0xFF333333)),
- ),
- Text(content,
- maxLines: 5,
- textAlign: TextAlign.left,
- overflow: TextOverflow.visible,
- style: TextStyle(
- fontSize: 13, color: Colours.dark_text_gray))
- ],
- )),
- Row(
- children: <Widget>[
- Offstage(
- offstage: !isEdit && value != 1,
- child: GestureDetector(
- onTap: () {
- onTap(1);
- },
- child: Container(
- margin: EdgeInsets.only(right: 10),
- child: LoadAssetImage(
- "icon_gou_${value == 1 ? "s" : "n"}",
- width: 25,
- height: 25),
- )
- )),
- Offstage(
- offstage: !isEdit && value != 2,
- child: GestureDetector(
- onTap: () {
- onTap(2);
- },
- child:Container(
- margin: EdgeInsets.only(right: 10),
- child: LoadAssetImage(
- "icon_cha_${value == 2 ? "s" : "n"}",
- width: 25,
- height: 25)),
- )),
- Offstage(
- offstage: !isEdit && value != 0,
- child: GestureDetector(
- onTap: () {
- onTap(0);
- },
- child: Container(
- margin: EdgeInsets.only(right: 10),
- child: LoadAssetImage(
- "icon_no_${value == 0 ? "s" : "n"}",
- width: 25,
- height: 25,
- ),
- ))),
- ],
- )
- ],
- ),
- ),
- );
- }
- }
|