import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_tzh/home/YSHomeListDetail.dart'; import '../../tool/YSRefrehLoad.dart'; import '../../tool/YSTools.dart'; class YSHomeListItemView extends StatefulWidget { final Map item; const YSHomeListItemView({Key? key, required this.item}) : super(key: key); @override YSHomeListItemViewState createState() => YSHomeListItemViewState(); } class YSHomeListItemViewState extends State { List _gradient = []; @override Widget build(BuildContext context) { if(widget.item['status']==2){ _gradient = [const Color(0xFF59D35D),const Color(0xFF59D7E3)]; }else if(widget.item['status']==4){ _gradient = [const Color(0xFF3980DD),const Color(0xFFC19CF9)]; }else if(widget.item['status']==0){ _gradient = [const Color(0xFFCE665E),const Color(0xFFE38459)]; }else if(widget.item['status']==1){ _gradient = [const Color(0xFFDE8128),const Color(0xFFF8D889)]; }else if(widget.item['status']==3){ _gradient = [const Color(0xFFE0C430),const Color(0xFF8ED674)]; }else if(widget.item['status']==5){ _gradient = [const Color(0xFFD86695),const Color(0xFFFB9696)]; } return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSHomeListDetail(itemId: widget.item['planNum'],); }) ).then((value) { CustomNotification('').dispatch(context); }); }, behavior: HitTestBehavior.opaque, child: Container( decoration: BoxDecoration( color: const Color(0xFF2E3138), borderRadius: const BorderRadius.all(Radius.circular(24)), border: Border.all(color: const Color(0xFF3E434E),width: hsp(1)) ), child: LayoutBuilder( builder: (context, constraints) { return Column( children: [ // Container( // padding: EdgeInsets.all(hsp(15)), // child: Row( // children: [ // SizedBox( // width: constraints.maxWidth*0.7-hsp(30), // child: Text(widget.item['title']??'',style: TextStyle(fontSize: zsp(14),color: Colors.white),), // ), // Container( // alignment: Alignment.centerRight, // width: constraints.maxWidth*0.3, // child: Text('查看更多',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), // ) // ], // ), // ), Container( padding: EdgeInsets.all(hsp(15)), // decoration: BoxDecoration( // border: Border(top: BorderSide(color: const Color(0xFF3E434E),width: hsp(1)),bottom: BorderSide(color: const Color(0xFF3E434E),width: hsp(1))) // ), width: ysWidth(context), child: Column( children: [ Row( children: [ SizedBox( width: constraints.maxWidth*0.85-hsp(30), child: Text('编号:${widget.item['planNum']}',style: TextStyle(fontSize: zsp(12),color: Colors.white),), ), Container( height: hsp(20), alignment: Alignment.center, width: constraints.maxWidth*0.15, decoration: BoxDecoration( gradient: LinearGradient(colors: _gradient), borderRadius: const BorderRadius.all(Radius.circular(50)) ), child: Text( widget.item['status']==0?'待确认':widget.item['status']==1?'待采样':widget.item['status']==2?'进行中':widget.item['status']==3? '待检测':widget.item['status']==4?'已完成':widget.item['status']==5?'已拒绝':'', style: TextStyle(fontSize: zsp(11),color: Colors.white), ), ) ], ), Container( width: constraints.maxWidth-hsp(30), padding: EdgeInsets.only(top: hsp(8),bottom: hsp(8)),//${widget.item['content']} child: Text('采样计划名称:${widget.item['name']}',style: TextStyle(fontSize: zsp(12),color: Colors.white),maxLines: 2,overflow: TextOverflow.ellipsis,), ), if(widget.item['address']!=null)SizedBox( width: constraints.maxWidth-hsp(30), child: Text('地址:${widget.item['address']??''}',style: TextStyle(fontSize: zsp(12),color: Colors.white),), ), ], ), ), Container( padding: EdgeInsets.all(hsp(15)), decoration: BoxDecoration( border: Border(top: BorderSide(color: const Color(0x99535966),width: hsp(1))) ), child: Row( children: [ SizedBox( width: constraints.maxWidth*0.8-hsp(30), child: Text('取样日期:${widget.item['startTime']??''} - ${widget.item['endTime']??''}',style: TextStyle(fontSize: zsp(12),color: Colors.white),), ), Container( alignment: Alignment.centerRight, width: constraints.maxWidth*0.2, child: Text('详情',style: TextStyle(fontSize: zsp(11),color: const Color(0xFFACB5C5)),), ) ], ), ), ], ); }, ), ), ); } }