Continue reconciling names with 6.1.6-ios branch.

This commit is contained in:
Brent Simmons 2025-01-02 22:06:19 -08:00
parent e00f5d2619
commit 9cc4db638c
17 changed files with 183 additions and 183 deletions

View File

@ -9,7 +9,7 @@
import AppKit import AppKit
import Articles import Articles
struct TimelineCellData { struct MainTimelineCellData {
private static let noText = NSLocalizedString("(No Text)", comment: "No Text") private static let noText = NSLocalizedString("(No Text)", comment: "No Text")

View File

@ -8,7 +8,7 @@
import AppKit import AppKit
class UnreadIndicatorView: NSView { class MainUnreadIndicatorView: NSView {
static let unreadCircleDimension: CGFloat = 8.0 static let unreadCircleDimension: CGFloat = 8.0
@ -39,7 +39,7 @@ class UnreadIndicatorView: NSView {
} else { } else {
NSColor.controlAccentColor.setFill() NSColor.controlAccentColor.setFill()
} }
UnreadIndicatorView.bezierPath.fill() MainUnreadIndicatorView.bezierPath.fill()
} }
} }

View File

@ -48,7 +48,7 @@ struct TimelineCellLayout {
} }
} }
init(width: CGFloat, height: CGFloat, cellData: TimelineCellData, appearance: TimelineCellAppearance, hasIcon: Bool) { init(width: CGFloat, height: CGFloat, cellData: MainTimelineCellData, appearance: TimelineCellAppearance, hasIcon: Bool) {
// If height == 0.0, then height is calculated. // If height == 0.0, then height is calculated.
@ -82,7 +82,7 @@ struct TimelineCellLayout {
self.init(width: width, height: height, feedNameRect: feedNameRect, dateRect: dateRect, titleRect: titleRect, numberOfLinesForTitle: numberOfLinesForTitle, summaryRect: summaryRect, textRect: textRect, unreadIndicatorRect: unreadIndicatorRect, starRect: starRect, iconImageRect: iconImageRect, separatorRect: separatorRect, paddingBottom: paddingBottom) self.init(width: width, height: height, feedNameRect: feedNameRect, dateRect: dateRect, titleRect: titleRect, numberOfLinesForTitle: numberOfLinesForTitle, summaryRect: summaryRect, textRect: textRect, unreadIndicatorRect: unreadIndicatorRect, starRect: starRect, iconImageRect: iconImageRect, separatorRect: separatorRect, paddingBottom: paddingBottom)
} }
static func height(for width: CGFloat, cellData: TimelineCellData, appearance: TimelineCellAppearance) -> CGFloat { static func height(for width: CGFloat, cellData: MainTimelineCellData, appearance: TimelineCellAppearance) -> CGFloat {
let layout = TimelineCellLayout(width: width, height: 0.0, cellData: cellData, appearance: appearance, hasIcon: true) let layout = TimelineCellLayout(width: width, height: 0.0, cellData: cellData, appearance: appearance, hasIcon: true)
return layout.height return layout.height
@ -93,7 +93,7 @@ struct TimelineCellLayout {
private extension TimelineCellLayout { private extension TimelineCellLayout {
static func rectForTextBox(_ appearance: TimelineCellAppearance, _ cellData: TimelineCellData, _ showIcon: Bool, _ width: CGFloat) -> NSRect { static func rectForTextBox(_ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData, _ showIcon: Bool, _ width: CGFloat) -> NSRect {
// Returned height is a placeholder. Not needed when this is calculated. // Returned height is a placeholder. Not needed when this is calculated.
@ -106,7 +106,7 @@ private extension TimelineCellLayout {
return textBoxRect return textBoxRect
} }
static func rectForTitle(_ textBoxRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> (NSRect, Int) { static func rectForTitle(_ textBoxRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData) -> (NSRect, Int) {
var r = textBoxRect var r = textBoxRect
@ -124,7 +124,7 @@ private extension TimelineCellLayout {
return (r, sizeInfo.numberOfLinesUsed) return (r, sizeInfo.numberOfLinesUsed)
} }
static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData) -> NSRect {
if titleNumberOfLines >= appearance.titleNumberOfLines || cellData.text.isEmpty { if titleNumberOfLines >= appearance.titleNumberOfLines || cellData.text.isEmpty {
return NSRect.zero return NSRect.zero
} }
@ -142,7 +142,7 @@ private extension TimelineCellLayout {
} }
static func rectForText(_ textBoxRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { static func rectForText(_ textBoxRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData) -> NSRect {
var r = textBoxRect var r = textBoxRect
if cellData.text.isEmpty { if cellData.text.isEmpty {
@ -158,7 +158,7 @@ private extension TimelineCellLayout {
return r return r
} }
static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData) -> NSRect {
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont) let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont)
var r = NSZeroRect var r = NSZeroRect
@ -171,7 +171,7 @@ private extension TimelineCellLayout {
return r return r
} }
static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: MainTimelineCellData) -> NSRect {
if cellData.showFeedName == .none { if cellData.showFeedName == .none {
return NSZeroRect return NSZeroRect
} }
@ -208,7 +208,7 @@ private extension TimelineCellLayout {
return r return r
} }
static func rectForIcon(_ cellData: TimelineCellData, _ appearance: TimelineCellAppearance, _ showIcon: Bool, _ textBoxRect: NSRect, _ width: CGFloat, _ height: CGFloat) -> NSRect { static func rectForIcon(_ cellData: MainTimelineCellData, _ appearance: TimelineCellAppearance, _ showIcon: Bool, _ textBoxRect: NSRect, _ width: CGFloat, _ height: CGFloat) -> NSRect {
var r = NSRect.zero var r = NSRect.zero
if !showIcon { if !showIcon {
@ -221,7 +221,7 @@ private extension TimelineCellLayout {
return r return r
} }
static func rectForSeparator(_ cellData: TimelineCellData, _ appearance: TimelineCellAppearance, _ alignmentRect: NSRect, _ width: CGFloat, _ height: CGFloat) -> NSRect { static func rectForSeparator(_ cellData: MainTimelineCellData, _ appearance: TimelineCellAppearance, _ alignmentRect: NSRect, _ width: CGFloat, _ height: CGFloat) -> NSRect {
return NSRect(x: alignmentRect.minX, y: height - 1, width: width - alignmentRect.minX, height: 1) return NSRect(x: alignmentRect.minX, y: height - 1, width: width - alignmentRect.minX, height: 1)
} }
} }

View File

@ -14,7 +14,7 @@ class TimelineTableCellView: NSTableCellView {
private let titleView = TimelineTableCellView.multiLineTextField() private let titleView = TimelineTableCellView.multiLineTextField()
private let summaryView = TimelineTableCellView.multiLineTextField() private let summaryView = TimelineTableCellView.multiLineTextField()
private let textView = TimelineTableCellView.multiLineTextField() private let textView = TimelineTableCellView.multiLineTextField()
private let unreadIndicatorView = UnreadIndicatorView(frame: NSZeroRect) private let unreadIndicatorView = MainUnreadIndicatorView(frame: NSZeroRect)
private let dateView = TimelineTableCellView.singleLineTextField() private let dateView = TimelineTableCellView.singleLineTextField()
private let feedNameView = TimelineTableCellView.singleLineTextField() private let feedNameView = TimelineTableCellView.singleLineTextField()
@ -36,7 +36,7 @@ class TimelineTableCellView: NSTableCellView {
} }
} }
var cellData: TimelineCellData! { var cellData: MainTimelineCellData! {
didSet { didSet {
updateSubviews() updateSubviews()
} }

View File

@ -723,7 +723,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date()) let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: Constants.prototypeText, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status) let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: Constants.prototypeText, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
let prototypeCellData = TimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false, featuredImage: nil) let prototypeCellData = MainTimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false, featuredImage: nil)
let height = TimelineCellLayout.height(for: 100, cellData: prototypeCellData, appearance: cellAppearance) let height = TimelineCellLayout.height(for: 100, cellData: prototypeCellData, appearance: cellAppearance)
return height return height
} }
@ -876,7 +876,7 @@ extension TimelineViewController: NSTableViewDelegate {
private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) { private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) {
cell.objectValue = article cell.objectValue = article
let iconImage = article.iconImage() let iconImage = article.iconImage()
cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcons, featuredImage: nil) cell.cellData = MainTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcons, featuredImage: nil)
} }
private func iconFor(_ article: Article) -> IconImage? { private func iconFor(_ article: Article) -> IconImage? {
@ -892,7 +892,7 @@ extension TimelineViewController: NSTableViewDelegate {
private func makeTimelineCellEmpty(_ cell: TimelineTableCellView) { private func makeTimelineCellEmpty(_ cell: TimelineTableCellView) {
cell.objectValue = nil cell.objectValue = nil
cell.cellData = TimelineCellData() cell.cellData = MainTimelineCellData()
} }
private func toggleArticleRead(_ article: Article) { private func toggleArticleRead(_ article: Article) {

View File

@ -114,11 +114,11 @@
<objects> <objects>
<tableViewController storyboardIdentifier="TimelineViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" clearsSelectionOnViewWillAppear="NO" id="Kyk-vK-QRX" customClass="TimelineViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController"> <tableViewController storyboardIdentifier="TimelineViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" clearsSelectionOnViewWillAppear="NO" id="Kyk-vK-QRX" customClass="TimelineViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="onDrag" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="mtv-Ik-FoJ"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="onDrag" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="mtv-Ik-FoJ">
<rect key="frame" x="0.0" y="0.0" width="414" height="721"/> <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="208" id="T5d-L4-OKG" customClass="TimelineTableViewCell" customModule="NetNewsWire" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="208" id="T5d-L4-OKG" customClass="MainTimelineTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="414" height="208"/> <rect key="frame" x="0.0" y="50" width="414" height="208"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="T5d-L4-OKG" id="QKC-jN-XDy"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="T5d-L4-OKG" id="QKC-jN-XDy">

View File

@ -77,7 +77,7 @@ final class IconView: UIView {
private extension IconView { private extension IconView {
func commonInit() { func commonInit() {
layer.cornerRadius = TimelineDefaultCellLayout.iconCornerRadius layer.cornerRadius = MainTimelineDefaultCellLayout.iconCornerRadius
clipsToBounds = true clipsToBounds = true
addSubview(imageView) addSubview(imageView)
} }

View File

@ -946,7 +946,7 @@
<rect key="frame" x="0.0" y="0.0" width="300" height="128"/> <rect key="frame" x="0.0" y="0.0" width="300" height="128"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="Zaq-yo-L5h" customClass="TimelineTableViewCell" customModule="NetNewsWire" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="Zaq-yo-L5h" customClass="MainTimelineTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="300" height="43.5"/> <rect key="frame" x="0.0" y="50" width="300" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Zaq-yo-L5h" id="fD5-nw-z0z"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Zaq-yo-L5h" id="fD5-nw-z0z">

View File

@ -23,10 +23,10 @@ class TimelinePreviewTableViewController: UIViewController, UITableViewDelegate,
func heightFor(width: CGFloat) -> CGFloat { func heightFor(width: CGFloat) -> CGFloat {
if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory { if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory {
let layout = TimelineAccessibilityCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) let layout = MainTimelineAccessibilityCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
return layout.height return layout.height
} else { } else {
let layout = TimelineDefaultCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) let layout = MainTimelineDefaultCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
return layout.height return layout.height
} }
} }
@ -42,7 +42,7 @@ class TimelinePreviewTableViewController: UIViewController, UITableViewDelegate,
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TimelineTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MainTimelineTableViewCell
cell.cellData = prototypeCellData cell.cellData = prototypeCellData
return cell return cell
} }
@ -62,7 +62,7 @@ class TimelinePreviewTableViewController: UIViewController, UITableViewDelegate,
private extension TimelinePreviewTableViewController { private extension TimelinePreviewTableViewController {
var prototypeCellData: TimelineCellData { var prototypeCellData: MainTimelineCellData {
let longTitle = "Enim ut tellus elementum sagittis vitae et. Nibh praesent tristique magna sit amet purus gravida quis blandit. Neque volutpat ac tincidunt vitae semper quis lectus nulla. Massa id neque aliquam vestibulum morbi blandit. Ultrices vitae auctor eu augue. Enim eu turpis egestas pretium aenean pharetra magna. Eget gravida cum sociis natoque. Sit amet consectetur adipiscing elit. Auctor eu augue ut lectus arcu bibendum. Maecenas volutpat blandit aliquam etiam erat velit. Ut pharetra sit amet aliquam id diam maecenas ultricies. In hac habitasse platea dictumst quisque sagittis purus sit amet." let longTitle = "Enim ut tellus elementum sagittis vitae et. Nibh praesent tristique magna sit amet purus gravida quis blandit. Neque volutpat ac tincidunt vitae semper quis lectus nulla. Massa id neque aliquam vestibulum morbi blandit. Ultrices vitae auctor eu augue. Enim eu turpis egestas pretium aenean pharetra magna. Eget gravida cum sociis natoque. Sit amet consectetur adipiscing elit. Auctor eu augue ut lectus arcu bibendum. Maecenas volutpat blandit aliquam etiam erat velit. Ut pharetra sit amet aliquam id diam maecenas ultricies. In hac habitasse platea dictumst quisque sagittis purus sit amet."
let prototypeID = "prototype" let prototypeID = "prototype"
@ -71,7 +71,7 @@ private extension TimelinePreviewTableViewController {
let iconImage = IconImage(AppAssets.faviconTemplateImage.withTintColor(AppAssets.secondaryAccentColor)) let iconImage = IconImage(AppAssets.faviconTemplateImage.withTintColor(AppAssets.secondaryAccentColor))
return TimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Feed Name", byline: nil, iconImage: iconImage, showIcon: true, featuredImage: nil, numberOfLines: AppDefaults.shared.timelineNumberOfLines, iconSize: AppDefaults.shared.timelineIconSize) return MainTimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Feed Name", byline: nil, iconImage: iconImage, showIcon: true, featuredImage: nil, numberOfLines: AppDefaults.shared.timelineNumberOfLines, iconSize: AppDefaults.shared.timelineIconSize)
} }
} }

View File

@ -0,0 +1,90 @@
//
// MainTimelineAccessibilityCellLayout.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 4/29/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
import RSCore
struct MainTimelineAccessibilityCellLayout: MainTimelineCellLayout {
let height: CGFloat
let unreadIndicatorRect: CGRect
let starRect: CGRect
let iconImageRect: CGRect
let titleRect: CGRect
let summaryRect: CGRect
let feedNameRect: CGRect
let dateRect: CGRect
init(width: CGFloat, insets: UIEdgeInsets, cellData: MainTimelineCellData) {
var currentPoint = CGPoint.zero
currentPoint.x = MainTimelineDefaultCellLayout.cellPadding.left + insets.left + MainTimelineDefaultCellLayout.unreadCircleMarginLeft
currentPoint.y = MainTimelineDefaultCellLayout.cellPadding.top
// Unread Indicator and Star
self.unreadIndicatorRect = MainTimelineAccessibilityCellLayout.rectForUnreadIndicator(currentPoint)
self.starRect = MainTimelineAccessibilityCellLayout.rectForStar(currentPoint)
// Start the point at the beginning position of the main block
currentPoint.x += MainTimelineDefaultCellLayout.unreadCircleDimension + MainTimelineDefaultCellLayout.unreadCircleMarginRight
// Icon Image
if cellData.showIcon {
self.iconImageRect = MainTimelineAccessibilityCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize)
currentPoint.y = self.iconImageRect.maxY
} else {
self.iconImageRect = CGRect.zero
}
let textAreaWidth = width - (currentPoint.x + MainTimelineDefaultCellLayout.cellPadding.right + insets.right)
// Title Text Block
let (titleRect, numberOfLinesForTitle) = MainTimelineAccessibilityCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth)
self.titleRect = titleRect
// Summary Text Block
if self.titleRect != CGRect.zero {
currentPoint.y = self.titleRect.maxY + MainTimelineDefaultCellLayout.titleBottomMargin
}
self.summaryRect = MainTimelineAccessibilityCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle)
currentPoint.y = [self.titleRect, self.summaryRect].maxY()
if cellData.showFeedName != .none {
self.feedNameRect = MainTimelineAccessibilityCellLayout.rectForFeedName(cellData, currentPoint, textAreaWidth)
currentPoint.y = self.feedNameRect.maxY
} else {
self.feedNameRect = CGRect.zero
}
// Feed Name and Pub Date
self.dateRect = MainTimelineAccessibilityCellLayout.rectForDate(cellData, currentPoint, textAreaWidth)
self.height = self.dateRect.maxY + MainTimelineDefaultCellLayout.cellPadding.bottom
}
}
// MARK: - Calculate Rects
private extension MainTimelineAccessibilityCellLayout {
static func rectForDate(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
var r = CGRect.zero
let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: MainTimelineDefaultCellLayout.dateFont)
r.size = size
r.origin = point
return r
}
}

View File

@ -1,5 +1,5 @@
// //
// TimelineCellData.swift // MainTimelineCellData.swift
// NetNewsWire // NetNewsWire
// //
// Created by Brent Simmons on 2/6/16. // Created by Brent Simmons on 2/6/16.
@ -9,7 +9,7 @@
import UIKit import UIKit
import Articles import Articles
struct TimelineCellData { struct MainTimelineCellData {
private static let noText = NSLocalizedString("(No Text)", comment: "No Text") private static let noText = NSLocalizedString("(No Text)", comment: "No Text")

View File

@ -1,5 +1,5 @@
// //
// TimelineCellLayout.swift // MainTimelineCellLayout.swift
// NetNewsWire-iOS // NetNewsWire-iOS
// //
// Created by Maurice Parker on 4/29/19. // Created by Maurice Parker on 4/29/19.
@ -8,7 +8,7 @@
import UIKit import UIKit
protocol TimelineCellLayout { protocol MainTimelineCellLayout {
var height: CGFloat {get} var height: CGFloat {get}
var unreadIndicatorRect: CGRect {get} var unreadIndicatorRect: CGRect {get}
@ -21,11 +21,11 @@ protocol TimelineCellLayout {
} }
extension TimelineCellLayout { extension MainTimelineCellLayout {
static func rectForUnreadIndicator(_ point: CGPoint) -> CGRect { static func rectForUnreadIndicator(_ point: CGPoint) -> CGRect {
var r = CGRect.zero var r = CGRect.zero
r.size = CGSize(width: TimelineDefaultCellLayout.unreadCircleDimension, height: TimelineDefaultCellLayout.unreadCircleDimension) r.size = CGSize(width: MainTimelineDefaultCellLayout.unreadCircleDimension, height: MainTimelineDefaultCellLayout.unreadCircleDimension)
r.origin.x = point.x r.origin.x = point.x
r.origin.y = point.y + 5 r.origin.y = point.y + 5
return r return r
@ -34,9 +34,9 @@ extension TimelineCellLayout {
static func rectForStar(_ point: CGPoint) -> CGRect { static func rectForStar(_ point: CGPoint) -> CGRect {
var r = CGRect.zero var r = CGRect.zero
r.size.width = TimelineDefaultCellLayout.starDimension r.size.width = MainTimelineDefaultCellLayout.starDimension
r.size.height = TimelineDefaultCellLayout.starDimension r.size.height = MainTimelineDefaultCellLayout.starDimension
r.origin.x = floor(point.x - ((TimelineDefaultCellLayout.starDimension - TimelineDefaultCellLayout.unreadCircleDimension) / 2.0)) r.origin.x = floor(point.x - ((MainTimelineDefaultCellLayout.starDimension - MainTimelineDefaultCellLayout.unreadCircleDimension) / 2.0))
r.origin.y = point.y + 3 r.origin.y = point.y + 3
return r return r
} }
@ -49,7 +49,7 @@ extension TimelineCellLayout {
return r return r
} }
static func rectForTitle(_ cellData: TimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> (CGRect, Int) { static func rectForTitle(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> (CGRect, Int) {
var r = CGRect.zero var r = CGRect.zero
if cellData.title.isEmpty { if cellData.title.isEmpty {
@ -58,7 +58,7 @@ extension TimelineCellLayout {
r.origin = point r.origin = point
let sizeInfo = MultilineUILabelSizer.size(for: cellData.title, font: TimelineDefaultCellLayout.titleFont, numberOfLines: cellData.numberOfLines, width: Int(textAreaWidth)) let sizeInfo = MultilineUILabelSizer.size(for: cellData.title, font: MainTimelineDefaultCellLayout.titleFont, numberOfLines: cellData.numberOfLines, width: Int(textAreaWidth))
r.size.width = textAreaWidth r.size.width = textAreaWidth
r.size.height = sizeInfo.size.height r.size.height = sizeInfo.size.height
@ -70,7 +70,7 @@ extension TimelineCellLayout {
} }
static func rectForSummary(_ cellData: TimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat, _ linesUsed: Int) -> CGRect { static func rectForSummary(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat, _ linesUsed: Int) -> CGRect {
let linesLeft = cellData.numberOfLines - linesUsed let linesLeft = cellData.numberOfLines - linesUsed
@ -81,7 +81,7 @@ extension TimelineCellLayout {
r.origin = point r.origin = point
let sizeInfo = MultilineUILabelSizer.size(for: cellData.summary, font: TimelineDefaultCellLayout.summaryFont, numberOfLines: linesLeft, width: Int(textAreaWidth)) let sizeInfo = MultilineUILabelSizer.size(for: cellData.summary, font: MainTimelineDefaultCellLayout.summaryFont, numberOfLines: linesLeft, width: Int(textAreaWidth))
r.size.width = textAreaWidth r.size.width = textAreaWidth
r.size.height = sizeInfo.size.height r.size.height = sizeInfo.size.height
@ -93,13 +93,13 @@ extension TimelineCellLayout {
} }
static func rectForFeedName(_ cellData: TimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect { static func rectForFeedName(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
var r = CGRect.zero var r = CGRect.zero
r.origin = point r.origin = point
let feedName = cellData.showFeedName == .feed ? cellData.feedName : cellData.byline let feedName = cellData.showFeedName == .feed ? cellData.feedName : cellData.byline
let size = SingleLineUILabelSizer.size(for: feedName, font: TimelineDefaultCellLayout.feedNameFont) let size = SingleLineUILabelSizer.size(for: feedName, font: MainTimelineDefaultCellLayout.feedNameFont)
r.size = size r.size = size
if r.size.width > textAreaWidth { if r.size.width > textAreaWidth {

View File

@ -9,17 +9,17 @@
import UIKit import UIKit
import RSCore import RSCore
struct TimelineDefaultCellLayout: TimelineCellLayout { struct MainTimelineDefaultCellLayout: MainTimelineCellLayout {
static let cellPadding = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 20) static let cellPadding = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 20)
static let unreadCircleMarginLeft = CGFloat(integerLiteral: 0) static let unreadCircleMarginLeft = CGFloat(integerLiteral: 0)
static let unreadCircleDimension = CGFloat(integerLiteral: 12) static let unreadCircleDimension = CGFloat(integerLiteral: 12)
static let unreadCircleSize = CGSize(width: TimelineDefaultCellLayout.unreadCircleDimension, height: TimelineDefaultCellLayout.unreadCircleDimension) static let unreadCircleSize = CGSize(width: MainTimelineDefaultCellLayout.unreadCircleDimension, height: MainTimelineDefaultCellLayout.unreadCircleDimension)
static let unreadCircleMarginRight = CGFloat(integerLiteral: 8) static let unreadCircleMarginRight = CGFloat(integerLiteral: 8)
static let starDimension = CGFloat(integerLiteral: 16) static let starDimension = CGFloat(integerLiteral: 16)
static let starSize = CGSize(width: TimelineDefaultCellLayout.starDimension, height: TimelineDefaultCellLayout.starDimension) static let starSize = CGSize(width: MainTimelineDefaultCellLayout.starDimension, height: MainTimelineDefaultCellLayout.starDimension)
static let iconMarginRight = CGFloat(integerLiteral: 8) static let iconMarginRight = CGFloat(integerLiteral: 8)
static let iconCornerRadius = CGFloat(integerLiteral: 4) static let iconCornerRadius = CGFloat(integerLiteral: 4)
@ -52,55 +52,55 @@ struct TimelineDefaultCellLayout: TimelineCellLayout {
let feedNameRect: CGRect let feedNameRect: CGRect
let dateRect: CGRect let dateRect: CGRect
init(width: CGFloat, insets: UIEdgeInsets, cellData: TimelineCellData) { init(width: CGFloat, insets: UIEdgeInsets, cellData: MainTimelineCellData) {
var currentPoint = CGPoint.zero var currentPoint = CGPoint.zero
currentPoint.x = TimelineDefaultCellLayout.cellPadding.left + insets.left + TimelineDefaultCellLayout.unreadCircleMarginLeft currentPoint.x = MainTimelineDefaultCellLayout.cellPadding.left + insets.left + MainTimelineDefaultCellLayout.unreadCircleMarginLeft
currentPoint.y = TimelineDefaultCellLayout.cellPadding.top currentPoint.y = MainTimelineDefaultCellLayout.cellPadding.top
// Unread Indicator and Star // Unread Indicator and Star
self.unreadIndicatorRect = TimelineDefaultCellLayout.rectForUnreadIndicator(currentPoint) self.unreadIndicatorRect = MainTimelineDefaultCellLayout.rectForUnreadIndicator(currentPoint)
self.starRect = TimelineDefaultCellLayout.rectForStar(currentPoint) self.starRect = MainTimelineDefaultCellLayout.rectForStar(currentPoint)
// Start the point at the beginning position of the main block // Start the point at the beginning position of the main block
currentPoint.x += TimelineDefaultCellLayout.unreadCircleDimension + TimelineDefaultCellLayout.unreadCircleMarginRight currentPoint.x += MainTimelineDefaultCellLayout.unreadCircleDimension + MainTimelineDefaultCellLayout.unreadCircleMarginRight
// Icon Image // Icon Image
if cellData.showIcon { if cellData.showIcon {
self.iconImageRect = TimelineDefaultCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize) self.iconImageRect = MainTimelineDefaultCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize)
currentPoint.x = self.iconImageRect.maxX + TimelineDefaultCellLayout.iconMarginRight currentPoint.x = self.iconImageRect.maxX + MainTimelineDefaultCellLayout.iconMarginRight
} else { } else {
self.iconImageRect = CGRect.zero self.iconImageRect = CGRect.zero
} }
let textAreaWidth = width - (currentPoint.x + TimelineDefaultCellLayout.cellPadding.right + insets.right) let textAreaWidth = width - (currentPoint.x + MainTimelineDefaultCellLayout.cellPadding.right + insets.right)
// Title Text Block // Title Text Block
let (titleRect, numberOfLinesForTitle) = TimelineDefaultCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth) let (titleRect, numberOfLinesForTitle) = MainTimelineDefaultCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth)
self.titleRect = titleRect self.titleRect = titleRect
// Summary Text Block // Summary Text Block
if self.titleRect != CGRect.zero { if self.titleRect != CGRect.zero {
currentPoint.y = self.titleRect.maxY + TimelineDefaultCellLayout.titleBottomMargin currentPoint.y = self.titleRect.maxY + MainTimelineDefaultCellLayout.titleBottomMargin
} }
self.summaryRect = TimelineDefaultCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle) self.summaryRect = MainTimelineDefaultCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle)
var y = [self.titleRect, self.summaryRect].maxY() var y = [self.titleRect, self.summaryRect].maxY()
if y == 0 { if y == 0 {
y = iconImageRect.origin.y + iconImageRect.height y = iconImageRect.origin.y + iconImageRect.height
// Necessary calculation of either feed name or date since we are working with dynamic font-sizes // Necessary calculation of either feed name or date since we are working with dynamic font-sizes
let tmp = TimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) let tmp = MainTimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth)
y -= tmp.height y -= tmp.height
} }
currentPoint.y = y currentPoint.y = y
// Feed Name and Pub Date // Feed Name and Pub Date
self.dateRect = TimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) self.dateRect = MainTimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth)
let feedNameWidth = textAreaWidth - (TimelineDefaultCellLayout.feedRightMargin + self.dateRect.size.width) let feedNameWidth = textAreaWidth - (MainTimelineDefaultCellLayout.feedRightMargin + self.dateRect.size.width)
self.feedNameRect = TimelineDefaultCellLayout.rectForFeedName(cellData, currentPoint, feedNameWidth) self.feedNameRect = MainTimelineDefaultCellLayout.rectForFeedName(cellData, currentPoint, feedNameWidth)
self.height = [self.iconImageRect, self.feedNameRect].maxY() + TimelineDefaultCellLayout.cellPadding.bottom self.height = [self.iconImageRect, self.feedNameRect].maxY() + MainTimelineDefaultCellLayout.cellPadding.bottom
} }
@ -108,13 +108,13 @@ struct TimelineDefaultCellLayout: TimelineCellLayout {
// MARK: - Calculate Rects // MARK: - Calculate Rects
extension TimelineDefaultCellLayout { extension MainTimelineDefaultCellLayout {
static func rectForDate(_ cellData: TimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect { static func rectForDate(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
var r = CGRect.zero var r = CGRect.zero
let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: TimelineDefaultCellLayout.dateFont) let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: MainTimelineDefaultCellLayout.dateFont)
r.size = size r.size = size
r.origin.x = (point.x + textAreaWidth) - size.width r.origin.x = (point.x + textAreaWidth) - size.width
r.origin.y = point.y r.origin.y = point.y

View File

@ -1,5 +1,5 @@
// //
// TimelineTableViewCell.swift // MainTimelineTableViewCell.swift
// NetNewsWire // NetNewsWire
// //
// Created by Brent Simmons on 8/31/15. // Created by Brent Simmons on 8/31/15.
@ -9,13 +9,13 @@
import UIKit import UIKit
import RSCore import RSCore
class TimelineTableViewCell: VibrantTableViewCell { class MainTimelineTableViewCell: VibrantTableViewCell {
private let titleView = TimelineTableViewCell.multiLineUILabel() private let titleView = MainTimelineTableViewCell.multiLineUILabel()
private let summaryView = TimelineTableViewCell.multiLineUILabel() private let summaryView = MainTimelineTableViewCell.multiLineUILabel()
private let unreadIndicatorView = UnreadIndicatorView(frame: CGRect.zero) private let unreadIndicatorView = MainUnreadIndicatorView(frame: CGRect.zero)
private let dateView = TimelineTableViewCell.singleLineUILabel() private let dateView = MainTimelineTableViewCell.singleLineUILabel()
private let feedNameView = TimelineTableViewCell.singleLineUILabel() private let feedNameView = MainTimelineTableViewCell.singleLineUILabel()
private lazy var iconView = IconView() private lazy var iconView = IconView()
@ -26,7 +26,7 @@ class TimelineTableViewCell: VibrantTableViewCell {
private var unreadIndicatorPropertyAnimator: UIViewPropertyAnimator? private var unreadIndicatorPropertyAnimator: UIViewPropertyAnimator?
private var starViewPropertyAnimator: UIViewPropertyAnimator? private var starViewPropertyAnimator: UIViewPropertyAnimator?
var cellData: TimelineCellData! { var cellData: MainTimelineCellData! {
didSet { didSet {
updateSubviews() updateSubviews()
} }
@ -106,7 +106,7 @@ class TimelineTableViewCell: VibrantTableViewCell {
// MARK: - Private // MARK: - Private
private extension TimelineTableViewCell { private extension MainTimelineTableViewCell {
static func singleLineUILabel() -> UILabel { static func singleLineUILabel() -> UILabel {
let label = NonIntrinsicLabel() let label = NonIntrinsicLabel()
@ -153,28 +153,28 @@ private extension TimelineTableViewCell {
addSubviewAtInit(starView, hidden: true) addSubviewAtInit(starView, hidden: true)
} }
func updatedLayout(width: CGFloat) -> TimelineCellLayout { func updatedLayout(width: CGFloat) -> MainTimelineCellLayout {
if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory { if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory {
return TimelineAccessibilityCellLayout(width: width, insets: safeAreaInsets, cellData: cellData) return MainTimelineAccessibilityCellLayout(width: width, insets: safeAreaInsets, cellData: cellData)
} else { } else {
return TimelineDefaultCellLayout(width: width, insets: safeAreaInsets, cellData: cellData) return MainTimelineDefaultCellLayout(width: width, insets: safeAreaInsets, cellData: cellData)
} }
} }
func updateTitleView() { func updateTitleView() {
titleView.font = TimelineDefaultCellLayout.titleFont titleView.font = MainTimelineDefaultCellLayout.titleFont
titleView.textColor = labelColor titleView.textColor = labelColor
updateTextFieldAttributedText(titleView, cellData?.attributedTitle) updateTextFieldAttributedText(titleView, cellData?.attributedTitle)
} }
func updateSummaryView() { func updateSummaryView() {
summaryView.font = TimelineDefaultCellLayout.summaryFont summaryView.font = MainTimelineDefaultCellLayout.summaryFont
summaryView.textColor = labelColor summaryView.textColor = labelColor
updateTextFieldText(summaryView, cellData?.summary) updateTextFieldText(summaryView, cellData?.summary)
} }
func updateDateView() { func updateDateView() {
dateView.font = TimelineDefaultCellLayout.dateFont dateView.font = MainTimelineDefaultCellLayout.dateFont
dateView.textColor = secondaryLabelColor dateView.textColor = secondaryLabelColor
updateTextFieldText(dateView, cellData.dateString) updateTextFieldText(dateView, cellData.dateString)
} }
@ -204,12 +204,12 @@ private extension TimelineTableViewCell {
switch cellData.showFeedName { switch cellData.showFeedName {
case .feed: case .feed:
showView(feedNameView) showView(feedNameView)
feedNameView.font = TimelineDefaultCellLayout.feedNameFont feedNameView.font = MainTimelineDefaultCellLayout.feedNameFont
feedNameView.textColor = secondaryLabelColor feedNameView.textColor = secondaryLabelColor
updateTextFieldText(feedNameView, cellData.feedName) updateTextFieldText(feedNameView, cellData.feedName)
case .byline: case .byline:
showView(feedNameView) showView(feedNameView)
feedNameView.font = TimelineDefaultCellLayout.feedNameFont feedNameView.font = MainTimelineDefaultCellLayout.feedNameFont
feedNameView.textColor = secondaryLabelColor feedNameView.textColor = secondaryLabelColor
updateTextFieldText(feedNameView, cellData.byline) updateTextFieldText(feedNameView, cellData.byline)
case .none: case .none:

View File

@ -1,5 +1,5 @@
// //
// UnreadIndicatorView.swift // MainUnreadIndicatorView.swift
// NetNewsWire // NetNewsWire
// //
// Created by Brent Simmons on 2/16/16. // Created by Brent Simmons on 2/16/16.
@ -8,7 +8,7 @@
import UIKit import UIKit
class UnreadIndicatorView: UIView { class MainUnreadIndicatorView: UIView {
override func layoutSubviews() { override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()

View File

@ -1,90 +0,0 @@
//
// TimelineAccessibilityCellLayout.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 4/29/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
import RSCore
struct TimelineAccessibilityCellLayout: TimelineCellLayout {
let height: CGFloat
let unreadIndicatorRect: CGRect
let starRect: CGRect
let iconImageRect: CGRect
let titleRect: CGRect
let summaryRect: CGRect
let feedNameRect: CGRect
let dateRect: CGRect
init(width: CGFloat, insets: UIEdgeInsets, cellData: TimelineCellData) {
var currentPoint = CGPoint.zero
currentPoint.x = TimelineDefaultCellLayout.cellPadding.left + insets.left + TimelineDefaultCellLayout.unreadCircleMarginLeft
currentPoint.y = TimelineDefaultCellLayout.cellPadding.top
// Unread Indicator and Star
self.unreadIndicatorRect = TimelineAccessibilityCellLayout.rectForUnreadIndicator(currentPoint)
self.starRect = TimelineAccessibilityCellLayout.rectForStar(currentPoint)
// Start the point at the beginning position of the main block
currentPoint.x += TimelineDefaultCellLayout.unreadCircleDimension + TimelineDefaultCellLayout.unreadCircleMarginRight
// Icon Image
if cellData.showIcon {
self.iconImageRect = TimelineAccessibilityCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize)
currentPoint.y = self.iconImageRect.maxY
} else {
self.iconImageRect = CGRect.zero
}
let textAreaWidth = width - (currentPoint.x + TimelineDefaultCellLayout.cellPadding.right + insets.right)
// Title Text Block
let (titleRect, numberOfLinesForTitle) = TimelineAccessibilityCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth)
self.titleRect = titleRect
// Summary Text Block
if self.titleRect != CGRect.zero {
currentPoint.y = self.titleRect.maxY + TimelineDefaultCellLayout.titleBottomMargin
}
self.summaryRect = TimelineAccessibilityCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle)
currentPoint.y = [self.titleRect, self.summaryRect].maxY()
if cellData.showFeedName != .none {
self.feedNameRect = TimelineAccessibilityCellLayout.rectForFeedName(cellData, currentPoint, textAreaWidth)
currentPoint.y = self.feedNameRect.maxY
} else {
self.feedNameRect = CGRect.zero
}
// Feed Name and Pub Date
self.dateRect = TimelineAccessibilityCellLayout.rectForDate(cellData, currentPoint, textAreaWidth)
self.height = self.dateRect.maxY + TimelineDefaultCellLayout.cellPadding.bottom
}
}
// MARK: - Calculate Rects
private extension TimelineAccessibilityCellLayout {
static func rectForDate(_ cellData: TimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
var r = CGRect.zero
let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: TimelineDefaultCellLayout.dateFont)
r.size = size
r.origin = point
return r
}
}

View File

@ -436,7 +436,7 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
for article in visibleUpdatedArticles { for article in visibleUpdatedArticles {
if let indexPath = dataSource.indexPath(for: article) { if let indexPath = dataSource.indexPath(for: article) {
if let cell = tableView.cellForRow(at: indexPath) as? TimelineTableViewCell { if let cell = tableView.cellForRow(at: indexPath) as? MainTimelineTableViewCell {
configure(cell, article: article) configure(cell, article: article)
} }
} }
@ -457,7 +457,7 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
guard let article = dataSource.itemIdentifier(for: indexPath) else { guard let article = dataSource.itemIdentifier(for: indexPath) else {
continue continue
} }
if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? TimelineTableViewCell, let image = iconImageFor(article) { if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? MainTimelineTableViewCell, let image = iconImageFor(article) {
cell.setIconImage(image) cell.setIconImage(image)
} }
} }
@ -474,7 +474,7 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
continue continue
} }
for author in authors { for author in authors {
if author.avatarURL == avatarURL, let cell = tableView.cellForRow(at: indexPath) as? TimelineTableViewCell, let image = iconImageFor(article) { if author.avatarURL == avatarURL, let cell = tableView.cellForRow(at: indexPath) as? MainTimelineTableViewCell, let image = iconImageFor(article) {
cell.setIconImage(image) cell.setIconImage(image)
} }
} }
@ -548,13 +548,13 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date()) let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: Constants.prototypeText, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status) let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: Constants.prototypeText, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
let prototypeCellData = TimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false, featuredImage: nil, numberOfLines: numberOfTextLines, iconSize: iconSize) let prototypeCellData = MainTimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false, featuredImage: nil, numberOfLines: numberOfTextLines, iconSize: iconSize)
if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory { if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory {
let layout = TimelineAccessibilityCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) let layout = MainTimelineAccessibilityCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
tableView.estimatedRowHeight = layout.height tableView.estimatedRowHeight = layout.height
} else { } else {
let layout = TimelineDefaultCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) let layout = MainTimelineDefaultCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
tableView.estimatedRowHeight = layout.height tableView.estimatedRowHeight = layout.height
} }
@ -713,7 +713,7 @@ private extension TimelineViewController {
func makeDataSource() -> UITableViewDiffableDataSource<Int, Article> { func makeDataSource() -> UITableViewDiffableDataSource<Int, Article> {
let dataSource: UITableViewDiffableDataSource<Int, Article> = let dataSource: UITableViewDiffableDataSource<Int, Article> =
TimelineDataSource(tableView: tableView, cellProvider: { [weak self] tableView, indexPath, article in TimelineDataSource(tableView: tableView, cellProvider: { [weak self] tableView, indexPath, article in
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TimelineTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MainTimelineTableViewCell
self?.configure(cell, article: article) self?.configure(cell, article: article)
return cell return cell
}) })
@ -721,14 +721,14 @@ private extension TimelineViewController {
return dataSource return dataSource
} }
func configure(_ cell: TimelineTableViewCell, article: Article) { func configure(_ cell: MainTimelineTableViewCell, article: Article) {
let iconImage = iconImageFor(article) let iconImage = iconImageFor(article)
let featuredImage = featuredImageFor(article) let featuredImage = featuredImageFor(article)
let showFeedNames = coordinator.showFeedNames let showFeedNames = coordinator.showFeedNames
let showIcon = coordinator.showIcons && iconImage != nil let showIcon = coordinator.showIcons && iconImage != nil
cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, featuredImage: featuredImage, numberOfLines: numberOfTextLines, iconSize: iconSize) cell.cellData = MainTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, featuredImage: featuredImage, numberOfLines: numberOfTextLines, iconSize: iconSize)
} }