From 15d7d1dabdbc1a1b21dbd51dc70adf9624d2c319 Mon Sep 17 00:00:00 2001 From: "Thai D. V" <46838577+thai-d-v@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:50:10 +0700 Subject: [PATCH] handle edge cases for `StatusRowCardView` (#1985) --- .../Row/Subviews/StatusRowCardView.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift index 23f8c752..d9ff53ac 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowCardView.swift @@ -234,13 +234,11 @@ struct DefaultPreviewImage: View { var body: some View { _Layout(originalWidth: originalWidth, originalHeight: originalHeight) { LazyResizableImage(url: url) { state, _ in - Rectangle() - .fill(theme.secondaryBackgroundColor) - .overlay { - if let image = state.image { - image.resizable().scaledToFill() - } - } + if let image = state.image?.resizable() { + Rectangle().fill(theme.secondaryBackgroundColor) + .overlay { image.scaledToFill().blur(radius: 50) } + .overlay { image.scaledToFit() } + } } .accessibilityHidden(true) // This image is decorative .clipped() @@ -264,7 +262,7 @@ struct DefaultPreviewImage: View { } private func calculateSize(_ proposal: ProposedViewSize) -> CGSize { - switch (proposal.width, proposal.height) { + var size = switch (proposal.width, proposal.height) { case (nil, nil): CGSize(width: originalWidth, height: originalWidth) case let (nil, .some(height)): @@ -278,6 +276,9 @@ struct DefaultPreviewImage: View { CGSize(width: width, height: width / originalWidth * originalHeight) } } + + size.height = min(size.height, 450) + return size } } }