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.

457 lines
15 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'package:huixiang/view_widget/round_button.dart';
3 years ago
class StoreActivity extends StatefulWidget {
final Map arguments;
final List<Activity> activitys;
StoreActivity(this.arguments, this.activitys);
@override
State<StatefulWidget> createState() {
return _StoreActivity();
}
}
class _StoreActivity extends State<StoreActivity> {
3 years ago
int page = 0;
3 years ago
int isSelected =0;
3 years ago
3 years ago
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
3 years ago
alignment:Alignment.centerLeft,
margin: EdgeInsets.only(top: 20.h, bottom: 20.h,left: 17.w),
child: Row(
children: [
GestureDetector(
onTap: (){setState(() {
page = 0;
});},
child: Text(
S.of(context).diandan,
textAlign: TextAlign.center,
style: TextStyle(
color: page==0?Colors.black:Colors.grey,
fontSize: page==0?16.sp:14.sp,
fontWeight: page==0?FontWeight.bold:FontWeight.normal,
),
),
),
Padding(padding: EdgeInsets.only(left: 10)),
GestureDetector(
onTap: (){setState(() {
page = 1;
});},
child: Text(
S.of(context).xindianhuodong,
textAlign: TextAlign.center,
style: TextStyle(
color: page==1?Colors.black:Colors.grey,
fontSize: page==1?16.sp:14.sp,
fontWeight: page==1?FontWeight.bold:FontWeight.normal,
),
),
),
],
3 years ago
),
),
3 years ago
page == 0 ? order():
3 years ago
(widget.activitys != null && widget.activitys.length > 0)
? Container(
margin: EdgeInsets.only(bottom: 30.h),
child: AspectRatio(
aspectRatio: 1.55,
child: buildSwiper2Bottom(),
),
)
: Container(
width: double.infinity,
height: 30.h,
margin: EdgeInsets.only(bottom: 30.h),
alignment: Alignment.center,
child: Text(
S.of(context).muqianzanwuxingdianhuodong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFA0A0A0),
),
),
),
],
);
}
3 years ago
Widget order(){
return Container(
3 years ago
width: double.infinity,
child: Row(
children: [
Container(
// decoration: BoxDecoration(
// color: Color(0xFFFAFAFA),
// boxShadow: [
// BoxShadow(
// color: Color(0x0D000000),
// offset: Offset(0, 3),
// blurRadius: 14,
// spreadRadius: 0,
// )
// ],
// ),
width: 104.w,
child:ListView.builder(
itemCount:5,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return orderItem(position);
}),
),
Expanded(flex:1,child:Container(
child:ListView.builder(
itemCount:5,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return goodsItem();
}),
)),
],),
3 years ago
);
}
3 years ago
Widget buildSwiper2Bottom() {
return Container(
child: Swiper(
viewportFraction: 0.95,
loop: false,
itemBuilder: (context, position) {
return InkWell(
onTap: () {
if (widget.arguments["source"] != null &&
widget.arguments["source"] == widget.activitys[position].id) {
Navigator.of(context).pop();
} else {
Navigator.of(context).pushNamed('/router/web_page',
arguments: {
"activityId": widget.activitys[position].id,
"source": widget.arguments["id"]
});
}
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 5.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Stack(
children: [
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
MImage(
(widget.activitys != null && widget.activitys.length > position)
? widget.activitys[position].coverImg
: "",
aspectRatio: 2.2,
radius: BorderRadius.vertical(
top: Radius.circular(8),
),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
Container(
padding: EdgeInsets.all(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(widget.activitys != null &&
widget.activitys.length > position)
? widget.activitys[position].storeName
: "",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF000000),
),
),
SizedBox(
height: 4.h,
),
Text(
(widget.activitys != null &&
widget.activitys.length > position)
? widget.activitys[position].mainTitle
: "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF727272),
),
),
],
),
),
],
),
),
Positioned(
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
vertical: 4.h,
horizontal: 8.w,
),
decoration: BoxDecoration(
color: Colors.black.withAlpha(76),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Text(
(widget.activitys != null && widget.activitys.length > position)
? widget.activitys[position].startTime.split(" ")[0]
: "",
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 12.sp,
color: Color(0xD9FFFFFF),
),
),
),
),
],
),
),
);
},
itemCount:
(widget.activitys != null && widget.activitys.length > 0) ? widget.activitys.length : 0,
),
);
}
3 years ago
Widget orderItem(int index) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
onTap: (){setState(() {
isSelected = index;
});},
child: Container(
color: isSelected != index ?Color(0xFFFAFAFA):Colors.white,
child: Padding(padding: EdgeInsets.only(left: 16,right: 28,top:8,bottom: 16),
child: Row(
children: [
Container(
color: isSelected != index ? Color(0xFFFAFAFA):Color(0xFF32A060),
width: 2.w,
height: 17.h,
),
SizedBox(width: 10.w,),
Text(
"人气推荐",
textAlign: TextAlign.center,
style: TextStyle(
color:isSelected != index ?Color(0xFF202020):Color(0xFF000000),
fontSize:12.sp,
fontWeight: MyFontWeight.medium,
),
),
],
),),
),
),
],
),
);
}
Widget goodsItem() {
return Container(
color: Colors.white,
padding: EdgeInsets.only(right: 16.w),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(width: 12.w
),
MImage(
"assets/image/default_1.png",
width: 70,
height: 70,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(width:10),
Expanded(child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"手工啵啵奶茶",
style: TextStyle(
color:Colors.black,
fontSize:13.sp,
fontWeight: MyFontWeight.medium,
),
),
SizedBox(height:2),
Row(
children: [
Text(
"无香精",
style: TextStyle(
color:Color(0xFF4C4C4C),
fontSize:10.sp,
fontWeight: MyFontWeight.regular,
),
),
SizedBox(width:10),
Text(
"无香精",
style: TextStyle(
color:Color(0xFF4C4C4C),
fontSize:10.sp,
fontWeight: MyFontWeight.regular,
),
)
],
),
SizedBox(height:7),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"会员价",
style: TextStyle(
color:Color(0xFFFF7A1A),
fontSize:10.sp,
fontWeight: MyFontWeight.medium,
),
),
Text(
"¥19.00",
style: TextStyle(
color:Color(0xFFFF7A1A),
fontSize:11.sp,
fontWeight: MyFontWeight.medium,
),
)
],
),
Row(
children: [
Text(
"原价",
style: TextStyle(
color:Color(0xFFA29E9E),
fontSize:9.sp,
fontWeight: MyFontWeight.regular,
),
),
SizedBox(width:10),
Text(
"¥19.00",
style: TextStyle(
color:Color(0xFFA29E9E),
fontSize:10.sp,
fontWeight: MyFontWeight.regular,
),
)
],
),
],
),
Spacer(),
true?RoundButton(
width: 49.w,
text: "选规格",
textColor: Colors.white,
fontWeight: MyFontWeight.medium,
radius: 11,
backgroup: Color(0xFF32A060),
fontSize: 11.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
):
InkWell(
onTap: () {
},
child: Image.asset(
"assets/image/reduce.png",
width: 22,
height: 22,
),
),
if(false)
Padding(padding: EdgeInsets.only(left: 8,right: 8),
child:Text(
"1",
style: TextStyle(
color:Colors.black,
fontSize:14.sp,
fontWeight: MyFontWeight.medium,
),
),),
if(false)
InkWell(
onTap: () {
},
child: Image.asset(
"assets/image/add.png",
width: 22,
height: 22,
),
),
],
),
],
),)
],
),
);
}
3 years ago
}