YSChoosePlane.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_easyrefresh/easy_refresh.dart';
  4. import 'package:ysairplane/base/YSBase.dart';
  5. import 'package:ysairplane/tools/YSNetWorking.dart';
  6. import 'package:ysairplane/tools/YSTools.dart';
  7. class YSChoosePlane extends StatefulWidget {
  8. final int type;
  9. const YSChoosePlane({Key key, this.type}) : super(key: key);
  10. @override
  11. _YSChoosePlaneState createState() => _YSChoosePlaneState();
  12. }
  13. class _YSChoosePlaneState extends State<YSChoosePlane> {
  14. int _index = 9999;
  15. int _page = 1;
  16. List _dataArray = [];
  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. return YSBase(
  27. ystitle: '飞机类型',
  28. yschild: Container(
  29. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  30. child: EasyRefresh(
  31. onRefresh: _refreshData,
  32. onLoad: _loadMoreData,
  33. header: TaurusHeader(
  34. ),
  35. footer: TaurusFooter(
  36. ),
  37. child: ListView.separated(
  38. itemBuilder: (context,index){
  39. return GestureDetector(
  40. onTap: (){
  41. Navigator.of(context).pop(_dataArray[index]);
  42. },
  43. behavior: HitTestBehavior.opaque,
  44. child: Container(
  45. padding: EdgeInsets.all(hsp(30)),
  46. color: Colors.white,
  47. child: Row(
  48. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  49. children: [
  50. Container(
  51. width: MediaQuery.of(context).size.width-hsp(150),
  52. child: Column(
  53. crossAxisAlignment: CrossAxisAlignment.start,
  54. children: [
  55. Text('${_dataArray[index]['partnerName']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold),),
  56. Text('${_dataArray[index]['model']} | 到达准点率${_dataArray[index]['seatNum']}% | 最多容纳${_dataArray[index]['seatNum']}人 ',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  57. ],
  58. ),
  59. ),
  60. Icon(Icons.check,color: _index==index?Color(0xFF007EFF):Colors.transparent,size: hsp(50),)
  61. ],
  62. ),
  63. ),
  64. );
  65. },
  66. separatorBuilder: (context,index){
  67. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF5F5F5),);
  68. },
  69. itemCount: _dataArray.length,
  70. padding: EdgeInsets.all(0),
  71. ),
  72. ),
  73. ),
  74. );
  75. }
  76. Future<void> _refreshData() async{
  77. _page = 1;
  78. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneinformation/list',parameter: {'category':widget.type,'pageNo':_page,'pageSize':10,'type':7},isLoading: false,isToken: false);
  79. if(dict!=null){
  80. setState(() {
  81. _dataArray = dict['data']['resultList'];
  82. });
  83. }
  84. }
  85. Future<void> _loadMoreData() async{
  86. _page++;
  87. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneinformation/list',parameter: {'category':widget.type,'pageNo':_page,'pageSize':10,'type':7},isLoading: false,isToken: false);
  88. if(dict!=null){
  89. setState(() {
  90. _dataArray.add(dict['data']['resultList']);
  91. });
  92. }
  93. }
  94. }