import 'dart:developer'; import 'dart:ui'; import 'package:flutter/material.dart'; import '../config/constants/app_constant.dart'; import '../models/OfferModel.dart'; // Your constants class ImageSliderPopup { static void show({ required BuildContext context, required List offers, }) { showDialog( context: context, barrierColor: Colors.black.withOpacity(0.5), // This is the key to removing the side padding builder: (BuildContext context) { return _ImageSliderDialog(offers: offers); }, ); } } class _ImageSliderDialog extends StatefulWidget { final List offers; const _ImageSliderDialog({required this.offers}); @override State<_ImageSliderDialog> createState() => _ImageSliderDialogState(); } class _ImageSliderDialogState extends State<_ImageSliderDialog> { late final PageController _pageController; int _currentPage = 0; @override void initState() { super.initState(); _pageController = PageController(); _pageController.addListener(() { if (_pageController.page != null) { setState(() { _currentPage = _pageController.page!.round(); }); } }); } @override void dispose() { _pageController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { log("offers=====>>> ${widget.offers}"); return Scaffold( backgroundColor: Colors.transparent, body: Stack( children: [ // 1. Frosted Glass / Blur Effect BackdropFilter( filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), child: Container( color: Colors.black.withOpacity(0.2), ), ), // 2. The PageView Slider PageView.builder( controller: _pageController, itemCount: widget.offers.length, itemBuilder: (context, index) { final offer = widget.offers[index]; return Container( // The image container itself decoration: BoxDecoration( image: DecorationImage( image: NetworkImage('$mediaUrl${offer.image.url}'), fit: BoxFit.contain, ), ), // 3. Adding a subtle gradient overlay for better text contrast child: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Colors.black.withOpacity(0.2), Colors.transparent, Colors.black.withOpacity(0.4), ], ), ), ), ); }, ), // 4. Styled Close Button Positioned( top: 50, right: 20, child: GestureDetector( onTap: () => Navigator.of(context).pop(), child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.black.withOpacity(0.5), shape: BoxShape.circle, ), child: const Icon(Icons.close, color: Colors.white, size: 24), ), ), ), // 5. Styled Page Indicator Positioned( bottom: 40, left: 0, right: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(widget.offers.length, (index) { return AnimatedContainer( duration: const Duration(milliseconds: 300), margin: const EdgeInsets.symmetric(horizontal: 4.0), height: 8.0, // Make the active dot wider width: _currentPage == index ? 24.0 : 8.0, decoration: BoxDecoration( color: _currentPage == index ? Colors.white : Colors.white.withOpacity(0.5), borderRadius: BorderRadius.circular(12), ), ); }), ), ), ], ), ); } }