123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:ysairplane2/base/YSBase.dart';
- import 'package:ysairplane2/code/YSHomeMsgDetail.dart';
- import 'package:ysairplane2/code/YSHomeMsgSetting.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- class YSHomeMsg extends StatefulWidget {
- @override
- _YSHomeMsgState createState() => _YSHomeMsgState();
- }
- class _YSHomeMsgState extends State<YSHomeMsg> {
- 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: '消息',
- ysright: GestureDetector(
- child: Icon(Icons.settings,size: hsp(40),color: Color(0xFF444444),),
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(
- builder: (context){
- return YSHomeMsgSetting();
- }
- )
- );
- },
- ),
- yschild: Container(
- width: MediaQuery.of(context).size.width,
- height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
- color: Color(0xFFF1F2F3),
- child: EasyRefresh(
- onRefresh: _refreshData,
- onLoad: _loadMore,
- header: TaurusHeader(),
- footer: TaurusFooter(),
- child: ListView.separated(
- padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
- shrinkWrap: true,
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- setState(() {
- _dataArray[index]['isRead'] = 1;
- });
- Navigator.of(context).push(
- CupertinoPageRoute(
- builder: (context){
- return YSHomeMsgDetail(detailDict: _dataArray[index],);
- }
- )
- );
- },
- child: Container(
- color: Color(0xFFFAFAFA),
- padding: EdgeInsets.all(hsp(30)),
- child: Row(
- children: [
- Stack(
- children: [
- Container(
- height: hsp(100),
- width: hsp(100),
- margin: EdgeInsets.only(top: hsp(5),right: wsp(20)),
- // decoration: BoxDecoration(
- // color: Color(0xFF3E81D0),
- // borderRadius: BorderRadius.all(Radius.circular(5))
- // ),
- child: ClipRRect(
- borderRadius: BorderRadius.all(Radius.circular(5)),
- child: ysImageLoad(
- imageUrl: '${_dataArray[index]['ico']}',
- fit: BoxFit.fill,
- height: hsp(100),
- width: hsp(100),
- ),
- ),
- ),
- if(_dataArray[index]['isRead']==-1)Container(
- height: hsp(20),
- width: hsp(20),
- margin: EdgeInsets.only(left: hsp(85)),
- decoration: BoxDecoration(
- color: Color(0xFFE95D58),
- borderRadius: BorderRadius.all(Radius.circular(hsp(10)))
- ),
- )
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- width: MediaQuery.of(context).size.width-hsp(160)-wsp(20),
- margin: EdgeInsets.only(bottom: hsp(10)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- child: Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)),
- maxLines: 1,overflow: TextOverflow.ellipsis,),
- width: (MediaQuery.of(context).size.width-hsp(160)-wsp(20))*0.6,
- ),
- Text('${_dataArray[index]['createTime']}',style: TextStyle(fontSize: zsp(22),color: Color(0xFFCCCCCC)),),
- ],
- ),
- ),
- Container(
- child: Text('${_dataArray[index]['content']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF999999)),maxLines: 1,overflow: TextOverflow.ellipsis,),
- width: MediaQuery.of(context).size.width-hsp(160)-wsp(20),
- )
- ],
- )
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F3),);
- },
- itemCount: _dataArray.length
- ),
- ),
- ),
- );
- }
- Future<void> _refreshData() async{
- _page = 1;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/message/list',parameter: {'pageNum':_page,'pageSize':10},
- isToken: true,refresh: (){_refreshData();});
- if(dict!=null){
- setState(() {
- _dataArray = dict['data']['resultList'];
- });
- }
- }
- Future<void> _loadMore() async{
- _page++;
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/message/list',parameter: {'pageNum':_page,'pageSize':10},
- isToken: true,refresh: (){_loadMore();});
- if(dict!=null){
- setState(() {
- _dataArray.addAll(dict['data']['resultList']);
- });
- }
- }
- }
|