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.
 
 
 
 
 
 

147 lines
4.7 KiB

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/retrofit/data/banner.dart';
import 'package:huixiang/retrofit/data/home_rank.dart';
import 'package:huixiang/retrofit/data/shopping_home_config.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(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
height: 235.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.white,
),
margin: EdgeInsets.only(
left: 14.w, right: 14.w, top: 14.h, bottom: 24.h),
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: [
Stack(
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.r),
),
child: MImage(
commodityZone?.productImg ?? "",
fit: BoxFit.contain,
radius: BorderRadius.circular(4.r),
width: 158,
height: 158,
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: FontWeight.bold,
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,
color: Color(0xFFB3B3B3),
),
),
],
)),
],
),
);
}
}