Files
NetNewsWire/iOS/MainTimeline/Cell/MainTimelineCellData.swift
T

91 lines
2.3 KiB
Swift
Raw Normal View History

//
2024-12-24 12:09:41 -08:00
// MainTimelineCellData.swift
// NetNewsWire
//
// Created by Brent Simmons on 2/6/16.
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//
import UIKit
import Articles
2026-05-29 10:46:00 -07:00
import Images
2025-11-13 17:11:34 -08:00
@MainActor struct MainTimelineCellData {
private static let noText = NSLocalizedString("(No Text)", comment: "No Text")
2025-11-05 11:22:10 -08:00
let accountID: String
let articleID: String
let title: String
2020-04-30 11:53:10 -05:00
let attributedTitle: NSAttributedString
2019-04-29 14:40:14 -05:00
let summary: String
let dateString: String
let feedName: String
let byline: String
let showFeedName: ShowFeedName
let iconImage: IconImage? // feed icon, user avatar, or favicon
let showIcon: Bool // Make space even when icon is nil
let read: Bool
let starred: Bool
let numberOfLines: Int
let iconSize: IconSize
2024-12-15 10:46:05 -08:00
init(article: Article, showFeedName: ShowFeedName, feedName: String?, byline: String?, iconImage: IconImage?, showIcon: Bool, numberOfLines: Int, iconSize: IconSize) {
self.accountID = article.accountID
self.articleID = article.articleID
self.title = ArticleStringFormatter.shared.truncatedTitle(article)
self.attributedTitle = ArticleStringFormatter.shared.attributedTruncatedTitle(article)
let truncatedSummary = ArticleStringFormatter.shared.truncatedSummary(article)
if self.title.isEmpty && truncatedSummary.isEmpty {
self.summary = Self.noText
} else {
self.summary = truncatedSummary
}
2025-11-05 11:22:10 -08:00
self.dateString = ArticleStringFormatter.shared.dateString(article.logicalDatePublished)
if let feedName = feedName {
self.feedName = ArticleStringFormatter.shared.truncatedFeedName(feedName)
2026-01-02 11:57:55 -08:00
} else {
self.feedName = ""
}
2025-11-05 11:22:10 -08:00
if let byline = byline {
self.byline = byline
} else {
self.byline = ""
}
self.showFeedName = showFeedName
self.showIcon = showIcon
self.iconImage = iconImage
2024-12-15 10:46:05 -08:00
self.read = article.status.read
self.starred = article.status.starred
self.numberOfLines = numberOfLines
2019-11-08 17:16:09 -06:00
self.iconSize = iconSize
2025-11-05 11:22:10 -08:00
}
2026-01-02 11:42:12 -08:00
init() { // Empty
self.accountID = ""
self.articleID = ""
self.title = ""
2020-04-30 11:53:10 -05:00
self.attributedTitle = NSAttributedString()
2019-04-29 14:40:14 -05:00
self.summary = ""
self.dateString = ""
self.feedName = ""
self.byline = ""
self.showFeedName = .none
self.showIcon = false
self.iconImage = nil
self.read = true
self.starred = false
self.numberOfLines = 0
2019-11-08 17:16:09 -06:00
self.iconSize = .medium
}
2025-11-05 11:22:10 -08:00
}