mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
feat(mobile): Enhanced vertical swiping motion in image viewer (#932)
This commit is contained in:
parent
bbe820d797
commit
c8538cc62f
1 changed files with 14 additions and 16 deletions
|
@ -9,7 +9,6 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
|
||||||
_RemoteImageStatus _status = _RemoteImageStatus.empty;
|
_RemoteImageStatus _status = _RemoteImageStatus.empty;
|
||||||
bool _zoomedIn = false;
|
bool _zoomedIn = false;
|
||||||
|
|
||||||
static const int swipeThreshold = 100;
|
|
||||||
late CachedNetworkImageProvider fullProvider;
|
late CachedNetworkImageProvider fullProvider;
|
||||||
late CachedNetworkImageProvider previewProvider;
|
late CachedNetworkImageProvider previewProvider;
|
||||||
late CachedNetworkImageProvider thumbnailProvider;
|
late CachedNetworkImageProvider thumbnailProvider;
|
||||||
|
@ -20,34 +19,33 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
|
||||||
|
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
ignoring: !allowMoving,
|
ignoring: !allowMoving,
|
||||||
child: PhotoView(
|
child: Listener(
|
||||||
imageProvider: _imageProvider,
|
onPointerMove: handleSwipUpDown,
|
||||||
minScale: PhotoViewComputedScale.contained,
|
child: PhotoView(
|
||||||
enablePanAlways: true,
|
imageProvider: _imageProvider,
|
||||||
scaleStateChangedCallback: _scaleStateChanged,
|
minScale: PhotoViewComputedScale.contained,
|
||||||
onScaleEnd: _onScaleListener,
|
enablePanAlways: false,
|
||||||
|
scaleStateChangedCallback: _scaleStateChanged,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onScaleListener(
|
void handleSwipUpDown(PointerMoveEvent details) {
|
||||||
BuildContext context,
|
int sensitivity = 10;
|
||||||
ScaleEndDetails details,
|
|
||||||
PhotoViewControllerValue controllerValue,
|
|
||||||
) {
|
|
||||||
// Disable swipe events when zoomed in
|
|
||||||
if (_zoomedIn) {
|
if (_zoomedIn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (controllerValue.position.dy > swipeThreshold) {
|
|
||||||
|
if (details.delta.dy > sensitivity) {
|
||||||
widget.onSwipeDown();
|
widget.onSwipeDown();
|
||||||
} else if (controllerValue.position.dy < -swipeThreshold) {
|
} else if (details.delta.dy < -sensitivity) {
|
||||||
widget.onSwipeUp();
|
widget.onSwipeUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _scaleStateChanged(PhotoViewScaleState state) {
|
void _scaleStateChanged(PhotoViewScaleState state) {
|
||||||
// _onScaleListener;
|
|
||||||
_zoomedIn = state != PhotoViewScaleState.initial;
|
_zoomedIn = state != PhotoViewScaleState.initial;
|
||||||
if (_zoomedIn) {
|
if (_zoomedIn) {
|
||||||
widget.isZoomedListener.value = true;
|
widget.isZoomedListener.value = true;
|
||||||
|
|
Loading…
Reference in a new issue