import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane/code/YSCourseDetail.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; class YSCourse extends StatefulWidget { @override _YSCourseState createState() => _YSCourseState(); } class _YSCourseState extends State with AutomaticKeepAliveClientMixin{ int _selected = 0; int _page = 1; List _dataArray = []; @override bool get wantKeepAlive => true; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _refreshData(); }); super.initState(); } @override Widget build(BuildContext context) { super.build(context); return Scaffold( backgroundColor: Color(0xFFF5F5F5), appBar: CupertinoNavigationBar( transitionBetweenRoutes: false, backgroundColor: Colors.white, border: Border(), middle: Container( margin: EdgeInsets.only(left: wsp(150),right: wsp(150)), width: MediaQuery.of(context).size.width-wsp(300), child: ListView.builder( itemBuilder: (context,index){ return GestureDetector( onTap: (){ _selected = index; _refreshData(); }, child: Container( width: (MediaQuery.of(context).size.width-wsp(300))/3, alignment: Alignment.center, child: Text('${index==0?'全部':index==1?'未出行':'已完成'}', style: TextStyle(color: _selected==index?Color(0xFF2674ED):Color(0xFF999999),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal,fontSize: zsp(34)),), ), ); }, itemCount: 3, padding: EdgeInsets.all(0), scrollDirection: Axis.horizontal, ), ), ), body: EasyRefresh( onRefresh: _refreshData, onLoad: _loadMoreData, header: TaurusHeader( ), footer: TaurusFooter( ), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSCourseDetail(orderStr: _dataArray[index]['orderSn'],); } ) ); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(10)) ), child: Column( children: [ Container( padding: EdgeInsets.all(hsp(20)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF141416),fontWeight: FontWeight.bold),), Text(_dataArray[index]['consumed']==1?'未出行':'已完成',style: TextStyle(fontSize: zsp(30),color: Color(0xFF2B7BF6)),) ], ), ), Divider(height: 1,thickness: 1,color: Color(0xFFF5F5F5),), Container( padding: EdgeInsets.all(hsp(20)), child: Row( children: [ Icon(Icons.access_time,color: Color(0xFFBABAC6),size: hsp(28),), Text(' ${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF24242B)),) ], ), ), _dataArray[index]['arrive']!=null?Container( width: MediaQuery.of(context).size.width-hsp(80), child: ListView.builder( itemBuilder: (context,indexSub2){ return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( children: [ Container( height: hsp(28), width: hsp(28), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50)), border: Border.all(color: indexSub2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6)) ), margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)), ), if(indexSub2<1)Container( height: hsp(28), child: DashedRect( color: Color(0xFFCACAD4), strokeWidth: 1, gap: 1 ), ) ], ), Container( child: indexSub2==1?Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(' ${_dataArray[index]['setout']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFF999999),) ], ):Text(' ${_dataArray[index]['arrive']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), width: MediaQuery.of(context).size.width-hsp(120), ), ], ); }, itemCount: 2, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.only(bottom: hsp(20)), ), ):Container( child: Text('${_dataArray[index]['title']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))), width: MediaQuery.of(context).size.width-hsp(80), alignment: Alignment.centerLeft, padding: EdgeInsets.only(bottom: hsp(20)), ) ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: hsp(16),thickness: hsp(16),color: Color(0xFFF5F5F5),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(hsp(20)), shrinkWrap: true, ), ), ); } Future _refreshData() async{ _page = 1; Map request = {}; request['type'] = _selected+1; request['pageNum'] = _page; request['pageSize'] = 10; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',parameter: request,isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map request = {}; request['type'] = _selected+1; request['pageNum'] = _page; request['pageSize'] = 10; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',parameter: request,isLoading: false,isToken: true); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } }