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.

224 lines
7.4 KiB

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:image_stack/image_stack.dart';
import 'package:akuCommunity/utils/screenutil.dart';
import 'package:akuCommunity/widget/cached_image_wrapper.dart';
import 'package:akuCommunity/routers/page_routers.dart';
class HomeCard extends StatefulWidget {
final String title;
final String subtitleOne;
final String subtitleTwo;
final bool isActivity;
final String imagePath;
HomeCard(
{this.title,
this.subtitleOne,
this.subtitleTwo,
this.imagePath,
this.isActivity,
Key key})
: super(key: key);
@override
_HomeCardState createState() => _HomeCardState();
}
class _HomeCardState extends State<HomeCard> {
List<String> images = [
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1151143562,4115642159&fm=26&gp=0.jpg",
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2551412680,857245643&fm=26&gp=0.jpg",
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3604827221,1047385274&fm=26&gp=0.jpg",
];
Widget _button(String buttonName) {
return InkWell(
onTap: () {
switch (widget.isActivity) {
case true:
Navigator.pushNamed(
context, PageName.activities_details_page.toString(),
arguments: Bundle()
..putMap('details', {
'title': widget.title,
'imagePath': widget.imagePath,
'isOver': false,
'isVoteOver': false,
'isVote': false,
'memberList': images
}));
break;
case false:
var shopInfo;
shopInfo = {
'itemid': '1',
'itemtitle':widget.title,
'taobao_image': "${widget.imagePath},${widget.imagePath}",
'itemprice': '69.9',
'itemshorttitle': widget.title,
'itempic_copy': widget.imagePath,
'itemdesc': widget.title,
'itempic': widget.imagePath
};
Navigator.pushNamed(context, PageName.goods_details_page.toString(),
arguments: Bundle()
..putString(
'shoplist', json.encode(shopInfo).toString()));
break;
default:
}
},
child: Container(
4 years ago
height: 44.w,
width: 120.w,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xffffc40c),
borderRadius:
4 years ago
BorderRadius.all(Radius.circular(22.w)),
),
4 years ago
padding: EdgeInsets.symmetric(vertical: 8.w),
child: Text(
buttonName,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Color(0xff4a4b51),
4 years ago
fontSize: 20.sp),
),
),
);
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
margin: EdgeInsets.symmetric(
4 years ago
horizontal: 32.w,
),
padding: EdgeInsets.only(
4 years ago
left: 24.w,
right: 24.w,
bottom: 40.w,
),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
4 years ago
borderRadius: BorderRadius.all(Radius.circular(8.w)),
border:
4 years ago
Border.all(color: Color(0xffe8e8e8), width: 2.w),
),
4 years ago
padding: EdgeInsets.only(bottom: 24.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
child: ClipRRect(
borderRadius: BorderRadius.only(
4 years ago
topLeft: Radius.circular(8.w),
topRight: Radius.circular(8.w),
),
child: CachedImageWrapper(
url: widget.imagePath,
4 years ago
width: 638.w,
height: 210.w,
),
),
),
],
),
Container(
margin: EdgeInsets.only(
4 years ago
top: 16.w,
left: 24.w,
),
child: Text(
widget.title,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Color(0xff4a4b51),
4 years ago
fontSize: 28.sp),
),
),
Container(
margin: EdgeInsets.only(
4 years ago
top: 16.w,
left: 24.w,
right: 24.w,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
4 years ago
style: TextStyle(fontSize: 24.sp),
children: <InlineSpan>[
TextSpan(
text: widget.isActivity ? '地点:' : '原产地区:',
style: TextStyle(color: Color(0xff999999))),
TextSpan(
text: widget.subtitleOne,
style: TextStyle(color: Color(0xff4a4b51))),
],
),
),
Container(
4 years ago
margin: EdgeInsets.only(top: 8.w),
child: RichText(
text: TextSpan(
4 years ago
style: TextStyle(fontSize: 24.sp),
children: <InlineSpan>[
TextSpan(
text: widget.isActivity ? '活动时间:' : '预计到货:',
style: TextStyle(color: Color(0xff999999))),
TextSpan(
text: widget.subtitleTwo,
style: TextStyle(color: Color(0xff4a4b51))),
],
),
),
),
],
),
widget.isActivity ? SizedBox() : _button('去团购')
],
),
),
widget.isActivity
? Container(
margin: EdgeInsets.only(
4 years ago
top: 16.w,
right: 24.w,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
4 years ago
margin: EdgeInsets.only(left: 80.w),
child: ImageStack(
imageList: images,
4 years ago
imageRadius: 44.sp,
imageCount: 3,
imageBorderWidth: 1,
totalCount: 3,
),
),
_button('去看看'),
],
),
)
: SizedBox(),
],
),
),
);
}
}