YSHomeListItemView.dart 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_tzh/home/YSHomeListDetail.dart';
  4. import '../../tool/YSRefrehLoad.dart';
  5. import '../../tool/YSTools.dart';
  6. class YSHomeListItemView extends StatefulWidget {
  7. final Map item;
  8. const YSHomeListItemView({Key? key, required this.item}) : super(key: key);
  9. @override
  10. YSHomeListItemViewState createState() => YSHomeListItemViewState();
  11. }
  12. class YSHomeListItemViewState extends State<YSHomeListItemView> {
  13. List<Color> _gradient = [];
  14. @override
  15. Widget build(BuildContext context) {
  16. if(widget.item['status']==2){
  17. _gradient = [const Color(0xFF59D35D),const Color(0xFF59D7E3)];
  18. }else if(widget.item['status']==4){
  19. _gradient = [const Color(0xFF3980DD),const Color(0xFFC19CF9)];
  20. }else if(widget.item['status']==0){
  21. _gradient = [const Color(0xFFCE665E),const Color(0xFFE38459)];
  22. }else if(widget.item['status']==1){
  23. _gradient = [const Color(0xFFDE8128),const Color(0xFFF8D889)];
  24. }else if(widget.item['status']==3){
  25. _gradient = [const Color(0xFFE0C430),const Color(0xFF8ED674)];
  26. }else if(widget.item['status']==5){
  27. _gradient = [const Color(0xFFD86695),const Color(0xFFFB9696)];
  28. }
  29. return GestureDetector(
  30. onTap: (){
  31. Navigator.of(context).push(
  32. CupertinoPageRoute(builder: (context){
  33. return YSHomeListDetail(itemId: widget.item['planNum'],);
  34. })
  35. ).then((value) {
  36. CustomNotification('').dispatch(context);
  37. });
  38. },
  39. behavior: HitTestBehavior.opaque,
  40. child: Container(
  41. decoration: BoxDecoration(
  42. color: const Color(0xFF2E3138),
  43. borderRadius: const BorderRadius.all(Radius.circular(24)),
  44. border: Border.all(color: const Color(0xFF3E434E),width: hsp(1))
  45. ),
  46. child: LayoutBuilder(
  47. builder: (context, constraints) {
  48. return Column(
  49. children: [
  50. // Container(
  51. // padding: EdgeInsets.all(hsp(15)),
  52. // child: Row(
  53. // children: [
  54. // SizedBox(
  55. // width: constraints.maxWidth*0.7-hsp(30),
  56. // child: Text(widget.item['title']??'',style: TextStyle(fontSize: zsp(14),color: Colors.white),),
  57. // ),
  58. // Container(
  59. // alignment: Alignment.centerRight,
  60. // width: constraints.maxWidth*0.3,
  61. // child: Text('查看更多',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  62. // )
  63. // ],
  64. // ),
  65. // ),
  66. Container(
  67. padding: EdgeInsets.all(hsp(15)),
  68. // decoration: BoxDecoration(
  69. // border: Border(top: BorderSide(color: const Color(0xFF3E434E),width: hsp(1)),bottom: BorderSide(color: const Color(0xFF3E434E),width: hsp(1)))
  70. // ),
  71. width: ysWidth(context),
  72. child: Column(
  73. children: [
  74. Row(
  75. children: [
  76. SizedBox(
  77. width: constraints.maxWidth*0.85-hsp(30),
  78. child: Text('编号:${widget.item['planNum']}',style: TextStyle(fontSize: zsp(12),color: Colors.white),),
  79. ),
  80. Container(
  81. height: hsp(20),
  82. alignment: Alignment.center,
  83. width: constraints.maxWidth*0.15,
  84. decoration: BoxDecoration(
  85. gradient: LinearGradient(colors: _gradient),
  86. borderRadius: const BorderRadius.all(Radius.circular(50))
  87. ),
  88. child: Text(
  89. widget.item['status']==0?'待确认':widget.item['status']==1?'待采样':widget.item['status']==2?'进行中':widget.item['status']==3?
  90. '待检测':widget.item['status']==4?'已完成':widget.item['status']==5?'已拒绝':'',
  91. style: TextStyle(fontSize: zsp(11),color: Colors.white),
  92. ),
  93. )
  94. ],
  95. ),
  96. Container(
  97. width: constraints.maxWidth-hsp(30),
  98. padding: EdgeInsets.only(top: hsp(8),bottom: hsp(8)),//${widget.item['content']}
  99. child: Text('采样计划名称:${widget.item['name']}',style: TextStyle(fontSize: zsp(12),color: Colors.white),maxLines: 2,overflow: TextOverflow.ellipsis,),
  100. ),
  101. if(widget.item['address']!=null)SizedBox(
  102. width: constraints.maxWidth-hsp(30),
  103. child: Text('地址:${widget.item['address']??''}',style: TextStyle(fontSize: zsp(12),color: Colors.white),),
  104. ),
  105. ],
  106. ),
  107. ),
  108. Container(
  109. padding: EdgeInsets.all(hsp(15)),
  110. decoration: BoxDecoration(
  111. border: Border(top: BorderSide(color: const Color(0x99535966),width: hsp(1)))
  112. ),
  113. child: Row(
  114. children: [
  115. SizedBox(
  116. width: constraints.maxWidth*0.8-hsp(30),
  117. child: Text('取样日期:${widget.item['startTime']??''} - ${widget.item['endTime']??''}',style: TextStyle(fontSize: zsp(12),color: Colors.white),),
  118. ),
  119. Container(
  120. alignment: Alignment.centerRight,
  121. width: constraints.maxWidth*0.2,
  122. child: Text('详情',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),),
  123. )
  124. ],
  125. ),
  126. ),
  127. ],
  128. );
  129. },
  130. ),
  131. ),
  132. );
  133. }
  134. }