|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/home_recommend_list.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart'; |
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -47,43 +47,72 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
width: 35.w, |
|
|
|
|
height: 5.h, |
|
|
|
|
), |
|
|
|
|
GridView.builder( |
|
|
|
|
itemCount:widget.homeRecommendList == null ? 0 : widget.homeRecommendList.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
left: 16.w, |
|
|
|
|
right: 16.w, |
|
|
|
|
top: 13.h, |
|
|
|
|
bottom: 16.h, |
|
|
|
|
), |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
//一行的Widget数量 |
|
|
|
|
// GridView.builder( |
|
|
|
|
// itemCount:widget.homeRecommendList == null ? 0 : widget.homeRecommendList.length, |
|
|
|
|
// padding: EdgeInsets.only( |
|
|
|
|
// left: 16.w, |
|
|
|
|
// right: 16.w, |
|
|
|
|
// top: 13.h, |
|
|
|
|
// bottom: 16.h, |
|
|
|
|
// ), |
|
|
|
|
// shrinkWrap: true, |
|
|
|
|
// physics: NeverScrollableScrollPhysics(), |
|
|
|
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
// //一行的Widget数量 |
|
|
|
|
// crossAxisCount: 2, |
|
|
|
|
// //水平子Widget之间间距 |
|
|
|
|
// crossAxisSpacing: 11.w, |
|
|
|
|
// //垂直子Widget之间间距 |
|
|
|
|
// mainAxisSpacing: 16.w, |
|
|
|
|
// //子Widget宽高比例 0.59 |
|
|
|
|
// childAspectRatio: |
|
|
|
|
// 185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), |
|
|
|
|
// ), |
|
|
|
|
// itemBuilder: (context, index) { |
|
|
|
|
// return GestureDetector( |
|
|
|
|
// onTap: () { |
|
|
|
|
// Navigator.of(context).pushNamed( |
|
|
|
|
// '/router/shopping_goods_details', |
|
|
|
|
// arguments: { |
|
|
|
|
// "id":widget.homeRecommendList[index].id, |
|
|
|
|
// "storeId":widget.storeId, |
|
|
|
|
// "tenant":widget.tenant, |
|
|
|
|
// }, |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// child: goodsListItem(widget.homeRecommendList[index]), |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// ), |
|
|
|
|
StaggeredGridView.countBuilder( |
|
|
|
|
crossAxisCount: 2, |
|
|
|
|
//水平子Widget之间间距 |
|
|
|
|
crossAxisSpacing: 11.w, |
|
|
|
|
//垂直子Widget之间间距 |
|
|
|
|
mainAxisSpacing: 16.w, |
|
|
|
|
//子Widget宽高比例 0.59 |
|
|
|
|
childAspectRatio: |
|
|
|
|
185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), |
|
|
|
|
), |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
itemCount: widget.homeRecommendList.length, |
|
|
|
|
mainAxisSpacing: 8, |
|
|
|
|
crossAxisSpacing: 8, |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
// scrollDirection: Axis.vertical, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
onTap: (){ |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/shopping_goods_details', |
|
|
|
|
arguments: { |
|
|
|
|
"id":widget.homeRecommendList[index].id, |
|
|
|
|
"id":widget.homeRecommendList[position].id, |
|
|
|
|
"storeId":widget.storeId, |
|
|
|
|
"tenant":widget.tenant, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: goodsListItem(widget.homeRecommendList[index]), |
|
|
|
|
child: goodsListItem(widget.homeRecommendList[position]), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
staggeredTileBuilder: (position) { |
|
|
|
|
// return StaggeredTile.count(1,position==0?1:1.2); |
|
|
|
|
return StaggeredTile.fit(1); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -91,9 +120,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
Widget goodsListItem(HomeRecommendList homeRecommendList) { |
|
|
|
|
return Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.vertical( |
|
|
|
|
top: Radius.circular(8), |
|
|
|
|
), |
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(10), |
|
|
|
@ -110,18 +137,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
child: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(10), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
ClipRRect( |
|
|
|
|
child: |
|
|
|
|
MImage( |
|
|
|
|
homeRecommendList.imgs[0], |
|
|
|
@ -131,10 +147,12 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
|
), |
|
|
|
|
borderRadius: BorderRadius.vertical( |
|
|
|
|
top: Radius.circular(4), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
padding: EdgeInsets.only(left: 12.w, right: 12.w), |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.only(left: 12.w, right: 12.w,bottom:15.h), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
@ -171,16 +189,19 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 7.h,), |
|
|
|
|
Text( |
|
|
|
|
homeRecommendList?.productName ?? "", |
|
|
|
|
maxLines: 2, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
// maxLines: 2, |
|
|
|
|
// overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
height: 1.2.h, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF353535), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 7.h,), |
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end, |
|
|
|
@ -221,7 +242,6 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|