import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane/code/YSShortDetail.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; import 'YSSearchResult.dart'; class YSShortPlane extends StatefulWidget { @override _YSShortPlaneState createState() => _YSShortPlaneState(); } class _YSShortPlaneState extends State { int _page = 1; List _dataArray = []; Map _msgDict; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getBackImageData(); _refreshData(); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFFF1F2F3), body: SingleChildScrollView( padding: EdgeInsets.all(0), child: Stack( children: [ Container( height: MediaQuery.of(context).padding.top+hsp(370), width: MediaQuery.of(context).size.width, child: _msgDict==null?Image( image: AssetImage('lib/images/home3.png'), fit: BoxFit.fill, ):CachedNetworkImage( imageUrl: '${_msgDict['background']}', fit: BoxFit.fill, ), ), GestureDetector( onTap: (){ Navigator.pop(context); }, child: Container( margin: EdgeInsets.only(left: hsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(50)), child: Icon(Icons.arrow_back_ios,color: Colors.white,size: hsp(50),), ), ), GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSSearchResult(type: 6,); }) ); }, child: Container( margin: EdgeInsets.only(left: hsp(110),top: MediaQuery.of(context).padding.top+hsp(45)), width: MediaQuery.of(context).size.width-hsp(140), height: hsp(60), decoration: BoxDecoration( color: Colors.black.withOpacity(0.35), borderRadius: BorderRadius.all(Radius.circular(50)) ), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( children: [ Row( children: [ Text('西安',style: TextStyle(fontSize: zsp(26),color: Colors.white),), Icon(Icons.keyboard_arrow_down,color: Colors.white.withOpacity(0.5),size: hsp(40),) ], ), Container( height: hsp(30), width: 0.5, margin: EdgeInsets.only(left: wsp(10),right: wsp(10)), color: Colors.white.withOpacity(0.2), ), Row( children: [ Icon(Icons.search,color: Colors.white.withOpacity(0.5),size: hsp(50),), Text(' 搜索',style: TextStyle(fontSize: zsp(26),color: Colors.white.withOpacity(0.5)),), ], ) ], ), ), ), if(_msgDict!=null)Container( margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)), child: RichText( text: TextSpan( text: '${_msgDict['name']} ', style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold), children: [ TextSpan( text: '${_msgDict['subtitle']}', style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5)) ) ] ), ), ), Container( margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(350)), height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(350), width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Color(0xFFF1F2F3), borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10)) ), child: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-hsp(430)-0.5, child: EasyRefresh( onRefresh: _refreshData, onLoad: _loadMoreData, header: TaurusHeader( ), footer: TaurusFooter( ), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSShortDetail(shortId: _dataArray[index]['id'],); } ) ); }, child: Container( padding: EdgeInsets.all(hsp(30)), child: Row( children: [ Container( height: hsp(200), width: hsp(250), margin: EdgeInsets.only(right: hsp(30)), child: CachedNetworkImage( imageUrl: '${_dataArray[index]['cover']}', fit: BoxFit.fill, ), ), Container( width: MediaQuery.of(context).size.width-hsp(340), height: hsp(200), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text('${_dataArray[index]['setoutInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),), Container( height: 2, width: wsp(40), margin: EdgeInsets.only(left: wsp(20),right: wsp(20)), color: Color(0xFFCCCCCC), ), Text('${_dataArray[index]['arriveInfo']['display']}',style: TextStyle(fontSize: zsp(40),color: Colors.black,fontWeight: FontWeight.bold),) ], ), Text('${_dataArray[index]['dtFlightInformation']['partnerName']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${_dataArray[index]['dtFlightInformation']['model']}',style: TextStyle(fontSize: zsp(24),color: Color(0xFF9A9A9A)),), RichText( text: TextSpan( text: '¥', style: TextStyle(fontSize: zsp(24),color: Color(0xFFEB423B)), children: [ TextSpan( text: '${_dataArray[index]['discountPrice']}', style: TextStyle(fontSize: zsp(42),fontWeight: FontWeight.bold), ), TextSpan( text: '元起', style: TextStyle(fontSize: zsp(20)), ) ] ), ) ], ) ], ), ) ], ), ), ); }, separatorBuilder: (context,index){ return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFEEEEEE),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(0), ), ), ) ), ], ), ), ); } _getBackImageData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':6},isLoading: false,isToken: false); if(dict!=null){ setState(() { _msgDict = dict['data']; }); } } Future _refreshData() async{ _page = 1; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':6,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':6,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray.addAll(dict['data']['resultList']); }); } } }