import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:liftmanager/internal/bbs/model/coupon_model_page.dart'; import 'package:liftmanager/internal/search/presenter/base_list_provider.dart'; import 'package:liftmanager/internal/wode/presenter/red_list_presenter.dart'; import 'package:liftmanager/mvp/base_page_state.dart'; import 'package:liftmanager/widgets/app_bar.dart'; import 'package:liftmanager/widgets/load_image.dart'; import 'package:liftmanager/widgets/my_refresh_list.dart'; import 'package:liftmanager/widgets/state_layout.dart'; import 'package:provider/provider.dart'; class RedbaoPage extends StatefulWidget { // QuestionList(this.index); // final String index; @override RedbaoPageState createState() => RedbaoPageState(); } class RedbaoPageState extends BasePageState with AutomaticKeepAliveClientMixin { // NewsDetailItem item = NewsDetailItem(); BaseListProvider provider = BaseListProvider(); ScrollController _scrollController = new ScrollController(); int _page = 1; @override void initState() { provider.setStateTypeNotNotify(StateType.loading); super.initState(); _onRefresh(); print(66666); } @override void dispose() { _scrollController.dispose(); super.dispose(); } getScenario(int type) { String str; if (type == 0) { str = "全场通用"; } else if (type == 1) { str = "仅限出诊问诊服务"; } else if (type == 2) { str = "仅限题库"; } else if (type == 3) { str = "仅限视频"; } return str; } @override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width; return ChangeNotifierProvider>( create: (_) => provider, child: Scaffold( resizeToAvoidBottomPadding: true, appBar: MyAppBar(centerTitle: "我的红包"), body: Container( // color: Color(0xFFF1F4FC), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( flex: 1, child: Consumer>( builder: (_, provider, __) { return MyListView( key: Key('red_list'), itemCount: provider.list.length, stateType: provider.stateType, onRefresh: _onRefresh, loadMore: _loadMore, pageSize: 8, hasMore: provider.hasMore, itemBuilder: (_, index) { return Container( child: Column( children: [ Container( // padding: EdgeInsets.only( // left: ScreenUtil().setWidth(10), // right: ScreenUtil().setWidth(10), // top: ScreenUtil().setWidth(15)), child: InkWell( child: Container( // padding: // EdgeInsets.only( // left: ScreenUtil().setWidth(15), // right: ScreenUtil().setWidth(15), // top: ScreenUtil().setWidth(10), // bottom: ScreenUtil().setWidth(10)), child: Stack( children: [ LoadAssetImage( // image: AssetImage(i['img']), 'img_hongbao_bg', width: width - 5, height: 140, fit: BoxFit.fill, // alignment: Alignment.centerLeft, ), Positioned( top: 20, left: 20, right: 20, child: Row( children: [ LoadAssetImage( // image: AssetImage(i['img']), 'icon_hongbao', width: 30, height: 40, fit: BoxFit.cover, // ScreenUtil().setHeight(141), // // alignment: Alignment.centerLeft, ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '会员专用红包', style: TextStyle( color: Color(0xff282828), fontWeight: FontWeight.bold, fontSize: 17), ), SizedBox( height: 6, ), Text('全场通用,支付立减', style: TextStyle( color: Color(0xff909090), fontSize: 13)), ], ), Expanded(child: Container()), RichText( text: TextSpan( text: '¥', style: TextStyle( color: Color(0xffF95046), fontSize: 18, fontWeight: FontWeight.bold), children: [ TextSpan( text: provider .list[index] .coupon .price .toString(), style: TextStyle( color: Color( 0xffF95046), fontSize: 40, fontWeight: FontWeight .bold)), ])) // Container( // alignment: Alignment.bottomLeft, // child: Row( // children: [ // Container( // alignment: Alignment.bottomLeft, // height: 30, // child: // Text('¥',style: TextStyle(color: Color(0xffF95046)),),), // Text('10',style: TextStyle(color: Color(0xffF95046),fontSize: 40,fontWeight: FontWeight.bold)), // ], // ), // ) ], )), // Positioned( // bottom: 25, // left: 30, // right: 30, // child: Row( // children: [ // Text( // '4天后过期', // style: TextStyle( // color: Color(0xffF95046), // fontSize: 12), // ), // Expanded(child: Container()), // Text( // '有效时间:2020.10.30 11:59', // style: TextStyle( // color: Color(0xff909090), // fontSize: 12), // ), // ], // )) ], ) // Row( // crossAxisAlignment: // CrossAxisAlignment.start, // children: [ // Container( // padding: EdgeInsets.only( // right: // ScreenUtil().setWidth(25), // left: // ScreenUtil().setWidth(10), // top: ScreenUtil() // .setWidth(15)), // child: Icon( // const IconData(0xe630, // fontFamily: "myfont"), // size: 60.0, // color: Color(0xffFE524C), // ), // ), // Column( // crossAxisAlignment: // CrossAxisAlignment.start, // children: [ // Text( // provider // .list[index].coupon.price // .toString(), // textAlign: TextAlign.left, // style: TextStyle( // fontSize: // ScreenUtil().setSp(26), // color: Color(0xff333333), // ), // ), // // Row( // // children: [ // // Text( // // DateUtils.instance // // .getFormartData( // // timeSamp: provider.list[index].coupon.createTime, // // format: "yyyy-MM-dd"), // // textAlign: TextAlign.left, // // style: TextStyle( // // fontSize:ScreenUtil().setSp(14), // // color:Color(0xff999999), // // ), // // ), // // Text( // // "至", // // textAlign: TextAlign.left, // // style: TextStyle( // // fontSize:ScreenUtil().setSp(14), // // color:Color(0xff999999), // // ), // // ), // // Text( // // DateUtils.instance // // .getFormartData( // // timeSamp: provider.list[index].coupon.updateTime, // // format: "yyyy-MM-dd"), // // textAlign: TextAlign.left, // // style: TextStyle( // // fontSize:ScreenUtil().setSp(14), // // color:Color(0xff999999), // // ), // // ), // // ], // // ), // SizedBox(height: 8), // Container( // width: ScreenUtil() // .setWidth(200), // height: 0.5, // color: Color(0xffeeeeee), // child: null, // ), // SizedBox(height: 5), // Text( // getScenario(provider // .list[index] // .coupon // .scenario), // textAlign: TextAlign.left, // style: TextStyle( // fontSize: // ScreenUtil().setSp(14), // color: Color(0xff999999), // ), // ), // ], // ), // ]), ), onTap: () {}, ) // MyCard( // child: // ), ) ], ), ); }, ); })) ], ), ), )); } Future _onRefresh() async { _page = 1; await presenter.getRedList(_page); } Future _loadMore() async { _page++; await presenter.getRedList(_page); } @override RedtListPresenter createPresenter() { return RedtListPresenter(); } bool get wantKeepAlive => true; }