From 67041b22f470e8c1faa7149334257124b11d41a1 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 4 Apr 2023 10:24:59 -0700 Subject: [PATCH] refactor: simplify calculate_image_fill argument --- damus/Components/ImageCarousel.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/damus/Components/ImageCarousel.swift b/damus/Components/ImageCarousel.swift index 1efa2c4c..433686d8 100644 --- a/damus/Components/ImageCarousel.swift +++ b/damus/Components/ImageCarousel.swift @@ -84,9 +84,10 @@ struct ImageCarousel: View { } let img_size = img.size let is_animated = img.kf.imageFrameCount != nil + let geo_size = geo.size DispatchQueue.main.async { - let fill = calculate_image_fill(geo: geo, img_size: img_size, is_animated: is_animated, maxHeight: maxHeight, minHeight: minHeight) + let fill = calculate_image_fill(geo_size: geo_size, img_size: img_size, is_animated: is_animated, maxHeight: maxHeight, minHeight: minHeight) self.previews.cache_image_meta(evid: evid, image_fill: fill) self.image_fill = fill @@ -130,10 +131,10 @@ struct ImageFill { let height: CGFloat } -func calculate_image_fill(geo: GeometryProxy, img_size: CGSize, is_animated: Bool, maxHeight: CGFloat, minHeight: CGFloat) -> ImageFill { +func calculate_image_fill(geo_size: CGSize, img_size: CGSize, is_animated: Bool, maxHeight: CGFloat, minHeight: CGFloat) -> ImageFill { let shape = determine_image_shape(img_size) - let xfactor = geo.size.width / img_size.width + let xfactor = geo_size.width / img_size.width let scaled = img_size.height * xfactor let yfactor = maxHeight / scaled // calculate scaled image height