import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../generated/l10n.dart'; import '../../retrofit/data/vip_card_home.dart'; import '../../view_widget/custom_image.dart'; class VipGoodsDiscount extends StatefulWidget { final VipCardHome vipCardHome; VipGoodsDiscount(this.vipCardHome); @override State createState() { return _VipGoodsDiscount(); } } class _VipGoodsDiscount extends State { @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric(vertical: 25.h,horizontal: 14.w), child:Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ (widget?.vipCardHome?.member?.isVip ?? false)? Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( "assets/image/vip_discount_left.webp", width: 21.w, height: 39.h, fit: BoxFit.fill, ), SizedBox(width: 11.w,), Text( S.of(context).huixiangvipkazhuanxiang, style: TextStyle( color: Color(0xff32A060), fontSize:15.sp, fontWeight: MyFontWeight.semi_bold, ), ), SizedBox(width: 11.w,), Image.asset( "assets/image/vip_discount_right.webp", width: 21.w, height: 39.h, fit: BoxFit.fill, ), ],): Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( "assets/image/vip_lock.webp", width: 20, height: 20, fit: BoxFit.cover, ), SizedBox(width: 2.w,), Text( S.of(context).kaitonghuixianghuoququanyi, style: TextStyle( color: Colors.black, fontSize:15.sp, fontWeight: MyFontWeight.semi_bold, ), ), ], ), vipGoodsRecommend(), ], ), ); } Widget vipGoodsRecommend(){ return Container( margin: EdgeInsets.only(top: 12.h), height: 195.h, width: double.infinity, padding: EdgeInsets.only(top: 16.h,left: 8.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(6.w), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withAlpha(12), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ) ], ), child:Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( S.of(context).huiyuanzhuanxiangjiage, style: TextStyle( color: Colors.black, fontSize:15.sp, fontWeight: MyFontWeight.semi_bold, ), ), SizedBox(height:20.h,), vipGoodsRecommendList(), ], ), ); } Widget vipGoodsRecommendList(){ return Container( height: 126.h, child: ListView.builder( scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), itemCount: widget.vipCardHome?.productVips?.length ?? 0, itemBuilder: (context, position) { return GestureDetector( onTap: () { Navigator.of(context) .pushNamed('/router/shop_details_page', arguments: { "id": widget?.vipCardHome?.productVips[position].id, "storeId": widget?.vipCardHome?.productVips[position].storeId, }); }, child: vipGoodsRecommendItem(widget.vipCardHome.productVips[position]), ); }, ), ); } Widget vipGoodsRecommendItem(ProductVips productVips){ return Container( width: 70.w, margin: EdgeInsets.only(right:40.w,left:6.w), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Stack( alignment: Alignment.bottomCenter, children: [ MImage( productVips.thumbnailImg ?? "", width: 70, height: 70, fit: BoxFit.cover, radius: BorderRadius.circular(2), errorSrc: "assets/image/default_1.webp", fadeSrc: "assets/image/default_1.webp", ), if(productVips.vipDiscount != "0.00") Container( width: 70, padding: EdgeInsets.symmetric(vertical:2.h), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomRight: Radius.circular(2.r), bottomLeft: Radius.circular(2.r), ), color: Color(0xff32A060), ), child: Text( "省${productVips.vipDiscount ?? "0"}元", style: TextStyle( color: Colors.white, fontSize:13.sp, fontWeight: MyFontWeight.regular, ),), ), ], ), Padding(padding:EdgeInsets.only(top:6.h,bottom: 4.h), child: Text( productVips.productName ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xff0D0D0D), fontSize:14.sp, fontWeight: MyFontWeight.regular, ),), ), Text( "¥${productVips.vipPrice ?? "0.00"}", style: TextStyle( color: Color(0xff0D0D0D), fontSize:14.sp, fontWeight: MyFontWeight.medium, ),) ], ), ); } }