ArticleItemView now uses feedIconPath
This commit is contained in:
parent
350c373ae2
commit
db9dbc97ec
@ -13,14 +13,14 @@ struct ArticleItemView: View {
|
|||||||
|
|
||||||
var article: LatestArticle
|
var article: LatestArticle
|
||||||
var deepLink: URL
|
var deepLink: URL
|
||||||
@State private var iconImage: UIImage?
|
@State private var iconImage: Image?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Link(destination: deepLink, label: {
|
Link(destination: deepLink, label: {
|
||||||
HStack(alignment: .top, spacing: nil, content: {
|
HStack(alignment: .top, spacing: nil, content: {
|
||||||
// Feed Icon
|
// Feed Icon
|
||||||
if iconImage != nil {
|
if iconImage != nil {
|
||||||
Image(uiImage: iconImage!)
|
iconImage!
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 30, height: 30)
|
.frame(width: 30, height: 30)
|
||||||
.cornerRadius(4)
|
.cornerRadius(4)
|
||||||
@ -49,16 +49,18 @@ struct ArticleItemView: View {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).onAppear {
|
}).onAppear {
|
||||||
iconImage = thumbnail(article.feedIcon)
|
iconImage = thumbnail(from: article.feedIconPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func thumbnail(_ data: Data?) -> UIImage {
|
func thumbnail(from path: String?) -> Image? {
|
||||||
if data == nil {
|
guard let imagePath = path,
|
||||||
return UIImage(systemName: "globe")!
|
let url = URL(string: imagePath),
|
||||||
} else {
|
let data = try? Data(contentsOf: url),
|
||||||
return UIImage(data: data!)!
|
let uiImage = UIImage(data: data) else {
|
||||||
|
return Image(uiImage: UIImage(systemName: "globe")!)
|
||||||
}
|
}
|
||||||
|
return Image(uiImage: uiImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pubDate(_ dateString: String) -> String {
|
func pubDate(_ dateString: String) -> String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user