import 'package:flutter/material.dart'; import 'package:flutter_tzh/base/YSBase.dart'; import 'package:flutter_tzh/mine/view/YSSearchView.dart'; import 'package:flutter_tzh/tool/YSRefrehLoad.dart'; import 'package:flutter_tzh/tool/YSTools.dart'; import '../home/view/YSHomeListItemView.dart'; class YSMineGatherPlan extends StatefulWidget { const YSMineGatherPlan({Key? key}) : super(key: key); @override YSMineGatherPlanState createState() => YSMineGatherPlanState(); } class YSMineGatherPlanState extends State with SingleTickerProviderStateMixin{ String _searchStr = ''; final List _titles = [ {'title':'全部','type':null}, {'title':'待确认','type':0}, {'title':'待采样','type':1}, {'title':'进行中','type':2}, {'title':'待检测','type':3}, {'title':'已完成','type':4}, {'title':'已拒绝','type':5} ]; bool _refresh = false; late TabController _tabController; @override void initState() { _tabController = TabController( vsync: this, length: _titles.length, ); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ysTitle: '采样计划', ysChild: Padding( padding: EdgeInsets.only(top: hsp(20)), child: Column( children: [ YSSearchView(postSearch: (value){ _searchStr = value; // refreshKey4.currentState?.refresh(request: {'name':_searchStr}); _refresh = !_refresh; setState(() {}); },), DefaultTabController( length: _titles.length, child: Column( children: [ Container( height: hsp(44), width: MediaQuery.of(context).size.width, margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)), child: TabBar( controller: _tabController, indicatorColor: Colors.transparent, isScrollable: true, labelColor: const Color(0xFF31D19E), indicatorWeight: 3, indicatorSize: TabBarIndicatorSize.label, labelStyle: TextStyle(fontSize: zsp(14)), unselectedLabelColor: const Color(0xFFACB5C5), tabs: _titles.map((f) {//text: '· ${f['title']}' return Tab( child: Row( mainAxisSize: MainAxisSize.min, children: [ Text('·',style: TextStyle(fontSize: zsp(30)),), Text(f['title']) ], ), ); }).toList(), ), ), SizedBox( height: ysHeight(context)-ysTOP(context)-44-hsp(126), width: MediaQuery.of(context).size.width, // key: Key('mine$_refreshIndex'), child: TabBarView( controller: _tabController, children: _titles.map((f) { return _refresh?SizedBox( child: YSPlanDataView(item: f,searchStr: _searchStr,), ):YSPlanDataView(item: f,searchStr: _searchStr,); }).toList(), ), ) ], ), ) ], ), ), ); } } class YSPlanDataView extends StatefulWidget { final Map item; final String searchStr; const YSPlanDataView({Key? key, required this.item, this.searchStr = ''}) : super(key: key); @override YSPlanDataViewState createState() => YSPlanDataViewState(); } class YSPlanDataViewState extends State { List _dataArray = []; @override Widget build(BuildContext context) { return YSRefreshLoad( // key: refreshKey4, postData: (value) { _dataArray = value; // LogUtil.d('YSRefreshLoad====$_dataArray'); setState(() {}); }, url: '/samp/search', request: {'name':widget.searchStr,'status':widget.item['type']}, child: SingleChildScrollView( child: ListView.separated( itemBuilder: (context, index) { Map item = _dataArray[index]; return YSHomeListItemView(item: item); }, separatorBuilder: (context,index){ return Container(height: hsp(16),); }, itemCount: _dataArray.length, padding: const EdgeInsets.all(0), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), ), ), ); } }