From 00d1c36da18cb57a062ad0ae78b37b91125b4a68 Mon Sep 17 00:00:00 2001 From: dbilgin Date: Sun, 26 Mar 2023 13:42:18 +0200 Subject: [PATCH] added background opacity --- CHANGELOG.md | 4 ++++ example/lib/main.dart | 1 + example/pubspec.lock | 2 +- lib/swipe_image_gallery.dart | 8 ++++++-- pubspec.yaml | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50bffe4..b4e2f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.8.2](https://github.com/dbilgin/swipe_image_gallery/releases/tag/v0.8.2) + +- Added `backgroundOpacity` property. + ## [0.8.1](https://github.com/dbilgin/swipe_image_gallery/releases/tag/v0.8.1) - Removed touchpad support to fix windows crash. diff --git a/example/lib/main.dart b/example/lib/main.dart index 57f4fd5..4a1659a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -112,6 +112,7 @@ class _ImageGalleryExamplesPageState extends State { initialOverlay: OverlayExample( title: '1/${remoteImages.length}', ), + backgroundOpacity: 0.5, ).show(); }, child: const Text('Open Gallery With Overlay'), diff --git a/example/pubspec.lock b/example/pubspec.lock index c3468c2..9c266a4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -166,7 +166,7 @@ packages: path: ".." relative: true source: path - version: "0.8.1" + version: "0.8.2" term_glyph: dependency: transitive description: diff --git a/lib/swipe_image_gallery.dart b/lib/swipe_image_gallery.dart index d4247b2..dd27709 100644 --- a/lib/swipe_image_gallery.dart +++ b/lib/swipe_image_gallery.dart @@ -80,6 +80,7 @@ class SwipeImageGallery { this.transitionDuration = 400, this.hideOverlayOnTap = true, this.zoom = 8.0, + this.backgroundOpacity = 1.0, this.controller, this.onSwipe, this.overlayController, @@ -136,6 +137,9 @@ class SwipeImageGallery { /// Amount of zoom allowed. final double zoom; + /// Background opacity between 0-1 and defaults to 1. + final double backgroundOpacity; + /// The controller for the image gallery, extends [PageController]. final ImageGalleryController? controller; @@ -273,13 +277,13 @@ class SwipeImageGallery { if (hideStatusBar) SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); var showOverlay = true; - double _opacity = 1.0; + double _opacity = backgroundOpacity; final content = StatefulBuilder( builder: (context, setState) { void _setOpacity(double opacity) { setState(() { - _opacity = opacity; + _opacity = opacity * backgroundOpacity; }); } diff --git a/pubspec.yaml b/pubspec.yaml index 32487f0..d05e7b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: swipe_image_gallery description: A scrollable, dismissable by swiping, zoomable gallery on which you can add a dynamic overlay. -version: 0.8.1 +version: 0.8.2 homepage: https://github.com/dbilgin/swipe_image_gallery environment: