import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/login_info.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/separator.dart'; class NewPeopleReward extends StatefulWidget { final List newUserCouponList; NewPeopleReward(this.newUserCouponList); @override State createState() { return _NewPeopleReward(); } } class _NewPeopleReward extends State { @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: 70.h), child: Column( children: [ Container( width: double.infinity, height: 500.h, padding: EdgeInsets.only(top: 210.h), margin: EdgeInsets.only(top: 20.h, left: 20, right: 20), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage("assets/image/xin_ren.png"), ), ), child: Column( children: [ Expanded( child: reward(), ), GestureDetector( onTap: () { Navigator.of(context).pop(); SmartDialog.showToast("领取成功"); }, child: Container( margin: EdgeInsets.only( left: 60.w, right: 60.w, top: 20.h, bottom: 10.h), decoration: BoxDecoration( gradient: new LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [ Color(0xFFFFDCA1), Color(0xFFFAE4C0), ]), borderRadius: BorderRadius.circular(22.5), ), width: MediaQuery.of(context).size.width, height: 40, alignment: Alignment.center, child: Text( "立即领取", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.sp, color: Color(0xFF4A4748), ), ), ), ), ], ), ), SizedBox(height: 35), GestureDetector( onTap: () { setState(() { Navigator.of(context).pop(); }); }, child: Image.asset( "assets/image/yq_qx.png", width: 34, height: 34, ), ) ], ), ); } Widget reward() { return ListView.builder( padding: EdgeInsets.zero, itemCount: widget.newUserCouponList.length, scrollDirection: Axis.vertical, shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( onTap: () {}, child: rewardItem(widget.newUserCouponList[position]), ); }, ); } Widget rewardItem(NewUserCouponList newUserCouponList) { return Container( height: 69.h, width: double.infinity, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage("assets/image/xin_rq.png"), ), ), margin: EdgeInsets.symmetric(horizontal: 60, vertical: 5), padding: EdgeInsets.only(left: 16.w, right: 25.w), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text.rich( TextSpan( children: [ TextSpan( text: "¥", style: TextStyle( fontSize: 25.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xFFDE5F3B), ), ), TextSpan( text: double.tryParse( "${newUserCouponList.discountAmount}" ?? "0") .toInt() .toString() ?? "", style: TextStyle( fontSize: 35.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xFFDE5F3B), ), ), ], ), ), Expanded(child:Padding( padding: EdgeInsets.only(top: 4, bottom: 4,left:10), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( newUserCouponList.storeName, overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xFF181818), ), ), Text( newUserCouponList.couponName, overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, color: Color(0xFFD3623D), ), ), Text( "有效期至:${(newUserCouponList.useEndTime != null && newUserCouponList.useEndTime != "") ? newUserCouponList.useEndTime.split(" ")[0] : "$newUserCouponList.useEndTime"}", overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF727272), ), ) ], ))), ], ), ); } }