mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
feat(mobile): play motion video with long press gesture support (#6543)
This commit is contained in:
parent
9bce3417e9
commit
42f03af2dc
@ -331,6 +331,11 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
onTapDown: (_, __, ___) {
|
onTapDown: (_, __, ___) {
|
||||||
ref.read(showControlsProvider.notifier).toggle();
|
ref.read(showControlsProvider.notifier).toggle();
|
||||||
},
|
},
|
||||||
|
onLongPressStart: (_, __, ___) {
|
||||||
|
if (asset.livePhotoVideoId != null) {
|
||||||
|
isPlayingVideo.value = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
imageProvider: provider,
|
imageProvider: provider,
|
||||||
heroAttributes: PhotoViewHeroAttributes(
|
heroAttributes: PhotoViewHeroAttributes(
|
||||||
tag: isFromDto
|
tag: isFromDto
|
||||||
|
@ -256,6 +256,7 @@ class PhotoView extends StatefulWidget {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
this.customSize,
|
this.customSize,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
this.tightMode,
|
this.tightMode,
|
||||||
@ -294,6 +295,7 @@ class PhotoView extends StatefulWidget {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
this.customSize,
|
this.customSize,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
this.tightMode,
|
this.tightMode,
|
||||||
@ -401,6 +403,10 @@ class PhotoView extends StatefulWidget {
|
|||||||
/// particular location.
|
/// particular location.
|
||||||
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
||||||
|
|
||||||
|
/// A pointer that might cause a tap has contacted the screen at a particular
|
||||||
|
/// location.
|
||||||
|
final PhotoViewImageLongPressStartCallback? onLongPressStart;
|
||||||
|
|
||||||
/// [HitTestBehavior] to be passed to the internal gesture detector.
|
/// [HitTestBehavior] to be passed to the internal gesture detector.
|
||||||
final HitTestBehavior? gestureDetectorBehavior;
|
final HitTestBehavior? gestureDetectorBehavior;
|
||||||
|
|
||||||
@ -537,6 +543,7 @@ class _PhotoViewState extends State<PhotoView>
|
|||||||
onDragEnd: widget.onDragEnd,
|
onDragEnd: widget.onDragEnd,
|
||||||
onDragUpdate: widget.onDragUpdate,
|
onDragUpdate: widget.onDragUpdate,
|
||||||
onScaleEnd: widget.onScaleEnd,
|
onScaleEnd: widget.onScaleEnd,
|
||||||
|
onLongPressStart: widget.onLongPressStart,
|
||||||
outerSize: computedOuterSize,
|
outerSize: computedOuterSize,
|
||||||
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
||||||
tightMode: widget.tightMode,
|
tightMode: widget.tightMode,
|
||||||
@ -566,6 +573,7 @@ class _PhotoViewState extends State<PhotoView>
|
|||||||
onDragEnd: widget.onDragEnd,
|
onDragEnd: widget.onDragEnd,
|
||||||
onDragUpdate: widget.onDragUpdate,
|
onDragUpdate: widget.onDragUpdate,
|
||||||
onScaleEnd: widget.onScaleEnd,
|
onScaleEnd: widget.onScaleEnd,
|
||||||
|
onLongPressStart: widget.onLongPressStart,
|
||||||
outerSize: computedOuterSize,
|
outerSize: computedOuterSize,
|
||||||
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
||||||
tightMode: widget.tightMode,
|
tightMode: widget.tightMode,
|
||||||
@ -649,6 +657,13 @@ typedef PhotoViewImageScaleEndCallback = Function(
|
|||||||
PhotoViewControllerValue controllerValue,
|
PhotoViewControllerValue controllerValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// A type definition for a callback when the user long press start
|
||||||
|
typedef PhotoViewImageLongPressStartCallback = Function(
|
||||||
|
BuildContext context,
|
||||||
|
LongPressStartDetails details,
|
||||||
|
PhotoViewControllerValue controllerValue,
|
||||||
|
);
|
||||||
|
|
||||||
/// A type definition for a callback to show a widget while the image is loading, a [ImageChunkEvent] is passed to inform progress
|
/// A type definition for a callback to show a widget while the image is loading, a [ImageChunkEvent] is passed to inform progress
|
||||||
typedef LoadingBuilder = Widget Function(
|
typedef LoadingBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
@ -12,6 +12,7 @@ import 'package:immich_mobile/shared/ui/photo_view/photo_view.dart'
|
|||||||
PhotoViewImageDragEndCallback,
|
PhotoViewImageDragEndCallback,
|
||||||
PhotoViewImageDragUpdateCallback,
|
PhotoViewImageDragUpdateCallback,
|
||||||
PhotoViewImageScaleEndCallback,
|
PhotoViewImageScaleEndCallback,
|
||||||
|
PhotoViewImageLongPressStartCallback,
|
||||||
ScaleStateCycle;
|
ScaleStateCycle;
|
||||||
|
|
||||||
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller.dart';
|
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller.dart';
|
||||||
@ -269,6 +270,7 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
|
|||||||
onDragEnd: pageOption.onDragEnd,
|
onDragEnd: pageOption.onDragEnd,
|
||||||
onDragUpdate: pageOption.onDragUpdate,
|
onDragUpdate: pageOption.onDragUpdate,
|
||||||
onScaleEnd: pageOption.onScaleEnd,
|
onScaleEnd: pageOption.onScaleEnd,
|
||||||
|
onLongPressStart: pageOption.onLongPressStart,
|
||||||
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
|
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
|
||||||
tightMode: pageOption.tightMode,
|
tightMode: pageOption.tightMode,
|
||||||
filterQuality: pageOption.filterQuality,
|
filterQuality: pageOption.filterQuality,
|
||||||
@ -300,6 +302,7 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
|
|||||||
onDragEnd: pageOption.onDragEnd,
|
onDragEnd: pageOption.onDragEnd,
|
||||||
onDragUpdate: pageOption.onDragUpdate,
|
onDragUpdate: pageOption.onDragUpdate,
|
||||||
onScaleEnd: pageOption.onScaleEnd,
|
onScaleEnd: pageOption.onScaleEnd,
|
||||||
|
onLongPressStart: pageOption.onLongPressStart,
|
||||||
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
|
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
|
||||||
tightMode: pageOption.tightMode,
|
tightMode: pageOption.tightMode,
|
||||||
filterQuality: pageOption.filterQuality,
|
filterQuality: pageOption.filterQuality,
|
||||||
@ -347,6 +350,7 @@ class PhotoViewGalleryPageOptions {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
this.tightMode,
|
this.tightMode,
|
||||||
this.filterQuality,
|
this.filterQuality,
|
||||||
@ -373,6 +377,7 @@ class PhotoViewGalleryPageOptions {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
this.tightMode,
|
this.tightMode,
|
||||||
this.filterQuality,
|
this.filterQuality,
|
||||||
@ -431,6 +436,9 @@ class PhotoViewGalleryPageOptions {
|
|||||||
/// Mirror to [PhotoView.onScaleEnd]
|
/// Mirror to [PhotoView.onScaleEnd]
|
||||||
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
||||||
|
|
||||||
|
/// Mirror to [PhotoView.onLongPressStart]
|
||||||
|
final PhotoViewImageLongPressStartCallback? onLongPressStart;
|
||||||
|
|
||||||
/// Mirror to [PhotoView.gestureDetectorBehavior]
|
/// Mirror to [PhotoView.gestureDetectorBehavior]
|
||||||
final HitTestBehavior? gestureDetectorBehavior;
|
final HitTestBehavior? gestureDetectorBehavior;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import 'package:immich_mobile/shared/ui/photo_view/photo_view.dart'
|
|||||||
PhotoViewImageDragEndCallback,
|
PhotoViewImageDragEndCallback,
|
||||||
PhotoViewImageDragStartCallback,
|
PhotoViewImageDragStartCallback,
|
||||||
PhotoViewImageDragUpdateCallback,
|
PhotoViewImageDragUpdateCallback,
|
||||||
|
PhotoViewImageLongPressStartCallback,
|
||||||
ScaleStateCycle;
|
ScaleStateCycle;
|
||||||
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller.dart';
|
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller.dart';
|
||||||
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller_delegate.dart';
|
import 'package:immich_mobile/shared/ui/photo_view/src/controller/photo_view_controller_delegate.dart';
|
||||||
@ -37,6 +38,7 @@ class PhotoViewCore extends StatefulWidget {
|
|||||||
required this.onDragEnd,
|
required this.onDragEnd,
|
||||||
required this.onDragUpdate,
|
required this.onDragUpdate,
|
||||||
required this.onScaleEnd,
|
required this.onScaleEnd,
|
||||||
|
required this.onLongPressStart,
|
||||||
required this.gestureDetectorBehavior,
|
required this.gestureDetectorBehavior,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.scaleBoundaries,
|
required this.scaleBoundaries,
|
||||||
@ -61,6 +63,7 @@ class PhotoViewCore extends StatefulWidget {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.scaleBoundaries,
|
required this.scaleBoundaries,
|
||||||
@ -95,6 +98,8 @@ class PhotoViewCore extends StatefulWidget {
|
|||||||
final PhotoViewImageDragEndCallback? onDragEnd;
|
final PhotoViewImageDragEndCallback? onDragEnd;
|
||||||
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
||||||
|
|
||||||
|
final PhotoViewImageLongPressStartCallback? onLongPressStart;
|
||||||
|
|
||||||
final HitTestBehavior? gestureDetectorBehavior;
|
final HitTestBehavior? gestureDetectorBehavior;
|
||||||
final bool tightMode;
|
final bool tightMode;
|
||||||
final bool disableGestures;
|
final bool disableGestures;
|
||||||
@ -373,6 +378,9 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
onTapDown: widget.onTapDown != null
|
onTapDown: widget.onTapDown != null
|
||||||
? (details) => widget.onTapDown!(context, details, value)
|
? (details) => widget.onTapDown!(context, details, value)
|
||||||
: null,
|
: null,
|
||||||
|
onLongPressStart: widget.onLongPressStart != null
|
||||||
|
? (details) => widget.onLongPressStart!(context, details, value)
|
||||||
|
: null,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,6 +16,7 @@ class PhotoViewGestureDetector extends StatelessWidget {
|
|||||||
this.onDragStart,
|
this.onDragStart,
|
||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
|
this.onLongPressStart,
|
||||||
this.child,
|
this.child,
|
||||||
this.onTapUp,
|
this.onTapUp,
|
||||||
this.onTapDown,
|
this.onTapDown,
|
||||||
@ -36,6 +37,8 @@ class PhotoViewGestureDetector extends StatelessWidget {
|
|||||||
final GestureTapUpCallback? onTapUp;
|
final GestureTapUpCallback? onTapUp;
|
||||||
final GestureTapDownCallback? onTapDown;
|
final GestureTapDownCallback? onTapDown;
|
||||||
|
|
||||||
|
final GestureLongPressStartCallback? onLongPressStart;
|
||||||
|
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
|
||||||
final HitTestBehavior? behavior;
|
final HitTestBehavior? behavior;
|
||||||
@ -99,6 +102,13 @@ class PhotoViewGestureDetector extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gestures[LongPressGestureRecognizer] =
|
||||||
|
GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
|
||||||
|
() => LongPressGestureRecognizer(debugOwner: this),
|
||||||
|
(LongPressGestureRecognizer instance) {
|
||||||
|
instance.onLongPressStart = onLongPressStart;
|
||||||
|
});
|
||||||
|
|
||||||
return RawGestureDetector(
|
return RawGestureDetector(
|
||||||
behavior: behavior,
|
behavior: behavior,
|
||||||
gestures: gestures,
|
gestures: gestures,
|
||||||
|
@ -28,6 +28,7 @@ class ImageWrapper extends StatefulWidget {
|
|||||||
required this.onDragEnd,
|
required this.onDragEnd,
|
||||||
required this.onDragUpdate,
|
required this.onDragUpdate,
|
||||||
required this.onScaleEnd,
|
required this.onScaleEnd,
|
||||||
|
required this.onLongPressStart,
|
||||||
required this.outerSize,
|
required this.outerSize,
|
||||||
required this.gestureDetectorBehavior,
|
required this.gestureDetectorBehavior,
|
||||||
required this.tightMode,
|
required this.tightMode,
|
||||||
@ -59,6 +60,7 @@ class ImageWrapper extends StatefulWidget {
|
|||||||
final PhotoViewImageDragEndCallback? onDragEnd;
|
final PhotoViewImageDragEndCallback? onDragEnd;
|
||||||
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
||||||
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
||||||
|
final PhotoViewImageLongPressStartCallback? onLongPressStart;
|
||||||
final Size outerSize;
|
final Size outerSize;
|
||||||
final HitTestBehavior? gestureDetectorBehavior;
|
final HitTestBehavior? gestureDetectorBehavior;
|
||||||
final bool? tightMode;
|
final bool? tightMode;
|
||||||
@ -205,6 +207,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
|
|||||||
onDragEnd: widget.onDragEnd,
|
onDragEnd: widget.onDragEnd,
|
||||||
onDragUpdate: widget.onDragUpdate,
|
onDragUpdate: widget.onDragUpdate,
|
||||||
onScaleEnd: widget.onScaleEnd,
|
onScaleEnd: widget.onScaleEnd,
|
||||||
|
onLongPressStart: widget.onLongPressStart,
|
||||||
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
gestureDetectorBehavior: widget.gestureDetectorBehavior,
|
||||||
tightMode: widget.tightMode ?? false,
|
tightMode: widget.tightMode ?? false,
|
||||||
filterQuality: widget.filterQuality ?? FilterQuality.none,
|
filterQuality: widget.filterQuality ?? FilterQuality.none,
|
||||||
@ -257,6 +260,7 @@ class CustomChildWrapper extends StatelessWidget {
|
|||||||
this.onDragEnd,
|
this.onDragEnd,
|
||||||
this.onDragUpdate,
|
this.onDragUpdate,
|
||||||
this.onScaleEnd,
|
this.onScaleEnd,
|
||||||
|
this.onLongPressStart,
|
||||||
required this.outerSize,
|
required this.outerSize,
|
||||||
this.gestureDetectorBehavior,
|
this.gestureDetectorBehavior,
|
||||||
required this.tightMode,
|
required this.tightMode,
|
||||||
@ -287,6 +291,7 @@ class CustomChildWrapper extends StatelessWidget {
|
|||||||
final PhotoViewImageDragEndCallback? onDragEnd;
|
final PhotoViewImageDragEndCallback? onDragEnd;
|
||||||
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
final PhotoViewImageDragUpdateCallback? onDragUpdate;
|
||||||
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
final PhotoViewImageScaleEndCallback? onScaleEnd;
|
||||||
|
final PhotoViewImageLongPressStartCallback? onLongPressStart;
|
||||||
final Size outerSize;
|
final Size outerSize;
|
||||||
final HitTestBehavior? gestureDetectorBehavior;
|
final HitTestBehavior? gestureDetectorBehavior;
|
||||||
final bool? tightMode;
|
final bool? tightMode;
|
||||||
@ -320,6 +325,7 @@ class CustomChildWrapper extends StatelessWidget {
|
|||||||
onDragEnd: onDragEnd,
|
onDragEnd: onDragEnd,
|
||||||
onDragUpdate: onDragUpdate,
|
onDragUpdate: onDragUpdate,
|
||||||
onScaleEnd: onScaleEnd,
|
onScaleEnd: onScaleEnd,
|
||||||
|
onLongPressStart: onLongPressStart,
|
||||||
gestureDetectorBehavior: gestureDetectorBehavior,
|
gestureDetectorBehavior: gestureDetectorBehavior,
|
||||||
tightMode: tightMode ?? false,
|
tightMode: tightMode ?? false,
|
||||||
filterQuality: filterQuality ?? FilterQuality.none,
|
filterQuality: filterQuality ?? FilterQuality.none,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user