Swiper(
itemBuilder: (context, index) {
final banner = listCarousel[index];
final isActive = _activeIndex == index;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: AnimatedOpacity(
opacity: isActive ? 1.0 : .8,
duration: const Duration(milliseconds: 1000),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(APP_UI_CARD_RADIUS),
color: APP_UI_COLOR[400],
boxShadow: [
BoxShadow(
color: Colors.grey[800]!.withOpacity(.7),
blurRadius: 15.0,
spreadRadius: -2.0,
offset: const Offset(2.0, 2.0),
),
]
),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => h.viewMenu(product: banner),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
SizedBox(width: double.infinity, height: double.infinity, child: MyCachedImage(banner.photo)),
AnimatedOpacity(
opacity: isActive ? 1.0 : 0.0,
duration: const Duration(milliseconds: 1000),
curve: Curves.ease,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0),
Colors.white54,
],
),
),
padding: const EdgeInsets.all(APP_UI_CARD_PADDING).copyWith(top: 50),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(banner.name, textAlign: TextAlign.center, style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w800,
color: Colors.black,
shadows: [
Shadow(blurRadius: 10.0, color: Colors.white),
],
),),
if (banner.bestComment != null) Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Text.rich(TextSpan(
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: APP_UI_TEXT_DEFAULT,
shadows: [
Shadow(blurRadius: 10.0, color: Colors.white),
],
),
children: [
TextSpan(text: '"${banner.bestComment}"', style: const TextStyle(fontWeight: FontWeight.w600),),
TextSpan(text: ' — ${banner.bestCommentAuthor}',),
],
), textAlign: TextAlign.center,),
),
],
),
),
),
],
),
),
).pulseIt(scaleEnd: 1.025, duration: 3000),
),
);
},
onIndexChanged: (index) async {
await Future.delayed(const Duration(milliseconds: 500));
if (mounted) setState(() { _activeIndex = index; });
},
viewportFraction: .7,
scale: .8,
itemCount: listCarousel.length,
autoplay: true,
autoplayDelay: 10000,
duration: 1000,
);