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.
 
 
 
 
 
 

85 lines
2.2 KiB

import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/brand.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class BrandView extends StatefulWidget {
final List<Brand> brandData;
BrandView(this.brandData);
@override
State<StatefulWidget> createState() {
return _BrandView();
}
}
class _BrandView extends State<BrandView> {
final SwiperController swiperController = SwiperController();
@override
Widget build(BuildContext context) {
return Column(
children: [
ItemTitle(
text: S.of(context).pinpaijieshao,
imgPath: "assets/image/icon_brand_introduction.webp",
),
brands(),
],
);
}
brands() {
return Container(
height: 90.h,
margin: EdgeInsets.only(bottom: 18.h),
child: Swiper(
controller: swiperController,
viewportFraction: 0.32,
scale: 0.7,
autoplay: true,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(37),
offset: Offset(0, 2),
blurRadius: 5,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
child: MImage(
widget.brandData != null ? widget.brandData[position].image : "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
);
},
itemCount:
(widget.brandData != null && widget.brandData.length > 0) ? widget.brandData.length : 0,
),
);
}
}