YSMineGatherPlan.dart 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_tzh/base/YSBase.dart';
  3. import 'package:flutter_tzh/mine/view/YSSearchView.dart';
  4. import 'package:flutter_tzh/tool/YSRefrehLoad.dart';
  5. import 'package:flutter_tzh/tool/YSTools.dart';
  6. import '../home/view/YSHomeListItemView.dart';
  7. class YSMineGatherPlan extends StatefulWidget {
  8. const YSMineGatherPlan({Key? key}) : super(key: key);
  9. @override
  10. YSMineGatherPlanState createState() => YSMineGatherPlanState();
  11. }
  12. class YSMineGatherPlanState extends State<YSMineGatherPlan> with SingleTickerProviderStateMixin{
  13. String _searchStr = '';
  14. final List _titles = [
  15. {'title':'全部','type':null},
  16. {'title':'待确认','type':0},
  17. {'title':'待采样','type':1},
  18. {'title':'进行中','type':2},
  19. {'title':'待检测','type':3},
  20. {'title':'已完成','type':4},
  21. {'title':'已拒绝','type':5}
  22. ];
  23. bool _refresh = false;
  24. late TabController _tabController;
  25. @override
  26. void initState() {
  27. _tabController = TabController(
  28. vsync: this,
  29. length: _titles.length,
  30. );
  31. super.initState();
  32. }
  33. @override
  34. Widget build(BuildContext context) {
  35. return YSBase(
  36. ysTitle: '采样计划',
  37. ysChild: Padding(
  38. padding: EdgeInsets.only(top: hsp(20)),
  39. child: Column(
  40. children: [
  41. YSSearchView(postSearch: (value){
  42. _searchStr = value;
  43. // refreshKey4.currentState?.refresh(request: {'name':_searchStr});
  44. _refresh = !_refresh;
  45. setState(() {});
  46. },),
  47. DefaultTabController(
  48. length: _titles.length,
  49. child: Column(
  50. children: [
  51. Container(
  52. height: hsp(44),
  53. width: MediaQuery.of(context).size.width,
  54. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  55. child: TabBar(
  56. controller: _tabController,
  57. indicatorColor: Colors.transparent,
  58. isScrollable: true,
  59. labelColor: const Color(0xFF31D19E),
  60. indicatorWeight: 3,
  61. indicatorSize: TabBarIndicatorSize.label,
  62. labelStyle: TextStyle(fontSize: zsp(14)),
  63. unselectedLabelColor: const Color(0xFFACB5C5),
  64. tabs: _titles.map((f) {//text: '· ${f['title']}'
  65. return Tab(
  66. child: Row(
  67. mainAxisSize: MainAxisSize.min,
  68. children: [
  69. Text('·',style: TextStyle(fontSize: zsp(30)),),
  70. Text(f['title'])
  71. ],
  72. ),
  73. );
  74. }).toList(),
  75. ),
  76. ),
  77. SizedBox(
  78. height: ysHeight(context)-ysTOP(context)-44-hsp(126),
  79. width: MediaQuery.of(context).size.width,
  80. // key: Key('mine$_refreshIndex'),
  81. child: TabBarView(
  82. controller: _tabController,
  83. children: _titles.map((f) {
  84. return _refresh?SizedBox(
  85. child: YSPlanDataView(item: f,searchStr: _searchStr,),
  86. ):YSPlanDataView(item: f,searchStr: _searchStr,);
  87. }).toList(),
  88. ),
  89. )
  90. ],
  91. ),
  92. ) ],
  93. ),
  94. ),
  95. );
  96. }
  97. }
  98. class YSPlanDataView extends StatefulWidget {
  99. final Map item;
  100. final String searchStr;
  101. const YSPlanDataView({Key? key, required this.item, this.searchStr = ''}) : super(key: key);
  102. @override
  103. YSPlanDataViewState createState() => YSPlanDataViewState();
  104. }
  105. class YSPlanDataViewState extends State<YSPlanDataView> {
  106. List _dataArray = [];
  107. @override
  108. Widget build(BuildContext context) {
  109. return YSRefreshLoad(
  110. // key: refreshKey4,
  111. postData: (value) {
  112. _dataArray = value;
  113. // LogUtil.d('YSRefreshLoad====$_dataArray');
  114. setState(() {});
  115. },
  116. url: '/samp/search',
  117. request: {'name':widget.searchStr,'status':widget.item['type']},
  118. child: SingleChildScrollView(
  119. child: ListView.separated(
  120. itemBuilder: (context, index) {
  121. Map item = _dataArray[index];
  122. return YSHomeListItemView(item: item);
  123. },
  124. separatorBuilder: (context,index){
  125. return Container(height: hsp(16),);
  126. },
  127. itemCount: _dataArray.length,
  128. padding: const EdgeInsets.all(0),
  129. shrinkWrap: true,
  130. physics: const NeverScrollableScrollPhysics(),
  131. ),
  132. ),
  133. );
  134. }
  135. }