-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewsFeedCellView.swift
62 lines (48 loc) · 1.21 KB
/
NewsFeedCellView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// NewsFeedCellView.swift
// TodayNews
//
// Created by Norris Wise Jr on 10/17/24.
//
import Foundation
import SwiftUI
import CachedAsyncImage
struct NewsFeedCellView: View {
let article: Article
var body: some View {
HStack {
CachedAsyncImage(url: URL(string: article.urlToImage ?? ""), urlCache: .imageCache) { img in
let image = img.image ?? Image("newsIcon")
image
.resizable()
.frame(width: 90, height: 90)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
VStack(alignment: .leading) {
Text(ArticleUtilities.shared.getShortAuthor(article.author))
.font(.custom("Poppins", size: 18))
.foregroundStyle(.gray)
Text(article.title ?? "[missing article]")
.lineLimit(2, reservesSpace: true)
.padding(.trailing)
HStack {
Image("bbcNewsImage")
.resizable()
.frame(width: 20, height: 20)
Text(article.source.name ?? "News")
.bold()
Image("clockImage")
.resizable()
.frame(width: 14, height: 14)
Text(">24 hrs ago")
.foregroundStyle(.gray)
}
}
Spacer()
}
.frame(maxWidth: .infinity)
}
}
#Preview {
NewsFeedCellView(article: Article(source: Source()))
}