Compare commits

...

5 Commits

Author SHA1 Message Date
LeLunZ
10bc17dace fix(mobile): simplify scale handling in photo_view_core.dart 2026-04-21 18:25:34 +02:00
LeLunZ
fa11a9a01b fix(mobile): keep zoom consistent when scale boundaries change 2026-04-21 18:15:48 +02:00
LeLunZ
4bd3d6054e revert fixes 2026-04-21 18:10:12 +02:00
LeLunZ
48b3b3caba fix(mobile): use actual child size for live photo 2026-04-21 15:03:33 +02:00
LeLunZ
276b42d3ff fix(mobile): preserve zoom level when new images load in asset viewer 2026-04-21 15:03:32 +02:00
2 changed files with 20 additions and 10 deletions

View File

@@ -139,8 +139,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
PhotoViewHeroAttributes? get heroAttributes => widget.heroAttributes;
late ScaleBoundaries cachedScaleBoundaries = widget.scaleBoundaries;
void handleScaleAnimation() {
scale = _scaleAnimation!.value;
}
@@ -303,7 +301,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
controller.scaleAnimationBuilder(_animateControllerScale);
controller.rotationAnimationBuilder(_animateControllerRotation);
cachedScaleBoundaries = widget.scaleBoundaries;
_updateScaleBoundaries();
_scaleAnimationController = AnimationController(vsync: this)
..addListener(handleScaleAnimation)
@@ -334,14 +332,27 @@ class PhotoViewCoreState extends State<PhotoViewCore>
widget.onTapDown?.call(context, details, controller.value);
}
void _updateScaleBoundaries() {
final prev = controller.scaleBoundaries;
if (prev == widget.scaleBoundaries) return;
if (prev != null && controller.scale != null && prev.initialScale > 0) {
final ratio = widget.scaleBoundaries.initialScale / prev.initialScale;
controller.setScaleInvisibly(controller.scale! * ratio);
} else {
markNeedsScaleRecalc = true;
}
controller.scaleBoundaries = widget.scaleBoundaries;
}
@override
void didUpdateWidget(PhotoViewCore oldWidget) {
super.didUpdateWidget(oldWidget);
_updateScaleBoundaries();
}
@override
Widget build(BuildContext context) {
// Check if we need a recalc on the scale
if (widget.scaleBoundaries != cachedScaleBoundaries) {
markNeedsScaleRecalc = true;
cachedScaleBoundaries = widget.scaleBoundaries;
}
return StreamBuilder(
stream: controller.outputStateStream,
initialData: controller.prevValue,

View File

@@ -145,7 +145,6 @@ class _ImageWrapperState extends State<ImageWrapper> {
_lastStack = null;
_didLoadSynchronously = synchronousCall;
widget.controller.scaleBoundaries = scaleBoundaries;
}
synchronousCall && !_didLoadSynchronously ? setupCB() : setState(setupCB);