diff --git a/lib/common/widgets/gesture/mouse_interactive_viewer.dart b/lib/common/widgets/gesture/mouse_interactive_viewer.dart index dcf85a6a4..83af59fbd 100644 --- a/lib/common/widgets/gesture/mouse_interactive_viewer.dart +++ b/lib/common/widgets/gesture/mouse_interactive_viewer.dart @@ -36,9 +36,9 @@ class MouseInteractiveViewer extends StatefulWidget { this.transformationController, this.alignment, this.trackpadScrollCausesScale = false, - required this.childKey, required this.child, + required this.onTranslate, }) : assert(minScale > 0), assert(interactionEndFrictionCoefficient > 0), assert(maxScale > 0), @@ -66,6 +66,7 @@ class MouseInteractiveViewer extends StatefulWidget { final GestureScaleUpdateCallback? onInteractionUpdate; final TransformationController? transformationController; final GlobalKey childKey; + final VoidCallback onTranslate; static const double _kDrag = 0.0000135; @@ -641,6 +642,8 @@ class _MouseInteractiveViewerState extends State _transformer.value, newFocalPointScene - focalPointScene, ); + + widget.onTranslate(); } void _handleInertiaAnimation() { diff --git a/lib/common/widgets/interactiveviewer_gallery/interactive_viewer.dart b/lib/common/widgets/interactiveviewer_gallery/interactive_viewer.dart index 7a60ae2de..6a8eabd93 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactive_viewer.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactive_viewer.dart @@ -740,7 +740,7 @@ class _InteractiveViewerState extends State // with GestureDetector's scale gesture. void _onScaleStart(ScaleStartDetails details) { if (widget.isAnimating?.call() == true || - (details.pointerCount < 2 && _transformer.value.row0.x == 1.0)) { + (details.pointerCount < 2 && _transformer.value.storage[0] == 1.0)) { widget.onPanStart?.call(details); return; } @@ -773,7 +773,7 @@ class _InteractiveViewerState extends State // handled with GestureDetector's scale gesture. void _onScaleUpdate(ScaleUpdateDetails details) { if (widget.isAnimating?.call() == true || - (details.pointerCount < 2 && _transformer.value.row0.x == 1.0)) { + (details.pointerCount < 2 && _transformer.value.storage[0] == 1.0)) { widget.onPanUpdate?.call(details); return; } @@ -873,11 +873,11 @@ class _InteractiveViewerState extends State // Handle the end of a gesture of _GestureType. All of pan, scale, and rotate // are handled with GestureDetector's scale gesture. void _onScaleEnd(ScaleEndDetails details) { - if (_transformer.value.row0.x == 1.0) { + if (_transformer.value.storage[0] == 1.0) { widget.onReset?.call(); } if (widget.isAnimating?.call() == true || - (details.pointerCount < 2 && _transformer.value.row0.x == 1.0)) { + (details.pointerCount < 2 && _transformer.value.storage[0] == 1.0)) { widget.onPanEnd?.call(details); return; } diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index 2900d7df2..a46434e31 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -359,7 +359,7 @@ class _InteractiveviewerGalleryState extends State void onDoubleTap() { Matrix4 matrix = _transformationController.value.clone(); - double currentScale = matrix.row0.x; + double currentScale = matrix.storage[0]; double targetScale = widget.minScale; diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 1ab96f3a3..dec5235eb 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -936,7 +936,8 @@ class _PLVideoPlayerState extends State } void _onInteractionUpdate(ScaleUpdateDetails details) { - showRestoreScaleBtn.value = transformationController.value.row0.x != 1.0; + showRestoreScaleBtn.value = + transformationController.value.storage[0] != 1.0; if (interacting || plPlayerController.initialFocalPoint == Offset.zero) { return; } @@ -2071,6 +2072,13 @@ class _PLVideoPlayerState extends State : EdgeInsets.zero, panAxis: PanAxis.aligned, transformationController: transformationController, + onTranslate: () { + final storage = transformationController.value.storage; + showRestoreScaleBtn.value = + storage[12].abs() > 2.0 || + storage[13].abs() > 2.0 || + storage[0] != 1.0; + }, childKey: _videoKey, child: RepaintBoundary( key: _videoKey,