NetNewsWire/Mac/MainWindow/Timeline/Cell/TimelineCellData.swift

81 lines
2.0 KiB
Swift
Raw Normal View History

2017-05-27 19:43:27 +02:00
//
// TimelineCellData.swift
2018-08-29 07:18:24 +02:00
// NetNewsWire
2017-05-27 19:43:27 +02:00
//
// Created by Brent Simmons on 2/6/16.
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//
import AppKit
import Articles
import Images
2017-05-27 19:43:27 +02:00
2024-03-20 07:05:30 +01:00
@MainActor struct TimelineCellData {
2017-05-27 19:43:27 +02:00
private static let noText = NSLocalizedString("(No Text)", comment: "No Text")
2017-05-27 19:43:27 +02:00
let title: String
let attributedTitle: NSAttributedString
2017-05-27 19:43:27 +02:00
let text: String
let dateString: String
let feedName: String
let byline: String
let showFeedName: TimelineShowFeedName
let iconImage: IconImage? // feed icon, user avatar, or favicon
let showIcon: Bool // Make space even when icon is nil
let featuredImage: NSImage? // image from within the article
2017-05-27 19:43:27 +02:00
let read: Bool
let starred: Bool
2017-05-27 19:43:27 +02:00
init(article: Article, showFeedName: TimelineShowFeedName, feedName: String?, byline: String?, iconImage: IconImage?, showIcon: Bool, featuredImage: NSImage?) {
self.title = ArticleStringFormatter.truncatedTitle(article)
self.attributedTitle = ArticleStringFormatter.attributedTruncatedTitle(article)
2017-05-27 19:43:27 +02:00
let truncatedSummary = ArticleStringFormatter.truncatedSummary(article)
if self.title.isEmpty && truncatedSummary.isEmpty {
self.text = Self.noText
} else {
self.text = truncatedSummary
}
self.dateString = ArticleStringFormatter.dateString(article.logicalDatePublished)
2017-05-27 19:43:27 +02:00
if let feedName = feedName {
self.feedName = ArticleStringFormatter.truncatedFeedName(feedName)
} else {
2017-05-27 19:43:27 +02:00
self.feedName = ""
}
if let byline = byline {
self.byline = byline
} else {
self.byline = ""
}
2017-05-27 19:43:27 +02:00
self.showFeedName = showFeedName
self.showIcon = showIcon
self.iconImage = iconImage
self.featuredImage = featuredImage
2017-09-24 21:24:44 +02:00
self.read = article.status.read
self.starred = article.status.starred
2017-05-27 19:43:27 +02:00
}
init() { //Empty
self.title = ""
self.text = ""
self.dateString = ""
self.feedName = ""
self.byline = ""
self.showFeedName = .none
self.showIcon = false
self.iconImage = nil
self.featuredImage = nil
2017-05-27 19:43:27 +02:00
self.read = true
self.starred = false
self.attributedTitle = NSAttributedString()
2017-05-27 19:43:27 +02:00
}
}