From b8caf579c34e1927276a86728ef52604d28e68bf Mon Sep 17 00:00:00 2001 From: lukas-heiligenbrunner Date: Thu, 29 Sep 2022 20:32:52 +0200 Subject: [PATCH] zoomable gallery view add network permission --- android/app/src/main/AndroidManifest.xml | 1 + lib/full_screen_image_view.dart | 39 +++++++++++++++--------- lib/image_grid.dart | 2 +- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6ae3f95..178e473 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ package="eu.heili.gallery"> + { }, child: Focus( autofocus: true, - child: PageView.builder( + child: PhotoViewGallery.builder( + scrollPhysics: const BouncingScrollPhysics(), + builder: (BuildContext context, int index) { + return PhotoViewGalleryPageOptions( + imageProvider: widget.provider.getImageProvider(widget.items[index].uri), + initialScale: PhotoViewComputedScale.contained, + minScale: PhotoViewComputedScale.contained, + heroAttributes: PhotoViewHeroAttributes(tag: widget.items[index].name), + ); + }, itemCount: widget.items.length, - controller: _controller, - pageSnapping: true, - itemBuilder: (context, pagePosition) { - return Container( - margin: const EdgeInsets.all(10), - child: PhotoView( - backgroundDecoration: - const BoxDecoration(color: Colors.white), - imageProvider: widget.provider - .getImageProvider(widget.items[pagePosition].uri), - ), - ); - }), + loadingBuilder: (context, event) => Center( + child: SizedBox( + width: 20.0, + height: 20.0, + child: CircularProgressIndicator( + value: event == null || event.expectedTotalBytes == null + ? null + : event.cumulativeBytesLoaded / event.expectedTotalBytes!, + ), + ), + ), + backgroundDecoration: const BoxDecoration(color: Colors.white), + pageController: _controller, + ), ), ), ), diff --git a/lib/image_grid.dart b/lib/image_grid.dart index f2d87de..b889ddf 100644 --- a/lib/image_grid.dart +++ b/lib/image_grid.dart @@ -106,7 +106,7 @@ class _ImageGridState extends State { }, ); } else if (snapshot.hasError) { - return const Text("Error loading files"); + return Text("Error loading files: ${snapshot.error}"); } }