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.
 
 
 
 
 
 

170 lines
5.1 KiB

import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/goods.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class HomeIntegralStore extends StatefulWidget {
final List<Goods> gooods;
HomeIntegralStore(this.gooods);
@override
State<StatefulWidget> createState() {
return _HomeIntegralStore();
}
}
class _HomeIntegralStore extends State<HomeIntegralStore> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
left: 16.5.w,
right: 16.5.w,
bottom: 20.h,
top: 10.h,
),
padding: EdgeInsets.only(bottom: 3.h, top: 16.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(left: 16,bottom: 10),child: Text(
"大家都在兑换",
textAlign: TextAlign.end,
style: TextStyle(
color: Colors.black,
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
),),
Divider(
thickness: 1,
color: Color(0xffF2F2F2),
),
integralStore(),
],
),
);
}
Widget integralStore() {
return GridView.builder(
itemCount: (widget.gooods != null && widget.gooods.length > 0)
? (widget.gooods.length > 2 ? 2 : widget.gooods.length)
: 0,
padding: EdgeInsets.all(13.w),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//一行的Widget数量
crossAxisCount: 2,
//水平子Widget之间间距
crossAxisSpacing: 13,
//垂直子Widget之间间距
mainAxisSpacing: 16,
//子Widget宽高比例
childAspectRatio: AppUtils.textScale(context) > 1
? (1 - ((AppUtils.textScale(context) - 1)))
: 0.85,
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": widget.gooods[index].id});
},
child: buildItem(widget.gooods[index]),
);
},
);
}
Widget buildItem(Goods goods) {
return Container(
alignment: Alignment.center,
child: Column(
children: [
MImage(
goods.mainImgPath,
aspectRatio: 5 / 3,
radius: BorderRadius.circular(4),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
height: 4.h,
),
Container(
margin: EdgeInsets.only(left: 8.w, right: 8.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 14.h,
),
Row(
children: [
Expanded(
flex: 1,
child: Text(
goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff353535),
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
),
),
),
BorderText(
padding: EdgeInsets.all(2.h),
text: S.of(context).haowu,
fontSize: 12.sp,
fontWeight: FontWeight.bold,
textColor: Color(0xFF32A060),
borderColor: Color(0xFF32A060),
borderWidth: 1.w,
),
],
),
SizedBox(
height: 5.h,
),
Text(
goods.description,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
)
],
),
);
}
}