2020-07-01 18:13:11 +02:00
|
|
|
//
|
|
|
|
// TimelineItemView.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 7/1/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct TimelineItemView: View {
|
|
|
|
|
2020-07-02 00:21:58 +02:00
|
|
|
@StateObject var articleIconImageLoader = ArticleIconImageLoader()
|
2020-07-01 18:13:11 +02:00
|
|
|
var timelineItem: TimelineItem
|
|
|
|
|
|
|
|
var body: some View {
|
2020-07-01 19:30:55 +02:00
|
|
|
VStack {
|
2020-07-01 23:33:07 +02:00
|
|
|
HStack(alignment: .top) {
|
|
|
|
TimelineItemStatusView(status: timelineItem.status)
|
2020-07-02 00:21:58 +02:00
|
|
|
if let image = articleIconImageLoader.image {
|
|
|
|
IconImageView(iconImage: image)
|
|
|
|
.frame(width: AppDefaults.timelineIconSize.size.width, height: AppDefaults.timelineIconSize.size.height, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
|
}
|
2020-07-02 00:39:27 +02:00
|
|
|
VStack {
|
|
|
|
Text(verbatim: timelineItem.article.title ?? "N/A")
|
|
|
|
.lineLimit(3)
|
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
.padding(.trailing, 4)
|
|
|
|
Spacer()
|
|
|
|
HStack {
|
|
|
|
Text(verbatim: timelineItem.byline)
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
Spacer()
|
|
|
|
Text(verbatim: timelineItem.dateTimeString)
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.padding(.trailing, 4)
|
|
|
|
}
|
|
|
|
}
|
2020-07-01 23:33:07 +02:00
|
|
|
}
|
2020-07-01 19:30:55 +02:00
|
|
|
Divider()
|
|
|
|
}
|
2020-07-02 00:21:58 +02:00
|
|
|
.onAppear {
|
|
|
|
articleIconImageLoader.loadImage(for: timelineItem.article)
|
|
|
|
}
|
2020-07-01 18:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-01 23:33:07 +02:00
|
|
|
struct TimelineItemView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
Group {
|
|
|
|
TimelineItemView(timelineItem: TimelineItem(article: PreviewArticles.basicRead))
|
|
|
|
.frame(maxWidth: 250)
|
|
|
|
TimelineItemView(timelineItem: TimelineItem(article: PreviewArticles.basicUnread))
|
|
|
|
.frame(maxWidth: 250)
|
|
|
|
TimelineItemView(timelineItem: TimelineItem(article: PreviewArticles.basicStarred))
|
|
|
|
.frame(maxWidth: 250)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|