mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
show video restore btn if translated
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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<MouseInteractiveViewer>
|
||||
_transformer.value,
|
||||
newFocalPointScene - focalPointScene,
|
||||
);
|
||||
|
||||
widget.onTranslate();
|
||||
}
|
||||
|
||||
void _handleInertiaAnimation() {
|
||||
|
||||
@@ -740,7 +740,7 @@ class _InteractiveViewerState extends State<InteractiveViewer>
|
||||
// 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<InteractiveViewer>
|
||||
// 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<InteractiveViewer>
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
|
||||
void onDoubleTap() {
|
||||
Matrix4 matrix = _transformationController.value.clone();
|
||||
double currentScale = matrix.row0.x;
|
||||
double currentScale = matrix.storage[0];
|
||||
|
||||
double targetScale = widget.minScale;
|
||||
|
||||
|
||||
@@ -936,7 +936,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
}
|
||||
|
||||
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<PLVideoPlayer>
|
||||
: 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,
|
||||
|
||||
Reference in New Issue
Block a user