From 4d75e7504c9a7d00f07ae9abc72c0b6607260200 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Tue, 9 Nov 2021 10:46:44 +0800 Subject: [PATCH] Resolves partial widget images --- Widget/Shared Views/ArticleItemView.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Widget/Shared Views/ArticleItemView.swift b/Widget/Shared Views/ArticleItemView.swift index c3ed7467d..ff922155e 100644 --- a/Widget/Shared Views/ArticleItemView.swift +++ b/Widget/Shared Views/ArticleItemView.swift @@ -13,15 +13,18 @@ struct ArticleItemView: View { var article: LatestArticle var deepLink: URL + @State private var iconImage: UIImage? var body: some View { Link(destination: deepLink, label: { HStack(alignment: .top, spacing: nil, content: { // Feed Icon - Image(uiImage: thumbnail(article.feedIcon)) - .resizable() - .frame(width: 30, height: 30) - .cornerRadius(4) + if iconImage != nil { + Image(uiImage: iconImage!) + .resizable() + .frame(width: 30, height: 30) + .cornerRadius(4) + } // Title and Feed Name VStack(alignment: .leading) { @@ -45,7 +48,9 @@ struct ArticleItemView: View { } } }) - }) + }).onAppear { + iconImage = thumbnail(article.feedIcon) + } } func thumbnail(_ data: Data?) -> UIImage {