mirror of
https://github.com/immich-app/immich.git
synced 2026-05-21 23:26:31 -04:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 706be2db5f | |||
| 10bc17dace | |||
| fa11a9a01b | |||
| 4bd3d6054e | |||
| 48b3b3caba | |||
| 276b42d3ff |
@@ -139,8 +139,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
|
|
||||||
PhotoViewHeroAttributes? get heroAttributes => widget.heroAttributes;
|
PhotoViewHeroAttributes? get heroAttributes => widget.heroAttributes;
|
||||||
|
|
||||||
late ScaleBoundaries cachedScaleBoundaries = widget.scaleBoundaries;
|
|
||||||
|
|
||||||
void handleScaleAnimation() {
|
void handleScaleAnimation() {
|
||||||
scale = _scaleAnimation!.value;
|
scale = _scaleAnimation!.value;
|
||||||
}
|
}
|
||||||
@@ -303,7 +301,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
controller.scaleAnimationBuilder(_animateControllerScale);
|
controller.scaleAnimationBuilder(_animateControllerScale);
|
||||||
controller.rotationAnimationBuilder(_animateControllerRotation);
|
controller.rotationAnimationBuilder(_animateControllerRotation);
|
||||||
|
|
||||||
cachedScaleBoundaries = widget.scaleBoundaries;
|
_updateScaleBoundaries();
|
||||||
|
|
||||||
_scaleAnimationController = AnimationController(vsync: this)
|
_scaleAnimationController = AnimationController(vsync: this)
|
||||||
..addListener(handleScaleAnimation)
|
..addListener(handleScaleAnimation)
|
||||||
@@ -334,14 +332,27 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
widget.onTapDown?.call(context, details, controller.value);
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Check if we need a recalc on the scale
|
|
||||||
if (widget.scaleBoundaries != cachedScaleBoundaries) {
|
|
||||||
markNeedsScaleRecalc = true;
|
|
||||||
cachedScaleBoundaries = widget.scaleBoundaries;
|
|
||||||
}
|
|
||||||
|
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: controller.outputStateStream,
|
stream: controller.outputStateStream,
|
||||||
initialData: controller.prevValue,
|
initialData: controller.prevValue,
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ class _ImageWrapperState extends State<ImageWrapper> {
|
|||||||
_lastStack = null;
|
_lastStack = null;
|
||||||
|
|
||||||
_didLoadSynchronously = synchronousCall;
|
_didLoadSynchronously = synchronousCall;
|
||||||
widget.controller.scaleBoundaries = scaleBoundaries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronousCall && !_didLoadSynchronously ? setupCB() : setState(setupCB);
|
synchronousCall && !_didLoadSynchronously ? setupCB() : setState(setupCB);
|
||||||
|
|||||||
Reference in New Issue
Block a user