NetNewsWire/Multiplatform/Shared/Timeline/TimelineItem.swift

54 lines
891 B
Swift
Raw Normal View History

2020-06-30 18:03:33 +02:00
//
// TimelineItem.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/30/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
import Articles
2020-07-01 23:33:07 +02:00
enum TimelineItemStatus {
case showStar
case showUnread
case showNone
}
2020-06-30 18:03:33 +02:00
struct TimelineItem: Identifiable {
2020-07-01 18:13:11 +02:00
var article: Article
2020-06-30 18:03:33 +02:00
init(article: Article) {
self.article = article
updateStatus()
}
2020-07-01 18:13:11 +02:00
var id: String {
return article.articleID
}
2020-06-30 18:03:33 +02:00
var status: TimelineItemStatus = .showNone
2020-07-01 23:33:07 +02:00
2020-07-02 00:39:27 +02:00
var byline: String {
return article.webFeed?.nameForDisplay ?? ""
2020-07-02 00:39:27 +02:00
}
var dateTimeString: String {
return ArticleStringFormatter.dateString(article.logicalDatePublished)
}
mutating func updateStatus() {
if article.status.starred == true {
status = .showStar
} else {
if article.status.read == false {
status = .showUnread
} else {
status = .showNone
}
}
}
2020-06-30 18:03:33 +02:00
}