123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:ysairplane2/base/YSBase.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- class YSChoosePlane extends StatefulWidget {
- final int category,type;
- const YSChoosePlane({Key key, this.type, this.category}) : super(key: key);
- @override
- _YSChoosePlaneState createState() => _YSChoosePlaneState();
- }
- class _YSChoosePlaneState extends State<YSChoosePlane> {
- int _index = 9999;
- int _page = 1;
- List _dataArray = [];
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- _refreshData();
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ystitle: '飞机类型',
- yschild: Container(
- height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
- child: EasyRefresh(
- onRefresh: _refreshData,
- onLoad: _loadMoreData,
- header: TaurusHeader(
- ),
- footer: TaurusFooter(
- ),
- child: ListView.separated(
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- Navigator.of(context).pop(_dataArray[index]);
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- padding: EdgeInsets.all(hsp(30)),
- color: Colors.white,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- width: MediaQuery.of(context).size.width-hsp(150),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [//到达准点率${_dataArray[index]['seatNum']}% |
- Text('${_dataArray[index]['model']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold),),
- Text('最多容纳${_dataArray[index]['seatNum']}人 ',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
- ],
- ),
- ),
- Icon(Icons.check,color: _index==index?Color(0xFF007EFF):Colors.transparent,size: hsp(50),)
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF5F5F5),);
- },
- itemCount: _dataArray.length,
- padding: EdgeInsets.all(0),
- ),
- ),
- ),
- );
- }
- Future<void> _refreshData() async{
- _page = 1;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneinformation/list',
- parameter: {'category':widget.category,'pageNo':_page,'pageSize':10,'type':widget.type},isLoading: false,isToken: false);
- if(dict!=null){
- setState(() {
- _dataArray = dict['data']['resultList'];
- });
- }
- }
- Future<void> _loadMoreData() async{
- _page++;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneinformation/list',
- parameter: {'category':widget.category,'pageNo':_page,'pageSize':10,'type':widget.type},isLoading: false,isToken: false);
- if(dict!=null){
- setState(() {
- _dataArray.add(dict['data']['resultList']);
- });
- }
- }
- }
|