show method
Implementation
Future<void> show() async {
double opacity = 1;
int activeIndex = initialIndex ?? 0;
await showGeneralDialog(
context: context,
barrierDismissible: false,
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (context, animation, secondaryAnimation) => StatefulBuilder(
builder: (context, setState) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: closeWithOnTap ? () => Navigator.of(context).pop() : null,
child: Container(
decoration: BoxDecoration(
color: backgroundColor ?? Colors.black.withOpacity(opacity),
gradient: backgroundGradient),
child: SafeArea(
child: Stack(
alignment: Alignment.center,
fit: StackFit.expand,
children: [
PageView.builder(
itemCount: imagePaths.length + 1,
controller:
PageController(initialPage: initialIndex ?? 0),
onPageChanged: (index) {
if (index == imagePaths.length) {
Navigator.of(context).pop();
} else {
onSwipe?.call(index);
}
Future.microtask(() => setState(() {
activeIndex = index;
}));
},
itemBuilder: (context, index) {
if (index == imagePaths.length) {
return const SizedBox();
}
return _AVSImageOnePage(
setBackgroundOpacity: (p0) {
opacity = p0;
Future.microtask(() => setState(() {}));
},
child: AVSImage(
imagePaths[index],
zoom: false,
),
);
},
),
showCloseButton == true
? Positioned(
top: closeButtonPosition ==
ButtonPosition.topLeft ||
closeButtonPosition ==
ButtonPosition.topRight
? 20
: null,
right: closeButtonPosition ==
ButtonPosition.topRight ||
closeButtonPosition ==
ButtonPosition.bottomRight
? 20
: null,
bottom: closeButtonPosition ==
ButtonPosition.bottomLeft ||
closeButtonPosition ==
ButtonPosition.bottomRight
? 20
: null,
left: closeButtonPosition ==
ButtonPosition.topLeft ||
closeButtonPosition ==
ButtonPosition.bottomLeft
? 20
: null,
child: InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Row(
children: [
customCloseButton ??
const Icon(Icons.close,
color: Colors.white),
],
),
),
)
: const SizedBox(),
secondaryButton != null
? Positioned(
top: secondaryButtonPosition ==
ButtonPosition.topLeft ||
secondaryButtonPosition ==
ButtonPosition.topRight
? 20
: null,
right: secondaryButtonPosition ==
ButtonPosition.topRight ||
secondaryButtonPosition ==
ButtonPosition.bottomRight
? 20
: null,
bottom: secondaryButtonPosition ==
ButtonPosition.bottomLeft ||
secondaryButtonPosition ==
ButtonPosition.bottomRight
? 20
: null,
left: secondaryButtonPosition ==
ButtonPosition.topLeft ||
secondaryButtonPosition ==
ButtonPosition.bottomLeft
? 20
: null,
child: secondaryButton ?? const SizedBox(),
)
: const SizedBox(),
// Bottom Bar
showBottomBar == false || imagePaths.length < 2
? const SizedBox()
: Positioned(
bottom: 20,
child: SizedBox(
height: imageGalleryStyle?.slideHeight ?? 9,
child: ListView.builder(
itemCount: imagePaths.length,
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, index) {
return activeIndex == index
? activeSlideWidget(opacity: opacity)
: inActiveSlideWidget(opacity: opacity);
},
),
),
),
],
),
),
),
),
);
},
),
);
}