Merge pull request #3618 from stuartbreckenridge/ios-candidate

ArticleItemView now uses feedIconPath
This commit is contained in:
Brent Simmons
2022-07-07 11:17:10 -07:00
committed by GitHub

View File

@@ -13,14 +13,14 @@ struct ArticleItemView: View {
var article: LatestArticle
var deepLink: URL
@State private var iconImage: UIImage?
@State private var iconImage: Image?
var body: some View {
Link(destination: deepLink, label: {
HStack(alignment: .top, spacing: nil, content: {
// Feed Icon
if iconImage != nil {
Image(uiImage: iconImage!)
iconImage!
.resizable()
.frame(width: 30, height: 30)
.cornerRadius(4)
@@ -49,16 +49,18 @@ struct ArticleItemView: View {
}
})
}).onAppear {
iconImage = thumbnail(article.feedIcon)
iconImage = thumbnail(from: article.feedIconPath)
}
}
func thumbnail(_ data: Data?) -> UIImage {
if data == nil {
return UIImage(systemName: "globe")!
} else {
return UIImage(data: data!)!
func thumbnail(from path: String?) -> Image? {
guard let imagePath = path,
let url = URL(string: imagePath),
let data = try? Data(contentsOf: url),
let uiImage = UIImage(data: data) else {
return Image(uiImage: UIImage(systemName: "globe")!)
}
return Image(uiImage: uiImage)
}
func pubDate(_ dateString: String) -> String {