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.
aku_new_community/lib/widget/sliver_goods_card.dart

146 lines
5.5 KiB

import 'dart:convert';
4 years ago
import 'package:akuCommunity/pages/goods_details/goods_details_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
4 years ago
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/model/aku_shop_model.dart';
import 'package:akuCommunity/widget/cached_image_wrapper.dart';
class SliverGoodsCard extends StatelessWidget {
final bool isShow;
final List<AkuShopModel> shoplist;
const SliverGoodsCard({Key key, this.isShow = false, this.shoplist})
: super(key: key);
@override
Widget build(BuildContext context) {
return SliverGrid(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return InkWell(
onTap: () {
4 years ago
GoodsDetailsPage(
bundle: Bundle()
..putString(
'shoplist', json.encode(shoplist[index]).toString()),
).to;
},
child: Container(
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Stack(
children: [
Container(
child: CachedImageWrapper(
url: shoplist[index].itempic,
4 years ago
width: 333.w,
height: 344.w,
),
),
],
),
Padding(
padding: EdgeInsets.only(
4 years ago
left: 12.w,
right: 25.w,
top: 20.w,
),
child: Container(
4 years ago
width: 296.w,
child: Text(
shoplist[index].itemtitle,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
4 years ago
fontSize: 24.sp,
color: Color(0xff4a4b51),
),
),
),
),
Container(
margin: EdgeInsets.only(
4 years ago
top: 20.w,
left: 12.w,
right: 8.w,
bottom: 17.w,
),
child: Row(
mainAxisAlignment: isShow
? MainAxisAlignment.start
: MainAxisAlignment.spaceBetween,
children: [
Container(
4 years ago
margin: EdgeInsets.only(right: 8.w),
child: Text(
'${shoplist[index].itemprice}',
style: TextStyle(
color: Color(0xffe60e0e),
4 years ago
fontSize: 28.sp,
fontWeight: FontWeight.w500,
),
),
),
isShow
? Text(
'${shoplist[index].itemsale}人已付款',
style: TextStyle(
color: Color(0xff999999),
4 years ago
fontSize: 20.w,
),
)
: InkWell(
onTap: () {
4 years ago
GoodsDetailsPage(
bundle: Bundle()
..putString(
'shoplist',
json
.encode(shoplist[index])
.toString()),
).to;
},
child: Container(
4 years ago
width: 134.w,
alignment: Alignment.center,
padding: EdgeInsets.only(
4 years ago
top: 6.w,
bottom: 5.w,
),
decoration: BoxDecoration(
color: Color(0xffffc40c),
borderRadius:
BorderRadius.all(Radius.circular(20.w)),
),
child: Text(
'立即购买',
style: TextStyle(
4 years ago
fontSize: 24.sp,
color: Color(0xff333333),
),
),
),
)
],
),
),
],
),
),
);
},
childCount: shoplist.length,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
4 years ago
mainAxisSpacing: 30.w,
crossAxisSpacing: 20.w,
childAspectRatio: 343.w / 539.w),
);
}
}