YSCourse.dart 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane/code/YSCourseDetail.dart';
  5. import 'package:ysairplane/tools/YSNetWorking.dart';
  6. import 'package:ysairplane/tools/YSTools.dart';
  7. class YSCourse extends StatefulWidget {
  8. @override
  9. _YSCourseState createState() => _YSCourseState();
  10. }
  11. class _YSCourseState extends State<YSCourse> with AutomaticKeepAliveClientMixin{
  12. int _selected = 0;
  13. int _page = 1;
  14. List _dataArray = [];
  15. @override
  16. bool get wantKeepAlive => true;
  17. @override
  18. void initState() {
  19. Future.delayed(Duration(seconds: 0)).then((value){
  20. _refreshData();
  21. });
  22. super.initState();
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. super.build(context);
  27. return Scaffold(
  28. backgroundColor: Color(0xFFF5F5F5),
  29. appBar: CupertinoNavigationBar(
  30. transitionBetweenRoutes: false,
  31. backgroundColor: Colors.white,
  32. border: Border(),
  33. middle: Container(
  34. margin: EdgeInsets.only(left: wsp(150),right: wsp(150)),
  35. width: MediaQuery.of(context).size.width-wsp(300),
  36. child: ListView.builder(
  37. itemBuilder: (context,index){
  38. return GestureDetector(
  39. onTap: (){
  40. _selected = index;
  41. _refreshData();
  42. },
  43. child: Container(
  44. width: (MediaQuery.of(context).size.width-wsp(300))/3,
  45. alignment: Alignment.center,
  46. child: Text('${index==0?'全部':index==1?'未出行':'已完成'}',
  47. style: TextStyle(color: _selected==index?Color(0xFF2674ED):Color(0xFF999999),fontWeight: _selected==index?FontWeight.bold:FontWeight.normal,fontSize: zsp(34)),),
  48. ),
  49. );
  50. },
  51. itemCount: 3,
  52. padding: EdgeInsets.all(0),
  53. scrollDirection: Axis.horizontal,
  54. ),
  55. ),
  56. ),
  57. body: EasyRefresh(
  58. onRefresh: _refreshData,
  59. onLoad: _loadMoreData,
  60. header: TaurusHeader(
  61. ),
  62. footer: TaurusFooter(
  63. ),
  64. child: ListView.separated(
  65. itemBuilder: (context,index){
  66. return GestureDetector(
  67. onTap: (){
  68. Navigator.of(context).push(
  69. CupertinoPageRoute(
  70. builder: (context){
  71. return YSCourseDetail(orderStr: _dataArray[index]['orderSn'],);
  72. }
  73. )
  74. );
  75. },
  76. child: Container(
  77. decoration: BoxDecoration(
  78. color: Colors.white,
  79. borderRadius: BorderRadius.all(Radius.circular(10))
  80. ),
  81. child: Column(
  82. children: [
  83. Container(
  84. padding: EdgeInsets.all(hsp(20)),
  85. child: Row(
  86. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  87. children: [
  88. Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF141416),fontWeight: FontWeight.bold),),
  89. Text(_dataArray[index]['consumed']==1?'未出行':'已完成',style: TextStyle(fontSize: zsp(30),color: Color(0xFF2B7BF6)),)
  90. ],
  91. ),
  92. ),
  93. Divider(height: 1,thickness: 1,color: Color(0xFFF5F5F5),),
  94. Container(
  95. padding: EdgeInsets.all(hsp(20)),
  96. child: Row(
  97. children: [
  98. Icon(Icons.access_time,color: Color(0xFFBABAC6),size: hsp(28),),
  99. Text(' ${_dataArray[index]['time']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF24242B)),)
  100. ],
  101. ),
  102. ),
  103. _dataArray[index]['arrive']!=null?Container(
  104. width: MediaQuery.of(context).size.width-hsp(80),
  105. child: ListView.builder(
  106. itemBuilder: (context,indexSub2){
  107. return Row(
  108. crossAxisAlignment: CrossAxisAlignment.start,
  109. children: [
  110. Column(
  111. children: [
  112. Container(
  113. height: hsp(28),
  114. width: hsp(28),
  115. decoration: BoxDecoration(
  116. color: Colors.white,
  117. borderRadius: BorderRadius.all(Radius.circular(50)),
  118. border: Border.all(color: indexSub2==0?Color(0xFF02C094):Color(0xFFFB9658),width: wsp(6))
  119. ),
  120. margin: EdgeInsets.only(top: hsp(7),bottom: hsp(7)),
  121. ),
  122. if(indexSub2<1)Container(
  123. height: hsp(28),
  124. child: DashedRect(
  125. color: Color(0xFFCACAD4),
  126. strokeWidth: 1,
  127. gap: 1
  128. ),
  129. )
  130. ],
  131. ),
  132. Container(
  133. child: indexSub2==1?Row(
  134. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  135. children: [
  136. Text(' ${_dataArray[index]['setout']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  137. Icon(Icons.keyboard_arrow_right,size: hsp(50),color: Color(0xFF999999),)
  138. ],
  139. ):Text(' ${_dataArray[index]['arrive']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  140. width: MediaQuery.of(context).size.width-hsp(120),
  141. ),
  142. ],
  143. );
  144. },
  145. itemCount: 2,
  146. shrinkWrap: true,
  147. physics: NeverScrollableScrollPhysics(),
  148. padding: EdgeInsets.only(bottom: hsp(20)),
  149. ),
  150. ):Container(
  151. child: Text('${_dataArray[index]['title']}',style: TextStyle(color: Color(0xFF68686F),fontSize: zsp(28))),
  152. width: MediaQuery.of(context).size.width-hsp(80),
  153. alignment: Alignment.centerLeft,
  154. padding: EdgeInsets.only(bottom: hsp(20)),
  155. )
  156. ],
  157. ),
  158. ),
  159. );
  160. },
  161. separatorBuilder: (context,index){
  162. return Divider(height: hsp(16),thickness: hsp(16),color: Color(0xFFF5F5F5),);
  163. },
  164. itemCount: _dataArray.length,
  165. padding: EdgeInsets.all(hsp(20)),
  166. shrinkWrap: true,
  167. ),
  168. ),
  169. );
  170. }
  171. Future<void> _refreshData() async{
  172. _page = 1;
  173. Map request = {};
  174. request['type'] = _selected+1;
  175. request['pageNum'] = _page;
  176. request['pageSize'] = 10;
  177. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',parameter: request,isLoading: false,isToken: true);
  178. if(dict!=null){
  179. setState(() {
  180. _dataArray = dict['data']['resultList'];
  181. });
  182. }
  183. }
  184. Future<void> _loadMoreData() async{
  185. _page++;
  186. Map request = {};
  187. request['type'] = _selected+1;
  188. request['pageNum'] = _page;
  189. request['pageSize'] = 10;
  190. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/orderList',parameter: request,isLoading: false,isToken: true);
  191. if(dict!=null){
  192. setState(() {
  193. _dataArray.addAll(dict['data']['resultList']);
  194. });
  195. }
  196. }
  197. }