import 'package:flutter/material.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/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 brandData; BrandView(this.brandData); @override State createState() { return _BrandView(); } } class _BrandView extends State { 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[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.length ?? 0, ), ); } }