Skip to content

Commit

Permalink
Default barrierColor to be same as backgroundColor when useSafeArea: …
Browse files Browse the repository at this point in the history
…true (#63)

* Default barrierColor to be same as backgroundColor when useSafeArea: true

Improve SafeArea support by defaulting the `barrierColor` to be the same as the `backgroundColor`, thus eliminating visually ugly bars on the top and bottom when using `useSafeArea: true`. The `barrierColor` can be now also be set explicitly (see [GH-62](#62))

Also improve the exmaple app: It's not embedded in a SafeArea and SingleChildScrollView to fix overflow layout errors on smaller devices.

* ci: Update setup-java and checkout actions to v4

Pipeline was failing because Node 16 actions are deprecated. So the two
actions had to be updated to v4.

* ci: Specify distribution for new actions/setup-java version

Starting with v2, you need to specify the distribution. v1 used "zulu", so
we stick with the same.
  • Loading branch information
jfahrenkrug authored Jun 24, 2024
1 parent 2a10a31 commit 97cfd50
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 131 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
flutter-version: ['any', '3.7.0', '3.10.0', '3.16.3'] # Specify versions here

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '12.x'
- uses: subosito/flutter-action@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# EasyImageViewer Changelog

## 1.5.1
- Improve SafeArea support by defaulting the `barrierColor` to be the same as the `backgroundColor`, thus eliminating visually ugly bars on the top and bottom when using `useSafeArea: true`. The `barrierColor` can be now also be set explicitly (see [GH-62](https://github.com/thesmythgroup/easy_image_viewer/issues/62)).

## 1.5.0
- Add ability to infinitely swipe through a set of images by setting `infinitelyScrollable` to `true`. Thanks to [@furkankurt](https://github.com/furkankurt) for implementing this feature. See the README for an example.

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -275,7 +275,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -353,7 +353,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -402,7 +402,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
269 changes: 151 additions & 118 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,127 +53,160 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: const Text("Show Single Image"),
onPressed: () {
showImageViewer(
context,
Image.network("https://picsum.photos/id/1001/4912/3264")
.image,
swipeDismissible: true,
doubleTapZoomable: true);
}),
ElevatedButton(
child: const Text("Show Multiple Images (Simple)"),
onPressed: () {
MultiImageProvider multiImageProvider =
MultiImageProvider(_imageProviders);
showImageViewerPager(context, multiImageProvider,
swipeDismissible: true, doubleTapZoomable: true);
}),
ElevatedButton(
child: const Text("Show Multiple Images (Simple) with Infinite Scroll"),
onPressed: () {
MultiImageProvider multiImageProvider =
MultiImageProvider(_imageProviders);
showImageViewerPager(context, multiImageProvider,
swipeDismissible: true, doubleTapZoomable: true,
infinitelyScrollable: true);
}),
ElevatedButton(
child: const Text("Show Multiple Images (Custom)"),
onPressed: () {
CustomImageProvider customImageProvider = CustomImageProvider(
imageUrls: [
"https://picsum.photos/id/1001/4912/3264",
"https://picsum.photos/id/1003/1181/1772",
"https://picsum.photos/id/1004/4912/3264",
"https://picsum.photos/id/1005/4912/3264"
].toList(),
initialIndex: 2);
showImageViewerPager(context, customImageProvider,
onPageChanged: (page) {
// print("Page changed to $page");
}, onViewerDismissed: (page) {
// print("Dismissed while on page $page");
});
}),
ElevatedButton(
child: const Text("Async Demo (FutureBuilder)"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const AsyncDemoPage()),
);
}),
ElevatedButton(
child: const Text("Custom Progress Indicator"),
onPressed: () {
CustomImageWidgetProvider customImageProvider = CustomImageWidgetProvider(
imageUrls: [
"https://picsum.photos/id/1001/4912/3264",
"https://picsum.photos/id/1003/1181/1772",
"https://picsum.photos/id/1004/4912/3264",
"https://picsum.photos/id/1005/4912/3264"
].toList(),
);
showImageViewerPager(context, customImageProvider);
}),
ElevatedButton(
child: const Text("Simulate Error"),
onPressed: () {
showImageViewer(
context,
// Notice that this will cause an "unhandled exception" although an error handler is defined.
// This is a known Flutter issue, see https://github.com/flutter/flutter/issues/81931
Image.network("https://thisisdefinitelynotavalidurl.com")
.image,
swipeDismissible: true,
doubleTapZoomable: true);
}),
SizedBox( // Tiny image just to test the EasyImageView constructor
width: MediaQuery.of(context).size.width,
height: 56,
child: EasyImageView(
imageProvider: Image.network("https://picsum.photos/id/1001/4912/3264").image)
),
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2.4,
child: EasyImageViewPager(
easyImageProvider: _easyEmbeddedImageProvider,
pageController: _pageController),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
child: const Text("<< Prev"),
body: SafeArea(
child: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: const Text("Show Single Image"),
onPressed: () {
showImageViewer(
context,
Image.network("https://picsum.photos/id/1001/4912/3264").image,
useSafeArea: true,
swipeDismissible: true,
doubleTapZoomable: true,
);
},
),
ElevatedButton(
child: const Text("Show Multiple Images (Simple)"),
onPressed: () {
MultiImageProvider multiImageProvider =
MultiImageProvider(_imageProviders);
showImageViewerPager(
context,
multiImageProvider,
swipeDismissible: true,
doubleTapZoomable: true,
);
},
),
ElevatedButton(
child: const Text("Show Multiple Images (Simple) with Infinite Scroll"),
onPressed: () {
final currentPage = _pageController.page?.toInt() ?? 0;
_pageController.animateToPage(
currentPage > 0 ? currentPage - 1 : 0,
duration: _kDuration,
curve: _kCurve);
}),
ElevatedButton(
child: const Text("Next >>"),
MultiImageProvider multiImageProvider =
MultiImageProvider(_imageProviders);
showImageViewerPager(
context,
multiImageProvider,
swipeDismissible: true,
doubleTapZoomable: true,
infinitelyScrollable: true,
);
},
),
ElevatedButton(
child: const Text("Show Multiple Images (Custom)"),
onPressed: () {
final currentPage = _pageController.page?.toInt() ?? 0;
final lastPage = _easyEmbeddedImageProvider.imageCount - 1;
_pageController.animateToPage(
currentPage < lastPage ? currentPage + 1 : lastPage,
duration: _kDuration,
curve: _kCurve);
}),
],
CustomImageProvider customImageProvider = CustomImageProvider(
imageUrls: [
"https://picsum.photos/id/1001/4912/3264",
"https://picsum.photos/id/1003/1181/1772",
"https://picsum.photos/id/1004/4912/3264",
"https://picsum.photos/id/1005/4912/3264",
].toList(),
initialIndex: 2,
);
showImageViewerPager(
context,
customImageProvider,
onPageChanged: (page) {
// print("Page changed to $page");
},
onViewerDismissed: (page) {
// print("Dismissed while on page $page");
},
);
},
),
ElevatedButton(
child: const Text("Async Demo (FutureBuilder)"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const AsyncDemoPage()),
);
},
),
ElevatedButton(
child: const Text("Custom Progress Indicator"),
onPressed: () {
CustomImageWidgetProvider customImageProvider = CustomImageWidgetProvider(
imageUrls: [
"https://picsum.photos/id/1001/4912/3264",
"https://picsum.photos/id/1003/1181/1772",
"https://picsum.photos/id/1004/4912/3264",
"https://picsum.photos/id/1005/4912/3264",
].toList(),
);
showImageViewerPager(context, customImageProvider);
},
),
ElevatedButton(
child: const Text("Simulate Error"),
onPressed: () {
showImageViewer(
context,
// Notice that this will cause an "unhandled exception" although an error handler is defined.
// This is a known Flutter issue, see https://github.com/flutter/flutter/issues/81931
Image.network("https://thisisdefinitelynotavalidurl.com").image,
swipeDismissible: true,
doubleTapZoomable: true,
);
},
),
SizedBox(
// Tiny image just to test the EasyImageView constructor
width: MediaQuery.of(context).size.width,
height: 56,
child: EasyImageView(
imageProvider: Image.network("https://picsum.photos/id/1001/4912/3264").image,
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2.4,
child: EasyImageViewPager(
easyImageProvider: _easyEmbeddedImageProvider,
pageController: _pageController,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
child: const Text("<< Prev"),
onPressed: () {
final currentPage = _pageController.page?.toInt() ?? 0;
_pageController.animateToPage(
currentPage > 0 ? currentPage - 1 : 0,
duration: _kDuration,
curve: _kCurve,
);
},
),
ElevatedButton(
child: const Text("Next >>"),
onPressed: () {
final currentPage = _pageController.page?.toInt() ?? 0;
final lastPage = _easyEmbeddedImageProvider.imageCount - 1;
_pageController.animateToPage(
currentPage < lastPage ? currentPage + 1 : lastPage,
duration: _kDuration,
curve: _kCurve,
);
},
),
],
),
],
),
),
],
)),
),
)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: easy_image_viewer_example
description: A new Flutter project.
description: An example app for the easy_image_viewer package.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
Expand Down
Loading

0 comments on commit 97cfd50

Please sign in to comment.