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.

233 lines
7.5 KiB

// Dart imports:
import 'dart:convert';
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:image_stack/image_stack.dart';
// Project imports:
import 'package:akuCommunity/pages/activities_page/activities_details_page/activities_details_page.dart';
import 'package:akuCommunity/pages/goods_details/goods_details_page.dart';
import 'package:akuCommunity/routers/page_routers.dart';
4 years ago
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/cached_image_wrapper.dart';
//TODO CLEAN BOTTOM CODES.
@Deprecated("sh*t home_card need to be cleaned.")
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:
4 years ago
ActivitiesDetailsPage(
bundle: Bundle()
..putMap('details', {
'title': widget.title,
'imagePath': widget.imagePath,
'isOver': false,
'isVoteOver': false,
'isVote': false,
'memberList': images
}),
).to;
break;
case false:
var shopInfo;
shopInfo = {
'itemid': '1',
4 years ago
'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
};
4 years ago
GoodsDetailsPage(
bundle: Bundle()
..putString('shoplist', json.encode(shopInfo).toString()),
).to;
break;
default:
}
},
child: Container(
4 years ago
height: 44.w,
width: 120.w,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xffffc40c),
4 years ago
borderRadius: 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)),
4 years ago
border: 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(),
],
),
),
);
}
}