options_item.dart 2.6 KB

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