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.
94 lines
2.6 KiB
94 lines
2.6 KiB
|
|
import 'package:flutter/material.dart'; |
|
import 'package:flutter_swiper/flutter_swiper.dart'; |
|
import 'package:huixiang/retrofit/data/banner.dart'; |
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
class HuiXiangBanner extends StatefulWidget { |
|
|
|
final List<BannerData> bannerData; |
|
|
|
HuiXiangBanner(this.bannerData); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _HuiXiangBanner(); |
|
} |
|
|
|
} |
|
|
|
class _HuiXiangBanner extends State<HuiXiangBanner> { |
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
child: AspectRatio( |
|
aspectRatio: 2.08, |
|
child: Swiper( |
|
viewportFraction: 0.88, |
|
scale: 0.93, |
|
pagination: SwiperPagination( |
|
alignment: Alignment.bottomCenter, |
|
builder: DotSwiperPaginationBuilder( |
|
size: 8, |
|
activeSize: 8, |
|
space: 5, |
|
activeColor: Colors.black, |
|
color: Colors.black.withAlpha(76), |
|
), |
|
), |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return InkWell( |
|
onTap: () { |
|
bannerClick(widget.bannerData[position]); |
|
}, |
|
child: MImage( |
|
(widget.bannerData != null && position < widget.bannerData.length) |
|
? widget.bannerData[position].imgUrl |
|
: "", |
|
fit: BoxFit.cover, |
|
radius: BorderRadius.circular(8), |
|
errorSrc: "assets/image/default_2_1.png", |
|
fadeSrc: "assets/image/default_2_1.png", |
|
), |
|
); |
|
}, |
|
itemCount: (widget.bannerData != null && widget.bannerData.length > 0) |
|
? widget.bannerData.length |
|
: 1), |
|
), |
|
); |
|
} |
|
|
|
/// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) |
|
bannerClick(BannerData bannerData) async { |
|
switch (bannerData.contentType) { |
|
case 1: |
|
Navigator.of(context).pushNamed('/router/integral_store_page', |
|
arguments: {"goodsId": bannerData.content}); |
|
break; |
|
case 2: |
|
Navigator.of(context) |
|
.pushNamed('/router/web_page', arguments: { |
|
"activityId": bannerData.content, |
|
}); |
|
break; |
|
case 3: |
|
Navigator.of(context) |
|
.pushNamed('/router/web_page', arguments: { |
|
"articleId": bannerData.content, |
|
}); |
|
break; |
|
} |
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|