options_item.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. import 'package:liftmanager/utils/theme_utils.dart';
  4. import 'package:liftmanager/widgets/load_image.dart';
  5. class OptionsItem extends StatelessWidget {
  6. const OptionsItem({
  7. Key key,
  8. this.onTap,
  9. @required this.title,
  10. this.content: "",
  11. this.isEdit: false,
  12. this.value: -1,
  13. }) : super(key: key);
  14. final Function onTap;
  15. final String title;
  16. final String content;
  17. final bool isEdit;
  18. final int value; //-1未选 0 不需要 1勾 2叉
  19. @override
  20. Widget build(BuildContext context) {
  21. bool isDark = ThemeUtils.isDark(context);
  22. return InkWell(
  23. child: Container(
  24. padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0),
  25. constraints:
  26. BoxConstraints(maxHeight: double.infinity, minHeight: 50.0),
  27. width: double.infinity,
  28. decoration: BoxDecoration(
  29. color: isDark?Colours.dark_bg_gray:Colors.white,
  30. borderRadius: BorderRadius.circular(6),
  31. ),
  32. child: Row(
  33. //为了数字类文字居中
  34. crossAxisAlignment: CrossAxisAlignment.center,
  35. mainAxisAlignment: MainAxisAlignment.center,
  36. children: <Widget>[
  37. Expanded(
  38. flex: 1,
  39. child: Column(
  40. mainAxisAlignment: MainAxisAlignment.start,
  41. crossAxisAlignment: CrossAxisAlignment.start,
  42. children: <Widget>[
  43. Text(
  44. "${title}",
  45. style: TextStyle(fontSize: 15, color: isDark?Colors.white:Color(0xFF333333)),
  46. ),
  47. Text(content,
  48. maxLines: 5,
  49. textAlign: TextAlign.left,
  50. overflow: TextOverflow.visible,
  51. style: TextStyle(
  52. fontSize: 13, color: Colours.dark_text_gray))
  53. ],
  54. )),
  55. Row(
  56. children: <Widget>[
  57. Offstage(
  58. offstage: !isEdit && value != 1,
  59. child: GestureDetector(
  60. onTap: () {
  61. onTap(1);
  62. },
  63. child: Container(
  64. margin: EdgeInsets.only(right: 10),
  65. child: LoadAssetImage(
  66. "icon_gou_${value == 1 ? "s" : "n"}",
  67. width: 25,
  68. height: 25),
  69. )
  70. )),
  71. Offstage(
  72. offstage: !isEdit && value != 2,
  73. child: GestureDetector(
  74. onTap: () {
  75. onTap(2);
  76. },
  77. child:Container(
  78. margin: EdgeInsets.only(right: 10),
  79. child: LoadAssetImage(
  80. "icon_cha_${value == 2 ? "s" : "n"}",
  81. width: 25,
  82. height: 25)),
  83. )),
  84. Offstage(
  85. offstage: !isEdit && value != 0,
  86. child: GestureDetector(
  87. onTap: () {
  88. onTap(0);
  89. },
  90. child: Container(
  91. margin: EdgeInsets.only(right: 10),
  92. child: LoadAssetImage(
  93. "icon_no_${value == 0 ? "s" : "n"}",
  94. width: 25,
  95. height: 25,
  96. ),
  97. ))),
  98. ],
  99. )
  100. ],
  101. ),
  102. ),
  103. );
  104. }
  105. }