From 62eeba5334f015f799ebbd1783ab429b57e333bd Mon Sep 17 00:00:00 2001 From: "Thai D. V" <46838577+thai-d-v@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:58:01 +0700 Subject: [PATCH] use default frame for preview images that API returns incorrect (width: 0, height: 0) (#1915) --- .../StatusKit/Row/Subviews/StatusRowCardView.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift index c72a492e..7b185f89 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift @@ -197,9 +197,7 @@ struct DefaultPreviewImage: View { } private func calculateSize(_ proposal: ProposedViewSize) -> CGSize { - guard originalWidth > 0 else { return CGSize.zero } - - return switch (proposal.width, proposal.height) { + switch (proposal.width, proposal.height) { case (nil, nil): CGSize(width: originalWidth, height: originalWidth) case let (nil, .some(height)): @@ -207,7 +205,11 @@ struct DefaultPreviewImage: View { case (0, _): CGSize.zero case let (.some(width), _): - CGSize(width: width, height: width / originalWidth * originalHeight) + if originalWidth == 0 { + CGSize(width: width, height: width / 2) + } else { + CGSize(width: width, height: width / originalWidth * originalHeight) + } } } }