You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
4.3 KiB
145 lines
4.3 KiB
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/data/home_rank.dart'; |
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
class HomeRecommendGoods extends StatefulWidget { |
|
final HomeRank? homeRank; |
|
|
|
HomeRecommendGoods(this.homeRank); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _HomeRecommendGoods(); |
|
} |
|
} |
|
|
|
class _HomeRecommendGoods extends State<HomeRecommendGoods> { |
|
ApiService? apiService; |
|
final RefreshController refreshController = RefreshController(); |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
height: 240.h, |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(6), |
|
color: Colors.white, |
|
), |
|
margin: EdgeInsets.only( |
|
top: 8.h, |
|
left: 14.w, |
|
right: 14.w, |
|
), |
|
child: ListView.builder( |
|
scrollDirection: Axis.horizontal, |
|
physics: BouncingScrollPhysics(), |
|
itemCount: widget.homeRank?.commodityZone?.length ?? 0, |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () { |
|
Navigator.of(context).pushNamed( |
|
'/router/store_order', |
|
arguments: { |
|
"id": widget.homeRank!.commodityZone![position].storeId, |
|
"tenant": |
|
widget.homeRank!.commodityZone![position].tenantCode, |
|
"storeName": "" |
|
}, |
|
); |
|
}, |
|
child: |
|
recommendGoodsItem(widget.homeRank!.commodityZone![position]), |
|
); |
|
}, |
|
), |
|
); |
|
} |
|
|
|
Widget recommendGoodsItem(CommodityZone commodityZone) { |
|
return Container( |
|
width: 158.w, |
|
margin: EdgeInsets.only( |
|
right: 7.w, |
|
left: 12.w, |
|
top: 12.h, |
|
bottom: 12.h, |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Container( |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(4.r), |
|
), |
|
child: MImage( |
|
commodityZone.productImg ?? "", |
|
fit: BoxFit.contain, |
|
radius: BorderRadius.circular(4.r), |
|
width: 158.w, |
|
height: 158.h, |
|
errorSrc: "assets/image/default_2_1.webp", |
|
fadeSrc: "assets/image/default_2_1.webp", |
|
), |
|
), |
|
SizedBox( |
|
height: 8.h, |
|
), |
|
Text( |
|
commodityZone.productName ?? "", |
|
maxLines: 1, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 13.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
SizedBox( |
|
height: 4.h, |
|
), |
|
Expanded( |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
"¥${AppUtils.calculateDouble(double.tryParse("${commodityZone.price}") ?? 0)}", |
|
style: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.medium, |
|
fontFamily: 'JDZhengHT', |
|
color: Color(0xFFF85400), |
|
), |
|
), |
|
SizedBox( |
|
width: 5.w, |
|
), |
|
Text( |
|
"¥${AppUtils.calculateDouble(double.tryParse("${commodityZone.price}") ?? 0)}", |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
decoration: TextDecoration.lineThrough, |
|
fontWeight: MyFontWeight.regular, |
|
fontFamily: 'JDZhengHT', |
|
color: Color(0xFFB3B3B3), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|