YSInstitutionListItemView.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import 'package:dotted_border/dotted_border.dart';
  2. import 'package:flutter/material.dart';
  3. import '../../base/YSTools.dart';
  4. class YSInstitutionListItemView extends StatefulWidget {
  5. final Map item;
  6. const YSInstitutionListItemView({Key key, this.item}) : super(key: key);
  7. @override
  8. _YSInstitutionListItemViewState createState() => _YSInstitutionListItemViewState();
  9. }
  10. class _YSInstitutionListItemViewState extends State<YSInstitutionListItemView> {
  11. @override
  12. Widget build(BuildContext context) {
  13. List array = widget.item['voucherDepartmentList']??[];
  14. bool isOpen = widget.item['isOpen']??false;
  15. int length = array.length;
  16. if(isOpen==false){
  17. length = array.length>2?2:array.length;
  18. }
  19. return DottedBorder(
  20. color: Color(0xFFFF6D96),
  21. borderType: BorderType.RRect,
  22. radius: Radius.circular(9),
  23. strokeWidth: 1,
  24. padding: EdgeInsets.all(0),
  25. child: Container(
  26. decoration: BoxDecoration(
  27. color: Colors.white,
  28. borderRadius: BorderRadius.all(Radius.circular(9))
  29. ),
  30. child: LayoutBuilder(
  31. builder: (context,conSize){
  32. return Column(
  33. children: [
  34. Container(
  35. child: Text(widget.item['hospitalName'],style: TextStyle(fontSize: 16,color: Color(0xFFEE6B8F)),maxLines: 1,),
  36. alignment: Alignment.centerLeft,
  37. padding: EdgeInsets.only(top: 10),
  38. ),
  39. SizedBox(
  40. height: 30,
  41. child: Row(
  42. children: [
  43. Container(
  44. width: conSize.maxWidth*0.7,
  45. child: Text('服务券',style: TextStyle(fontSize: 14,color: Color(0xFF444444)),),
  46. alignment: Alignment.centerLeft,
  47. ),
  48. Container(
  49. width: conSize.maxWidth*0.3,
  50. child: Text('科室',style: TextStyle(fontSize: 14,color: Color(0xFF444444)),),
  51. alignment: Alignment.centerRight,
  52. )
  53. ],
  54. ),
  55. ),
  56. ListView.builder(
  57. itemBuilder: (context,indexSub){
  58. Map itemSub = array[indexSub];
  59. return SizedBox(
  60. height: 20,
  61. child: Row(
  62. children: [
  63. Container(
  64. width: conSize.maxWidth*0.7,
  65. child: Text(itemSub['couponName'],style: TextStyle(fontSize: 12,color: Color(0xFF8A8A8A)),),
  66. alignment: Alignment.centerLeft,
  67. ),
  68. Container(
  69. width: conSize.maxWidth*0.3,
  70. child: Text(itemSub['departmentName'],style: TextStyle(fontSize: 12,color: Color(0xFF8A8A8A)),),
  71. alignment: Alignment.centerRight,
  72. )
  73. ],
  74. ),
  75. );
  76. },
  77. itemCount: length,
  78. padding: EdgeInsets.all(0),
  79. physics: NeverScrollableScrollPhysics(),
  80. shrinkWrap: true,
  81. ),
  82. array.length>2?Container(
  83. height: 30,
  84. child: GestureDetector(
  85. onTap: (){
  86. if(widget.item['isOpen']==true){
  87. widget.item['isOpen'] = false;
  88. }else{
  89. widget.item['isOpen'] = true;
  90. }
  91. setState(() {});
  92. },
  93. behavior: HitTestBehavior.opaque,
  94. child: Row(
  95. mainAxisSize: MainAxisSize.min,
  96. children: [
  97. Text(isOpen?'收起':'显示更多',style: TextStyle(fontSize: 10,color: Color(0xFFD8D8D8)),),
  98. Icon(isOpen?Icons.keyboard_arrow_up:Icons.keyboard_arrow_down,size: 15,color: Color(0xFFD8D8D8),)
  99. ],
  100. ),
  101. ),
  102. ):Container(height: 10,),
  103. DashLine(height: 1,color: Color(0xFF979797),),
  104. Padding(
  105. padding: EdgeInsets.only(top: 10,bottom: 10),
  106. child: Row(
  107. children: [
  108. Container(
  109. width: conSize.maxWidth-10,
  110. child: Text('${widget.item['hospitalAddress']} | ${widget.item['businessHoursInformation']}',style: TextStyle(fontSize: 14,color: Color(0xFF444444)),),
  111. alignment: Alignment.centerLeft,
  112. ),
  113. // Image.asset('lib/images/地址_fy.png',height: 10,width: 10,)
  114. ],
  115. ),
  116. )
  117. ],
  118. );
  119. },
  120. ),
  121. padding: EdgeInsets.only(left: 15,right: 15),
  122. ),
  123. );
  124. }
  125. }