diff --git a/android/.gitignore b/android/.gitignore index f12b17c55..bc2100d8f 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -5,6 +5,3 @@ gradle-wrapper.jar /gradlew.bat /local.properties GeneratedPluginRegistrant.java - -# Signing config files -*.jks \ No newline at end of file diff --git a/lib/ui/viewer/file/detail_page.dart b/lib/ui/viewer/file/detail_page.dart index 46db449c5..779243c27 100644 --- a/lib/ui/viewer/file/detail_page.dart +++ b/lib/ui/viewer/file/detail_page.dart @@ -73,6 +73,7 @@ class DetailPage extends StatefulWidget { class _DetailPageState extends State { static const kLoadLimit = 100; final _logger = Logger("DetailPageState"); + bool _shouldDisableScroll = false; List? _files; late PageController _pageController; final _selectedIndexNotifier = ValueNotifier(0); @@ -171,6 +172,14 @@ class _DetailPageState extends State { file, autoPlay: shouldAutoPlay(), tagPrefix: widget.config.tagPrefix, + shouldDisableScroll: (value) { + if (_shouldDisableScroll != value) { + setState(() { + _logger.fine('setState $_shouldDisableScroll to $value'); + _shouldDisableScroll = value; + }); + } + }, playbackCallback: (isPlaying) { Future.delayed(Duration.zero, () { _toggleFullScreen(shouldEnable: isPlaying); @@ -199,7 +208,9 @@ class _DetailPageState extends State { } _preloadEntries(); }, - physics: const FastScrollPhysics(speedFactor: 4.0), + physics: _shouldDisableScroll + ? const NeverScrollableScrollPhysics() + : const FastScrollPhysics(speedFactor: 4.0), controller: _pageController, itemCount: _files!.length, ); diff --git a/lib/ui/viewer/file/file_widget.dart b/lib/ui/viewer/file/file_widget.dart index 754cb1a67..6e6dcc7f1 100644 --- a/lib/ui/viewer/file/file_widget.dart +++ b/lib/ui/viewer/file/file_widget.dart @@ -8,6 +8,7 @@ import "package:photos/ui/viewer/file/zoomable_live_image_new.dart"; class FileWidget extends StatelessWidget { final EnteFile file; final String? tagPrefix; + final Function(bool)? shouldDisableScroll; final Function(bool)? playbackCallback; final BoxDecoration? backgroundDecoration; final bool? autoPlay; @@ -15,6 +16,7 @@ class FileWidget extends StatelessWidget { const FileWidget( this.file, { this.autoPlay, + this.shouldDisableScroll, this.playbackCallback, this.tagPrefix, this.backgroundDecoration, @@ -30,6 +32,7 @@ class FileWidget extends StatelessWidget { file.fileType == FileType.image) { return ZoomableLiveImageNew( file, + shouldDisableScroll: shouldDisableScroll, tagPrefix: tagPrefix, backgroundDecoration: backgroundDecoration, key: key ?? ValueKey(fileKey), diff --git a/lib/ui/viewer/file/zoomable_image.dart b/lib/ui/viewer/file/zoomable_image.dart index 5a1d47b29..db96554fc 100644 --- a/lib/ui/viewer/file/zoomable_image.dart +++ b/lib/ui/viewer/file/zoomable_image.dart @@ -6,7 +6,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:logging/logging.dart'; import 'package:photo_view/photo_view.dart'; -import "package:photo_view/photo_view_gallery.dart"; import 'package:photos/core/cache/thumbnail_in_memory_cache.dart'; import 'package:photos/core/constants.dart'; import 'package:photos/core/event_bus.dart'; @@ -25,6 +24,7 @@ import 'package:photos/utils/thumbnail_util.dart'; class ZoomableImage extends StatefulWidget { final EnteFile photo; + final Function(bool)? shouldDisableScroll; final String? tagPrefix; final Decoration? backgroundDecoration; final bool shouldCover; @@ -32,6 +32,7 @@ class ZoomableImage extends StatefulWidget { const ZoomableImage( this.photo, { Key? key, + this.shouldDisableScroll, required this.tagPrefix, this.backgroundDecoration, this.shouldCover = false, @@ -51,9 +52,9 @@ class _ZoomableImageState extends State bool _loadedLargeThumbnail = false; bool _loadingFinalImage = false; bool _loadedFinalImage = false; - PhotoViewController _photoViewController = PhotoViewController(); - bool _isZooming = false; ValueChanged? _scaleStateChangedCallback; + bool _isZooming = false; + PhotoViewController _photoViewController = PhotoViewController(); @override void initState() { @@ -61,8 +62,12 @@ class _ZoomableImageState extends State _logger = Logger("ZoomableImage"); _logger.info('initState for ${_photo.generatedID} with tag ${_photo.tag}'); _scaleStateChangedCallback = (value) { + if (widget.shouldDisableScroll != null) { + widget.shouldDisableScroll!(value != PhotoViewScaleState.initial); + } _isZooming = value != PhotoViewScaleState.initial; debugPrint("isZooming = $_isZooming, currentState $value"); + // _logger.info('is reakky zooming $_isZooming with state $value'); }; super.initState(); } @@ -83,41 +88,41 @@ class _ZoomableImageState extends State Widget content; if (_imageProvider != null) { - content = PhotoViewGallery.builder( - gaplessPlayback: true, - scaleStateChangedCallback: _scaleStateChangedCallback, - backgroundDecoration: widget.backgroundDecoration as BoxDecoration?, - builder: (context, index) { - return PhotoViewGalleryPageOptions( - imageProvider: _imageProvider!, - minScale: widget.shouldCover - ? PhotoViewComputedScale.covered - : PhotoViewComputedScale.contained, - heroAttributes: PhotoViewHeroAttributes( - tag: widget.tagPrefix! + _photo.tag, - ), - controller: _photoViewController, - ); - }, - itemCount: 1, + content = PhotoViewGestureDetectorScope( + axis: Axis.vertical, + child: PhotoView( + imageProvider: _imageProvider, + controller: _photoViewController, + scaleStateChangedCallback: _scaleStateChangedCallback, + minScale: widget.shouldCover + ? PhotoViewComputedScale.covered + : PhotoViewComputedScale.contained, + gaplessPlayback: true, + heroAttributes: PhotoViewHeroAttributes( + tag: widget.tagPrefix! + _photo.tag, + ), + backgroundDecoration: widget.backgroundDecoration as BoxDecoration?, + ), ); } else { content = const EnteLoadingWidget(); } - verticalDragCallback(d) => { - if (!_isZooming) - { - if (d.delta.dy > dragSensitivity) - { - {Navigator.of(context).pop()}, - } - else if (d.delta.dy < (dragSensitivity * -1)) + + final GestureDragUpdateCallback? verticalDragCallback = _isZooming + ? null + : (d) => { + if (!_isZooming) { - showDetailsSheet(context, widget.photo), + if (d.delta.dy > dragSensitivity) + { + {Navigator.of(context).pop()}, + } + else if (d.delta.dy < (dragSensitivity * -1)) + { + showDetailsSheet(context, widget.photo), + }, }, - }, - }; - + }; return GestureDetector( onVerticalDragUpdate: verticalDragCallback, child: content, @@ -258,7 +263,9 @@ class _ZoomableImageState extends State required ImageProvider? previewImageProvider, required ImageProvider finalImageProvider, }) async { - final bool shouldFixPosition = previewImageProvider != null && _isZooming; + final bool shouldFixPosition = previewImageProvider != null && + _isZooming && + _photoViewController.scale != null; ImageInfo? finalImageInfo; if (shouldFixPosition) { final prevImageInfo = await getImageInfo(previewImageProvider); diff --git a/lib/ui/viewer/file/zoomable_live_image.dart b/lib/ui/viewer/file/zoomable_live_image.dart index 28564f673..f7e2aa55a 100644 --- a/lib/ui/viewer/file/zoomable_live_image.dart +++ b/lib/ui/viewer/file/zoomable_live_image.dart @@ -16,12 +16,14 @@ import 'package:video_player/video_player.dart'; class ZoomableLiveImage extends StatefulWidget { final EnteFile enteFile; + final Function(bool)? shouldDisableScroll; final String? tagPrefix; final Decoration? backgroundDecoration; const ZoomableLiveImage( this.enteFile, { Key? key, + this.shouldDisableScroll, required this.tagPrefix, this.backgroundDecoration, }) : super(key: key); @@ -43,9 +45,8 @@ class _ZoomableLiveImageState extends State @override void initState() { _enteFile = widget.enteFile; - _logger.info( - 'initState for ${_enteFile.generatedID} with tag ${_enteFile.tag} and name ${_enteFile.displayName}', - ); + _logger.info('initState for ${_enteFile.generatedID} with tag ${_enteFile + .tag} and name ${_enteFile.displayName}'); super.initState(); } @@ -75,6 +76,7 @@ class _ZoomableLiveImageState extends State content = ZoomableImage( _enteFile, tagPrefix: widget.tagPrefix, + shouldDisableScroll: widget.shouldDisableScroll, backgroundDecoration: widget.backgroundDecoration, ); } @@ -136,8 +138,7 @@ class _ZoomableLiveImageState extends State } Future _getLivePhotoVideo() async { - if (_enteFile.isRemoteFile && - !(await isFileCached(_enteFile, liveVideo: true))) { + if (_enteFile.isRemoteFile && !(await isFileCached(_enteFile, liveVideo: true))) { showShortToast(context, S.of(context).downloading); } @@ -205,4 +206,5 @@ class _ZoomableLiveImageState extends State } }); } + } diff --git a/lib/ui/viewer/file/zoomable_live_image_new.dart b/lib/ui/viewer/file/zoomable_live_image_new.dart index 73a7f629b..598ae60e0 100644 --- a/lib/ui/viewer/file/zoomable_live_image_new.dart +++ b/lib/ui/viewer/file/zoomable_live_image_new.dart @@ -17,12 +17,14 @@ import 'package:photos/utils/toast_util.dart'; class ZoomableLiveImageNew extends StatefulWidget { final EnteFile enteFile; + final Function(bool)? shouldDisableScroll; final String? tagPrefix; final Decoration? backgroundDecoration; const ZoomableLiveImageNew( this.enteFile, { Key? key, + this.shouldDisableScroll, required this.tagPrefix, this.backgroundDecoration, }) : super(key: key); @@ -79,6 +81,7 @@ class _ZoomableLiveImageNewState extends State content = ZoomableImage( _enteFile, tagPrefix: widget.tagPrefix, + shouldDisableScroll: widget.shouldDisableScroll, backgroundDecoration: widget.backgroundDecoration, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 037c7ac84..dfbe55f75 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,6 @@ description: ente photos application # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 0.8.59+579 - environment: sdk: ">=3.0.0 <4.0.0"