diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard
index 949061a9d..026dd3416 100644
--- a/iOS/Base.lproj/Main.storyboard
+++ b/iOS/Base.lproj/Main.storyboard
@@ -128,316 +128,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/iOS/MainTimeline/Cell/MainTimelineCell.swift b/iOS/MainTimeline/Cell/MainTimelineCell.swift
new file mode 100644
index 000000000..78134e4ee
--- /dev/null
+++ b/iOS/MainTimeline/Cell/MainTimelineCell.swift
@@ -0,0 +1,235 @@
+//
+// MainTimelineCell.swift
+// NetNewsWire-iOS
+//
+// Created by Brent Simmons on 6/22/26.
+//
+
+import UIKit
+import RSCore
+import Images
+
+/// Manual-layout timeline cell modeled on the Mac timeline
+/// and the pre-7.0 iOS table view cell.
+final class MainTimelineCell: UICollectionViewCell {
+
+ static let reuseIdentifier = "MainTimelineCell"
+
+ var isPreview = false
+
+ private let titleView = MainTimelineCell.multiLineLabel()
+ private let summaryView = MainTimelineCell.multiLineLabel()
+ private let dateView = MainTimelineCell.singleLineLabel()
+ private let feedNameView = MainTimelineCell.singleLineLabel()
+ private lazy var iconView = IconView()
+ private lazy var indicatorView = IconView()
+ private let topSeparator = UIView()
+
+ var cellData: MainTimelineCellData! {
+ didSet {
+ updateSubviews()
+ }
+ }
+
+ override init(frame: CGRect) {
+ super.init(frame: frame)
+ commonInit()
+ }
+
+ required init?(coder: NSCoder) {
+ super.init(coder: coder)
+ commonInit()
+ }
+
+ override func prepareForReuse() {
+ super.prepareForReuse()
+ indicatorView.isHidden = true
+ }
+
+ override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
+ let layout = updatedLayout(width: layoutAttributes.frame.width)
+ layoutAttributes.frame.size.height = layout.height
+ return layoutAttributes
+ }
+
+ override func layoutSubviews() {
+ super.layoutSubviews()
+
+ let layout = updatedLayout(width: contentView.bounds.width)
+
+ setFrame(for: titleView, rect: layout.titleRect)
+ setFrame(for: summaryView, rect: layout.summaryRect)
+ feedNameView.setFrameIfNotEqual(layout.feedNameRect)
+ dateView.setFrameIfNotEqual(layout.dateRect)
+ iconView.setFrameIfNotEqual(layout.iconImageRect)
+ indicatorView.setFrameIfNotEqual(cellData.starred ? layout.starRect : layout.unreadIndicatorRect)
+ topSeparator.frame = CGRect(x: layout.separatorRect.minX, y: 0, width: layout.separatorRect.width, height: 1.0 / traitCollection.displayScale)
+ }
+
+ override func updateConfiguration(using state: UICellConfigurationState) {
+ super.updateConfiguration(using: state)
+
+ var backgroundConfig: UIBackgroundConfiguration
+ if #available(iOS 18, *) {
+ backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
+ } else {
+ backgroundConfig = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
+ }
+ if #available(iOS 26, *) {
+ backgroundConfig.cornerRadius = 20
+ backgroundConfig.edgesAddingLayoutMarginsToBackgroundInsets = [.leading, .trailing]
+ if UIDevice.current.userInterfaceIdiom == .pad {
+ backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -8, bottom: 0, trailing: -8)
+ } else if isPreview {
+ backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -16, bottom: 0, trailing: -16)
+ } else {
+ backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -12, bottom: 0, trailing: -12)
+ }
+ } else {
+ backgroundConfig.cornerRadius = 0
+ }
+
+ if state.isSelected {
+ backgroundConfig.backgroundColor = Assets.Colors.primaryAccent
+ } else if state.isSwiped {
+ backgroundConfig.backgroundColor = .secondarySystemFill
+ } else {
+ backgroundConfig.backgroundColor = .clear
+ }
+
+ let isActive = state.isSwiped || state.isSelected
+
+ if isPreview {
+ backgroundConfig.backgroundColor = traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
+ }
+ backgroundConfiguration = backgroundConfig
+
+ topSeparator.alpha = (isActive || isPreview) ? 0.0 : 1.0
+
+ updateColors(active: isActive)
+ updateIndicatorView(active: isActive)
+ }
+
+ func setIconImage(_ image: IconImage) {
+ iconView.iconImage = image
+ }
+}
+
+// MARK: - Private
+
+private extension MainTimelineCell {
+
+ static func singleLineLabel() -> UILabel {
+ let label = NonIntrinsicLabel()
+ label.lineBreakMode = .byTruncatingTail
+ label.allowsDefaultTighteningForTruncation = false
+ label.adjustsFontForContentSizeCategory = true
+ return label
+ }
+
+ static func multiLineLabel() -> UILabel {
+ let label = NonIntrinsicLabel()
+ label.numberOfLines = 0
+ label.lineBreakMode = .byTruncatingTail
+ label.allowsDefaultTighteningForTruncation = false
+ label.adjustsFontForContentSizeCategory = true
+ return label
+ }
+
+ func commonInit() {
+ isAccessibilityElement = true
+ topSeparator.backgroundColor = .separator.withAlphaComponent(0.1)
+ for view in [titleView, summaryView, dateView, feedNameView, iconView, indicatorView, topSeparator] {
+ contentView.addSubview(view)
+ view.isAccessibilityElement = false
+ }
+ indicatorView.isHidden = true
+ }
+
+ func updatedLayout(width: CGFloat) -> MainTimelineCellLayout {
+ guard cellData != nil else {
+ return MainTimelineDefaultCellLayout(width: width, insets: .zero, cellData: MainTimelineCellData())
+ }
+ if traitCollection.preferredContentSizeCategory.isAccessibilityCategory {
+ return MainTimelineAccessibilityCellLayout(width: width, insets: .zero, cellData: cellData)
+ }
+ return MainTimelineDefaultCellLayout(width: width, insets: .zero, cellData: cellData)
+ }
+
+ func setFrame(for label: UILabel, rect: CGRect) {
+ if Int(floor(rect.height)) == 0 || Int(floor(rect.width)) == 0 {
+ label.isHidden = true
+ } else {
+ label.isHidden = false
+ label.setFrameIfNotEqual(rect)
+ }
+ }
+
+ func updateSubviews() {
+ titleView.font = MainTimelineDefaultCellLayout.titleFont
+ titleView.attributedText = cellData.attributedTitle.applyingBaseFont(MainTimelineDefaultCellLayout.titleFont)
+
+ summaryView.font = MainTimelineDefaultCellLayout.summaryFont
+ summaryView.text = cellData.summary
+
+ dateView.font = MainTimelineDefaultCellLayout.dateFont
+ dateView.text = cellData.dateString
+
+ switch cellData.showFeedName {
+ case .feed:
+ feedNameView.font = MainTimelineDefaultCellLayout.feedNameFont
+ feedNameView.text = cellData.feedName
+ feedNameView.isHidden = false
+ case .byline:
+ feedNameView.font = MainTimelineDefaultCellLayout.feedNameFont
+ feedNameView.text = cellData.byline
+ feedNameView.isHidden = false
+ case .none:
+ feedNameView.isHidden = true
+ }
+
+ if cellData.showIcon, let iconImage = cellData.iconImage {
+ iconView.iconImage = iconImage
+ iconView.isHidden = false
+ } else {
+ iconView.iconImage = nil
+ iconView.isHidden = true
+ }
+
+ updateColors(active: configurationState.isSelected)
+ updateIndicatorView(active: configurationState.isSelected)
+ updateAccessibilityLabel()
+ setNeedsLayout()
+ }
+
+ func updateColors(active: Bool) {
+ titleView.textColor = active ? .white : .label
+ summaryView.textColor = active ? .white : (cellData.title.isEmpty ? .label : .secondaryLabel)
+ dateView.textColor = active ? .white : .secondaryLabel
+ feedNameView.textColor = active ? .white : .secondaryLabel
+ }
+
+ func updateIndicatorView(active: Bool) {
+ guard cellData != nil else {
+ indicatorView.isHidden = true
+ return
+ }
+ if cellData.starred {
+ indicatorView.iconImage = Assets.Images.starredFeed
+ indicatorView.tintColor = active ? .white : Assets.Colors.star
+ indicatorView.isHidden = false
+ } else if !cellData.read {
+ indicatorView.iconImage = Assets.Images.unreadCellIndicator
+ indicatorView.tintColor = active ? .white : Assets.Colors.secondaryAccent
+ indicatorView.isHidden = false
+ } else {
+ indicatorView.isHidden = true
+ }
+ }
+
+ func updateAccessibilityLabel() {
+ let starredStatus = cellData.starred ? "\(NSLocalizedString("Starred", comment: "Starred")), " : ""
+ let unreadStatus = cellData.read ? "" : "\(NSLocalizedString("Unread", comment: "Unread")), "
+ accessibilityLabel = starredStatus + unreadStatus + "\(cellData.feedName), \(cellData.title), \(cellData.summary), \(cellData.dateString)"
+ }
+}
diff --git a/iOS/MainTimeline/Cells/MainTimelineCellData.swift b/iOS/MainTimeline/Cell/MainTimelineCellData.swift
similarity index 100%
rename from iOS/MainTimeline/Cells/MainTimelineCellData.swift
rename to iOS/MainTimeline/Cell/MainTimelineCellData.swift
diff --git a/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift b/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift
new file mode 100644
index 000000000..0874ea583
--- /dev/null
+++ b/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift
@@ -0,0 +1,251 @@
+//
+// MainTimelineCellLayout.swift
+// NetNewsWire-iOS
+//
+// Created by Maurice Parker on 4/29/19.
+// Copyright © 2019 Ranchero Software. All rights reserved.
+//
+
+import UIKit
+import RSCore
+import Images
+
+@MainActor protocol MainTimelineCellLayout {
+ var height: CGFloat { get }
+ var unreadIndicatorRect: CGRect { get }
+ var starRect: CGRect { get }
+ var iconImageRect: CGRect { get }
+ var titleRect: CGRect { get }
+ var summaryRect: CGRect { get }
+ var feedNameRect: CGRect { get }
+ var dateRect: CGRect { get }
+ var separatorRect: CGRect { get }
+}
+
+extension MainTimelineCellLayout {
+
+ static func rectForUnreadIndicator(_ point: CGPoint) -> CGRect {
+ var r = CGRect.zero
+ r.size = CGSize(width: MainTimelineDefaultCellLayout.unreadCircleDimension, height: MainTimelineDefaultCellLayout.unreadCircleDimension)
+ r.origin.x = point.x
+ r.origin.y = point.y + 5
+ return r
+ }
+
+ static func rectForStar(_ point: CGPoint) -> CGRect {
+ var r = CGRect.zero
+ r.size.width = MainTimelineDefaultCellLayout.starDimension
+ r.size.height = MainTimelineDefaultCellLayout.starDimension
+ r.origin.x = floor(point.x - ((MainTimelineDefaultCellLayout.starDimension - MainTimelineDefaultCellLayout.unreadCircleDimension) / 2.0))
+ r.origin.y = point.y + 3
+ return r
+ }
+
+ static func rectForIconView(_ point: CGPoint, iconSize: IconSize) -> CGRect {
+ var r = CGRect.zero
+ r.size = iconSize.size
+ r.origin.x = point.x
+ r.origin.y = point.y + 4
+ return r
+ }
+
+ static func rectForTitle(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> (CGRect, Int) {
+ var r = CGRect.zero
+ if cellData.title.isEmpty {
+ return (r, 0)
+ }
+ r.origin = point
+ let sizeInfo = MultilineUILabelSizer.size(for: cellData.title, font: MainTimelineDefaultCellLayout.titleFont, numberOfLines: cellData.numberOfLines, width: Int(textAreaWidth))
+ r.size.width = textAreaWidth
+ r.size.height = sizeInfo.size.height
+ if sizeInfo.numberOfLinesUsed < 1 {
+ r.size.height = 0
+ }
+ return (r, sizeInfo.numberOfLinesUsed)
+ }
+
+ static func rectForSummary(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat, _ linesUsed: Int) -> CGRect {
+ let linesLeft = cellData.numberOfLines - linesUsed
+ var r = CGRect.zero
+ if cellData.summary.isEmpty || linesLeft < 1 {
+ return r
+ }
+ r.origin = point
+ let sizeInfo = MultilineUILabelSizer.size(for: cellData.summary, font: MainTimelineDefaultCellLayout.summaryFont, numberOfLines: linesLeft, width: Int(textAreaWidth))
+ r.size.width = textAreaWidth
+ r.size.height = sizeInfo.size.height
+ if sizeInfo.numberOfLinesUsed < 1 {
+ r.size.height = 0
+ }
+ return r
+ }
+
+ static func rectForFeedName(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
+ var r = CGRect.zero
+ r.origin = point
+ let feedName = cellData.showFeedName == .feed ? cellData.feedName : cellData.byline
+ let size = SingleLineUILabelSizer.size(for: feedName, font: MainTimelineDefaultCellLayout.feedNameFont)
+ r.size = size
+ if r.size.width > textAreaWidth {
+ r.size.width = textAreaWidth
+ }
+ return r
+ }
+}
+
+// MARK: - Default
+
+struct MainTimelineDefaultCellLayout: MainTimelineCellLayout {
+
+ static let cellPadding = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 20)
+
+ static let unreadCircleMarginLeft = CGFloat(0)
+ static let unreadCircleDimension = CGFloat(12)
+ static let unreadCircleMarginRight = CGFloat(8)
+
+ static let starDimension = CGFloat(16)
+
+ static let iconMarginRight = CGFloat(8)
+ static let iconCornerRadius = CGFloat(4)
+
+ static var titleFont: UIFont { UIFont.preferredFont(forTextStyle: .headline) }
+ static let titleBottomMargin = CGFloat(1)
+
+ static var feedNameFont: UIFont { UIFont.preferredFont(forTextStyle: .footnote) }
+ static let feedRightMargin = CGFloat(8)
+
+ static var dateFont: UIFont { UIFont.preferredFont(forTextStyle: .footnote) }
+ static let dateMarginBottom = CGFloat(1)
+
+ static var summaryFont: UIFont { UIFont.preferredFont(forTextStyle: .body) }
+
+ let height: CGFloat
+ let unreadIndicatorRect: CGRect
+ let starRect: CGRect
+ let iconImageRect: CGRect
+ let titleRect: CGRect
+ let summaryRect: CGRect
+ let feedNameRect: CGRect
+ let dateRect: CGRect
+ let separatorRect: CGRect
+
+ init(width: CGFloat, insets: UIEdgeInsets, cellData: MainTimelineCellData) {
+
+ var currentPoint = CGPoint.zero
+ currentPoint.x = Self.cellPadding.left + insets.left + Self.unreadCircleMarginLeft
+ currentPoint.y = Self.cellPadding.top
+
+ self.unreadIndicatorRect = Self.rectForUnreadIndicator(currentPoint)
+ self.starRect = Self.rectForStar(currentPoint)
+
+ currentPoint.x += Self.unreadCircleDimension + Self.unreadCircleMarginRight
+
+ if cellData.showIcon {
+ self.iconImageRect = Self.rectForIconView(currentPoint, iconSize: cellData.iconSize)
+ currentPoint.x = self.iconImageRect.maxX + Self.iconMarginRight
+ } else {
+ self.iconImageRect = CGRect.zero
+ }
+
+ let textAreaWidth = width - (currentPoint.x + Self.cellPadding.right + insets.right)
+ self.separatorRect = CGRect(x: currentPoint.x, y: 0, width: textAreaWidth, height: 0)
+
+ let (titleRect, numberOfLinesForTitle) = Self.rectForTitle(cellData, currentPoint, textAreaWidth)
+ self.titleRect = titleRect
+
+ if self.titleRect != CGRect.zero {
+ currentPoint.y = self.titleRect.maxY + Self.titleBottomMargin
+ }
+ self.summaryRect = Self.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle)
+
+ var y = [self.titleRect, self.summaryRect].maxY()
+ if y == 0 {
+ y = iconImageRect.origin.y + iconImageRect.height
+ let tmp = Self.rectForDate(cellData, currentPoint, textAreaWidth)
+ y -= tmp.height
+ }
+ currentPoint.y = y
+
+ self.dateRect = Self.rectForDate(cellData, currentPoint, textAreaWidth)
+
+ let feedNameWidth = textAreaWidth - (Self.feedRightMargin + self.dateRect.size.width)
+ self.feedNameRect = Self.rectForFeedName(cellData, currentPoint, feedNameWidth)
+
+ self.height = [self.iconImageRect, self.feedNameRect].maxY() + Self.cellPadding.bottom
+ }
+
+ static func rectForDate(_ cellData: MainTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect {
+ var r = CGRect.zero
+ let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: Self.dateFont)
+ r.size = size
+ r.origin.x = (point.x + textAreaWidth) - size.width
+ r.origin.y = point.y
+ return r
+ }
+}
+
+// MARK: - Accessibility
+
+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
+ let separatorRect: 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
+
+ self.unreadIndicatorRect = Self.rectForUnreadIndicator(currentPoint)
+ self.starRect = Self.rectForStar(currentPoint)
+
+ currentPoint.x += MainTimelineDefaultCellLayout.unreadCircleDimension + MainTimelineDefaultCellLayout.unreadCircleMarginRight
+
+ if cellData.showIcon {
+ self.iconImageRect = Self.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)
+ self.separatorRect = CGRect(x: currentPoint.x, y: 0, width: textAreaWidth, height: 0)
+
+ let (titleRect, numberOfLinesForTitle) = Self.rectForTitle(cellData, currentPoint, textAreaWidth)
+ self.titleRect = titleRect
+
+ if self.titleRect != CGRect.zero {
+ currentPoint.y = self.titleRect.maxY + MainTimelineDefaultCellLayout.titleBottomMargin
+ }
+ self.summaryRect = Self.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle)
+
+ currentPoint.y = [self.titleRect, self.summaryRect].maxY()
+
+ if cellData.showFeedName != .none {
+ self.feedNameRect = Self.rectForFeedName(cellData, currentPoint, textAreaWidth)
+ currentPoint.y = self.feedNameRect.maxY
+ } else {
+ self.feedNameRect = CGRect.zero
+ }
+
+ self.dateRect = Self.rectForDate(cellData, currentPoint, textAreaWidth)
+
+ self.height = self.dateRect.maxY + MainTimelineDefaultCellLayout.cellPadding.bottom
+ }
+
+ 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
+ }
+}
diff --git a/iOS/MainTimeline/Cell/MultilineUILabelSizer.swift b/iOS/MainTimeline/Cell/MultilineUILabelSizer.swift
new file mode 100644
index 000000000..9e83f9835
--- /dev/null
+++ b/iOS/MainTimeline/Cell/MultilineUILabelSizer.swift
@@ -0,0 +1,150 @@
+//
+// MultilineUILabelSizer.swift
+// NetNewsWire-iOS
+//
+// Created by Brent Simmons on 2/19/18.
+// Copyright © 2018 Ranchero Software. All rights reserved.
+//
+
+import UIKit
+
+// Get the height of a UILabel given a string, font, and width.
+// Uses a cache. Avoids actually measuring text as much as possible.
+// Main thread only.
+
+typealias WidthHeightCache = [Int: Int] // width: height
+
+private struct UILabelSizerSpecifier: Hashable {
+ let numberOfLines: Int
+ let font: UIFont
+}
+
+struct TextFieldSizeInfo {
+ let size: CGSize // Integral size (ceiled)
+ let numberOfLinesUsed: Int // A two-line label may only use one line, for instance. This would equal 1, then.
+}
+
+@MainActor final class MultilineUILabelSizer {
+
+ private let numberOfLines: Int
+ private let font: UIFont
+ private let singleLineHeightEstimate: Int
+ private let doubleLineHeightEstimate: Int
+ private var cache = [String: WidthHeightCache]() // Each string has a cache.
+ private static var sizers = [UILabelSizerSpecifier: MultilineUILabelSizer]()
+
+ private init(numberOfLines: Int, font: UIFont) {
+ self.numberOfLines = numberOfLines
+ self.font = font
+ self.singleLineHeightEstimate = MultilineUILabelSizer.calculateHeight("AqLjJ0/y", 200, font)
+ self.doubleLineHeightEstimate = MultilineUILabelSizer.calculateHeight("AqLjJ0/y\nAqLjJ0/y", 200, font)
+ }
+
+ static func size(for string: String, font: UIFont, numberOfLines: Int, width: Int) -> TextFieldSizeInfo {
+ sizer(numberOfLines: numberOfLines, font: font).sizeInfo(for: string, width: width)
+ }
+
+ static func emptyCache() {
+ sizers = [UILabelSizerSpecifier: MultilineUILabelSizer]()
+ }
+}
+
+// MARK: - Private
+
+private extension MultilineUILabelSizer {
+
+ static func sizer(numberOfLines: Int, font: UIFont) -> MultilineUILabelSizer {
+ let specifier = UILabelSizerSpecifier(numberOfLines: numberOfLines, font: font)
+ if let cachedSizer = sizers[specifier] {
+ return cachedSizer
+ }
+ let newSizer = MultilineUILabelSizer(numberOfLines: numberOfLines, font: font)
+ sizers[specifier] = newSizer
+ return newSizer
+ }
+
+ func sizeInfo(for string: String, width: Int) -> TextFieldSizeInfo {
+ let labelHeight = height(for: string, width: width)
+ let numberOfLinesUsed = numberOfLines(for: labelHeight)
+ let size = CGSize(width: width, height: labelHeight)
+ return TextFieldSizeInfo(size: size, numberOfLinesUsed: numberOfLinesUsed)
+ }
+
+ func height(for string: String, width: Int) -> Int {
+ if cache[string] == nil {
+ cache[string] = WidthHeightCache()
+ }
+ if let height = cache[string]![width] {
+ return height
+ }
+ if let height = heightConsideringNeighbors(cache[string]!, width) {
+ return height
+ }
+
+ var height = MultilineUILabelSizer.calculateHeight(string, width, font)
+ if numberOfLines != 0 {
+ let maxHeight = singleLineHeightEstimate * numberOfLines
+ if height > maxHeight {
+ height = maxHeight
+ }
+ }
+
+ cache[string]![width] = height
+ return height
+ }
+
+ static func calculateHeight(_ string: String, _ width: Int, _ font: UIFont) -> Int {
+ let height = string.height(withConstrainedWidth: CGFloat(width), font: font)
+ return Int(ceil(height))
+ }
+
+ func numberOfLines(for height: Int) -> Int {
+ let averageHeight = CGFloat(doubleLineHeightEstimate) / 2.0
+ return Int(round(CGFloat(height) / averageHeight))
+ }
+
+ func heightIsProbablySingleLineHeight(_ height: Int) -> Bool {
+ heightIsProbablyEqualToEstimate(height, singleLineHeightEstimate)
+ }
+
+ func heightIsProbablyDoubleLineHeight(_ height: Int) -> Bool {
+ heightIsProbablyEqualToEstimate(height, doubleLineHeightEstimate)
+ }
+
+ func heightIsProbablyEqualToEstimate(_ height: Int, _ estimate: Int) -> Bool {
+ let slop = 4
+ let minimum = estimate - slop
+ let maximum = estimate + slop
+ return height >= minimum && height <= maximum
+ }
+
+ func heightConsideringNeighbors(_ heightCache: WidthHeightCache, _ width: Int) -> Int? {
+ // Given width, if the height at width - something and width + something is equal,
+ // then that height must be correct for the given width.
+
+ var smallNeighbor = (width: 0, height: 0)
+ var largeNeighbor = (width: 0, height: 0)
+
+ for (oneWidth, oneHeight) in heightCache {
+
+ if oneWidth < width && heightIsProbablySingleLineHeight(oneHeight) {
+ return oneHeight
+ }
+ if numberOfLines == 2 && oneWidth > width && heightIsProbablyDoubleLineHeight(oneHeight) {
+ return oneHeight
+ }
+
+ if oneWidth < width && (oneWidth > smallNeighbor.width || smallNeighbor.width == 0) {
+ smallNeighbor = (oneWidth, oneHeight)
+ } else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
+ largeNeighbor = (oneWidth, oneHeight)
+ }
+
+ if smallNeighbor.width != 0 && smallNeighbor.height == largeNeighbor.height {
+ return smallNeighbor.height
+ }
+ }
+
+ return nil
+ }
+}
diff --git a/iOS/MainTimeline/Cell/SingleLineUILabelSizer.swift b/iOS/MainTimeline/Cell/SingleLineUILabelSizer.swift
new file mode 100644
index 000000000..5d63eca4f
--- /dev/null
+++ b/iOS/MainTimeline/Cell/SingleLineUILabelSizer.swift
@@ -0,0 +1,51 @@
+//
+// SingleLineUILabelSizer.swift
+// NetNewsWire-iOS
+//
+// Created by Brent Simmons on 2/19/18.
+// Copyright © 2018 Ranchero Software. All rights reserved.
+//
+
+import UIKit
+
+// Get the size of a UILabel configured with a specific font. Uses a cache. Main thread only.
+
+@MainActor final class SingleLineUILabelSizer {
+
+ let font: UIFont
+ private var cache = [String: CGSize]()
+
+ init(font: UIFont) {
+ self.font = font
+ }
+
+ func size(for text: String) -> CGSize {
+ if let cachedSize = cache[text] {
+ return cachedSize
+ }
+ let height = text.height(withConstrainedWidth: .greatestFiniteMagnitude, font: font)
+ let width = text.width(withConstrainedHeight: .greatestFiniteMagnitude, font: font)
+ let calculatedSize = CGSize(width: ceil(width), height: ceil(height))
+ cache[text] = calculatedSize
+ return calculatedSize
+ }
+
+ private static var sizers = [UIFont: SingleLineUILabelSizer]()
+
+ static func sizer(for font: UIFont) -> SingleLineUILabelSizer {
+ if let cachedSizer = sizers[font] {
+ return cachedSizer
+ }
+ let newSizer = SingleLineUILabelSizer(font: font)
+ sizers[font] = newSizer
+ return newSizer
+ }
+
+ static func size(for text: String, font: UIFont) -> CGSize {
+ sizer(for: font).size(for: text)
+ }
+
+ static func emptyCache() {
+ sizers = [UIFont: SingleLineUILabelSizer]()
+ }
+}
diff --git a/iOS/MainTimeline/Cell/StringSize+Extensions.swift b/iOS/MainTimeline/Cell/StringSize+Extensions.swift
new file mode 100644
index 000000000..a6cbfe474
--- /dev/null
+++ b/iOS/MainTimeline/Cell/StringSize+Extensions.swift
@@ -0,0 +1,23 @@
+//
+// StringSize+Extensions.swift
+// NetNewsWire-iOS
+//
+// Created by Brent Simmons on 6/22/26.
+//
+
+import UIKit
+
+extension String {
+
+ func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat {
+ let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
+ let boundingBox = self.boundingRect(with: constraintRect, options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [.font: font], context: nil)
+ return ceil(boundingBox.height)
+ }
+
+ func width(withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat {
+ let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
+ let boundingBox = self.boundingRect(with: constraintRect, options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [.font: font], context: nil)
+ return ceil(boundingBox.width)
+ }
+}
diff --git a/iOS/MainTimeline/Cells/MainTimelineCollectionViewCell.swift b/iOS/MainTimeline/Cells/MainTimelineCollectionViewCell.swift
deleted file mode 100644
index b59e11e0a..000000000
--- a/iOS/MainTimeline/Cells/MainTimelineCollectionViewCell.swift
+++ /dev/null
@@ -1,466 +0,0 @@
-//
-// MainTimelineCollectionViewCell.swift
-// NetNewsWire-iOS
-//
-// Created by Stuart Breckenridge on 24/01/2026.
-// Copyright © 2026 Ranchero Software. All rights reserved.
-//
-
-import UIKit
-import Account
-import Articles
-import Images
-
-@MainActor private final class ArticleContentCache: NSObject {
-
- struct Key: Hashable {
- let accountID: String
- let articleID: String
- }
-
- struct Entry {
- let width: CGFloat
- let numberOfLines: Int
- let contentSizeCategory: UIContentSizeCategory
- let attributedText: NSAttributedString
- let lineBreakMode: NSLineBreakMode
- let rangeOfTitle: NSRange?
- let rangeOfSummary: NSRange?
- }
-
- private var storage = [Key: Entry]()
-
- override init() {
- super.init()
- NotificationCenter.default.addObserver(self, selector: #selector(articlesDidDownload(_:)), name: .AccountDidDownloadArticles, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(handleLowMemory(_:)), name: .lowMemory, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(handleAppDidGoToBackground(_:)), name: .appDidGoToBackground, object: nil)
- }
-
- func entry(for key: Key) -> Entry? {
- storage[key]
- }
-
- func setEntry(_ entry: Entry, for key: Key) {
- storage[key] = entry
- }
-
- @objc private func articlesDidDownload(_ note: Notification) {
- guard let updatedArticles = note.userInfo?[Account.UserInfoKey.updatedArticles] as? Set else {
- return
- }
- for article in updatedArticles {
- storage.removeValue(forKey: Key(accountID: article.accountID, articleID: article.articleID))
- }
- }
-
- @objc private func handleLowMemory(_ note: Notification) {
- storage.removeAll()
- }
-
- @objc private func handleAppDidGoToBackground(_ note: Notification) {
- storage.removeAll()
- }
-}
-
-final class MainTimelineCollectionViewCell: UICollectionViewCell {
-
- @IBOutlet var articleContent: UILabel!
- @IBOutlet var articleByLine: UILabel!
- @IBOutlet var feedIcon: IconView?
- @IBOutlet var indicatorView: IconView!
- @IBOutlet var articleDate: UILabel!
- @IBOutlet var metaDataStackView: UIStackView!
- @IBOutlet var topSeparator: UIView!
-
- var cellData: MainTimelineCellData! {
- didSet {
- configure(cellData)
- }
- }
-
- var isPreview: Bool = false
-
- // Cached Values
- private var rangeOfTitle: NSRange?
- private var rangeOfSummary: NSRange?
- private var title: String = ""
- private var summary: String = ""
- private var appliedIconSize: CGSize?
-
- private static let indicatorAnimationDuration = 0.25
-
- // Paragraph Styles
- private static let baseWrappingParagraphStyle: NSParagraphStyle = {
- let style = NSMutableParagraphStyle()
- style.lineBreakMode = .byWordWrapping
- style.lineBreakStrategy = []
- style.hyphenationFactor = 1.0
- style.allowsDefaultTighteningForTruncation = true
- return style
- }()
- private static let headlineBaseParagraphStyle: NSParagraphStyle = {
- let style = (baseWrappingParagraphStyle.mutableCopy() as! NSMutableParagraphStyle)
- style.hyphenationFactor = 0.5
- return style
- }()
- private static let summaryBaseParagraphStyle: NSParagraphStyle = {
- let style = (baseWrappingParagraphStyle.mutableCopy() as! NSMutableParagraphStyle)
- return style
- }()
-
- private static let contentCache = ArticleContentCache()
-
- // Text Storage
- private lazy var lineCountTextStorage = NSTextStorage()
- private lazy var lineCountLayoutManager: NSLayoutManager = {
- let lm = NSLayoutManager()
- lineCountTextStorage.addLayoutManager(lm)
- return lm
- }()
- private lazy var lineCountTextContainer: NSTextContainer = {
- let tc = NSTextContainer(size: .zero)
- tc.lineFragmentPadding = 0
- lineCountLayoutManager.addTextContainer(tc)
- return tc
- }()
-
- override func awakeFromNib() {
- MainActor.assumeIsolated {
- super.awakeFromNib()
- isAccessibilityElement = true
- articleContent.isAccessibilityElement = false
- articleByLine.isAccessibilityElement = false
- articleDate.isAccessibilityElement = false
- indicatorView.isAccessibilityElement = false
- feedIcon?.isAccessibilityElement = false
- indicatorView.alpha = 0.0
- topSeparator.backgroundColor = .separator.withAlphaComponent(0.1)
- feedIcon?.translatesAutoresizingMaskIntoConstraints = false
- configureStackView()
-
- registerForTraitChanges([UITraitPreferredContentSizeCategory.self], target: self, action: #selector(configureStackView))
- }
- }
-
- override func prepareForReuse() {
- super.prepareForReuse()
- rangeOfTitle = nil
- rangeOfSummary = nil
- title = ""
- summary = ""
- }
-
- private func configure(_ cellData: MainTimelineCellData) {
- articleContent.numberOfLines = cellData.numberOfLines
- updateIndicatorView(configurationState)
- if title != cellData.title || summary != cellData.summary {
- title = cellData.title
- summary = cellData.summary
- addArticleContent(configurationState)
- }
-
- if cellData.showFeedName == .feed {
- articleByLine.text = cellData.feedName
- } else if cellData.showFeedName == .byline {
- articleByLine.text = cellData.byline
- } else if cellData.showFeedName == .none {
- articleByLine.text = ""
- }
-
- if feedIcon != nil {
- setIconImage(cellData.iconImage, with: cellData.iconSize)
- }
-
- articleDate.text = cellData.dateString
- updateAccessibilityLabel()
- }
-
- private func updateAccessibilityLabel() {
- let starredStatus = cellData.starred ? "\(NSLocalizedString("Starred", comment: "Starred")), " : ""
- let unreadStatus = cellData.read ? "" : "\(NSLocalizedString("Unread", comment: "Unread")), "
- let label = starredStatus + unreadStatus + "\(cellData.feedName), \(cellData.title), \(cellData.summary), \(cellData.dateString)"
- accessibilityLabel = label
- }
-
- private func updateIndicatorView(_ state: UICellConfigurationState) {
- if cellData.starred {
- if indicatorView.alpha == 0.0 {
- indicatorView.alpha = 1.0
- }
- UIView.animate(withDuration: Self.indicatorAnimationDuration) {
- self.indicatorView.iconImage = Assets.Images.starredFeed
- self.indicatorView.tintColor = (state.isSelected && !state.isSwiped) ? .white : Assets.Colors.star
- }
- return
- } else if cellData.read == false {
- if indicatorView.alpha == 0.0 {
- indicatorView.alpha = 1.0
- }
- UIView.animate(withDuration: Self.indicatorAnimationDuration) {
- self.indicatorView.iconImage = Assets.Images.unreadCellIndicator
- self.indicatorView.tintColor = (state.isSelected && !state.isSwiped) ? .white : Assets.Colors.secondaryAccent
- }
- return
- } else if indicatorView.alpha == 1.0 {
- UIView.animate(withDuration: Self.indicatorAnimationDuration) {
- self.indicatorView.alpha = 0.0
- self.indicatorView.iconImage = nil
- }
- }
- }
-
- @objc private func configureStackView() {
- switch traitCollection.preferredContentSizeCategory {
- case .accessibilityMedium, .accessibilityLarge, .accessibilityExtraLarge, .accessibilityExtraExtraLarge, .accessibilityExtraExtraExtraLarge:
- metaDataStackView.axis = .vertical
- metaDataStackView.alignment = .leading
- metaDataStackView.distribution = .fill
- default:
- metaDataStackView.axis = .horizontal
- metaDataStackView.alignment = .bottom
- metaDataStackView.distribution = .fillEqually
- }
- }
-
- private func setIconImage(_ iconImage: IconImage?, with size: IconSize) {
- if feedIcon != nil {
- updateIconViewSizeConstraints(to: size.size)
- feedIcon!.iconImage = iconImage
- }
- }
-
- private func updateIconViewSizeConstraints(to size: CGSize) {
- guard let feedIcon, appliedIconSize != size else {
- return
- }
- appliedIconSize = size
-
- for constraint in feedIcon.constraints {
- constraint.isActive = false
- }
-
- NSLayoutConstraint.activate([
- feedIcon.widthAnchor.constraint(equalToConstant: size.width),
- feedIcon.heightAnchor.constraint(equalToConstant: size.height)
- ])
-
- setNeedsLayout()
- }
-
- private func addArticleContent(_ state: UICellConfigurationState) {
- let width = articleContent.bounds.width
- let numberOfLines = cellData.numberOfLines
- let contentSizeCategory = traitCollection.preferredContentSizeCategory
-
- let key = ArticleContentCache.Key(accountID: cellData.accountID, articleID: cellData.articleID)
- let entry: ArticleContentCache.Entry
- if let cached = Self.contentCache.entry(for: key),
- cached.width == width, cached.numberOfLines == numberOfLines, cached.contentSizeCategory == contentSizeCategory {
- entry = cached
- } else {
- entry = buildArticleContent(width: width, numberOfLines: numberOfLines, contentSizeCategory: contentSizeCategory)
- if width > 0 {
- Self.contentCache.setEntry(entry, for: key)
- }
- }
-
- articleContent.attributedText = entry.attributedText
- articleContent.lineBreakMode = entry.lineBreakMode
- rangeOfTitle = entry.rangeOfTitle
- rangeOfSummary = entry.rangeOfSummary
- }
-
- private func buildArticleContent(width: CGFloat, numberOfLines: Int, contentSizeCategory: UIContentSizeCategory) -> ArticleContentCache.Entry {
- let attributedCellText = NSMutableAttributedString()
-
- // 1. Prepare Title
- if cellData.title != "" {
- let titleFont = UIFont.preferredFont(forTextStyle: .headline)
- let lineHeight = titleFont.lineHeight
-
- let paragraphStyle = (Self.headlineBaseParagraphStyle.mutableCopy() as! NSMutableParagraphStyle)
- paragraphStyle.minimumLineHeight = lineHeight
- paragraphStyle.maximumLineHeight = lineHeight
-
- let titleAttributes: [NSAttributedString.Key: Any] = [
- .font: titleFont,
- .paragraphStyle: paragraphStyle,
- .foregroundColor: UIColor.label
- ]
-
- let titleAttributed = NSAttributedString(string: cellData.title, attributes: titleAttributes)
-
- // 2. If the title already fills the available lines, it occupies the whole label and
- // truncates with an ellipsis if it overflows.
- let linesUsed = countLines(titleAttributed, width: width)
- if linesUsed >= numberOfLines {
- let titleRange = NSRange(location: 0, length: titleAttributed.length)
- return Self.entry(width, numberOfLines, contentSizeCategory, titleAttributed, .byTruncatingTail, titleRange, nil)
- }
-
- attributedCellText.append(titleAttributed)
- }
-
- let rangeOfTitle = cellData.title != "" ? NSRange(location: 0, length: attributedCellText.length) : nil
-
- // 3. Prepare Summary (only reached if the title is under numberOfLines).
- var rangeOfSummary: NSRange?
- if cellData.summary != "" {
- let summaryFont = UIFont.preferredFont(forTextStyle: .body)
- let summaryLineHeight = summaryFont.lineHeight
-
- let paragraphStyle = (Self.summaryBaseParagraphStyle.mutableCopy() as! NSMutableParagraphStyle)
- paragraphStyle.minimumLineHeight = summaryLineHeight
- paragraphStyle.maximumLineHeight = summaryLineHeight
-
- let summaryAttributes: [NSAttributedString.Key: Any] = [
- .font: summaryFont,
- .paragraphStyle: paragraphStyle,
- .foregroundColor: cellData.title != "" ? UIColor.secondaryLabel : UIColor.label
- ]
-
- let prefix = cellData.title != "" ? "\n" : ""
- let summaryAttributed = NSAttributedString(string: prefix + cellData.summary, attributes: summaryAttributes)
- rangeOfSummary = NSRange(location: attributedCellText.length, length: summaryAttributed.length)
- attributedCellText.append(summaryAttributed)
- }
-
- // The whole label truncates with an ellipsis only when the combined title+summary overflows;
- // when it fits, wrap so a fitting title isn't given a spurious ellipsis by the trailing summary.
- let linesUsed = countLines(attributedCellText, width: width)
- let lineBreakMode: NSLineBreakMode = linesUsed >= numberOfLines ? .byTruncatingTail : .byWordWrapping
- return Self.entry(width, numberOfLines, contentSizeCategory, attributedCellText, lineBreakMode, rangeOfTitle, rangeOfSummary)
- }
-
- private static func entry(_ width: CGFloat, _ numberOfLines: Int, _ contentSizeCategory: UIContentSizeCategory, _ attributedText: NSAttributedString, _ lineBreakMode: NSLineBreakMode, _ rangeOfTitle: NSRange?, _ rangeOfSummary: NSRange?) -> ArticleContentCache.Entry {
- ArticleContentCache.Entry(width: width, numberOfLines: numberOfLines, contentSizeCategory: contentSizeCategory, attributedText: attributedText, lineBreakMode: lineBreakMode, rangeOfTitle: rangeOfTitle, rangeOfSummary: rangeOfSummary)
- }
-
- func adjustArticleContentColor() {
- func applyTitleColour() {
- guard let titleRange = rangeOfTitle, titleRange.location != NSNotFound, titleRange.length > 0 else { return }
- guard let current = articleContent.attributedText else { return }
- let mutable = NSMutableAttributedString(attributedString: current)
- mutable.addAttribute(.foregroundColor, value: UIColor.label, range: titleRange)
- articleContent.attributedText = mutable
- }
- func applySummaryColour() {
- guard let summaryRange = rangeOfSummary, summaryRange.location != NSNotFound, summaryRange.length > 0 else { return }
- guard let current = articleContent.attributedText else { return }
- let mutable = NSMutableAttributedString(attributedString: current)
- mutable.addAttribute(.foregroundColor, value: cellData.title == "" ? UIColor.label : UIColor.secondaryLabel, range: summaryRange)
- articleContent.attributedText = mutable
- }
-
- if configurationState.isSwiped && configurationState.isSelected {
- articleContent.textColor = .white
- articleByLine.textColor = .white
- articleDate.textColor = .white
- } else if configurationState.isSwiped && !configurationState.isSelected {
- applyTitleColour()
- applySummaryColour()
- articleByLine.textColor = .secondaryLabel
- articleDate.textColor = .secondaryLabel
- } else if !configurationState.isSwiped && configurationState.isSelected {
- articleContent.textColor = .white
- articleByLine.textColor = .white
- articleDate.textColor = .white
- } else {
- applyTitleColour()
- applySummaryColour()
- articleByLine.textColor = .secondaryLabel
- articleDate.textColor = .secondaryLabel
- }
- }
-
- func countLines(_ attributed: NSAttributedString, width: CGFloat) -> Int {
- lineCountTextContainer.size = CGSize(width: width, height: .greatestFiniteMagnitude)
- lineCountTextStorage.setAttributedString(attributed)
- lineCountLayoutManager.ensureLayout(for: lineCountTextContainer)
-
- var lineCount = 0
- var index = 0
- var lineRange = NSRange()
- while index < lineCountLayoutManager.numberOfGlyphs {
- lineCountLayoutManager.lineFragmentRect(forGlyphAt: index, effectiveRange: &lineRange)
- index = NSMaxRange(lineRange)
- lineCount += 1
- }
- return lineCount
- }
-
- override func updateConfiguration(using state: UICellConfigurationState) {
- super.updateConfiguration(using: state)
-
- var backgroundConfig: UIBackgroundConfiguration
- if #available(iOS 18, *) {
- backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
- } else {
- backgroundConfig = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
- }
- if #available(iOS 26, *) {
- backgroundConfig.cornerRadius = 20
- backgroundConfig.edgesAddingLayoutMarginsToBackgroundInsets = [.leading, .trailing]
- if UIDevice.current.userInterfaceIdiom == .pad {
- backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -8, bottom: 0, trailing: -8)
- } else {
- if !isPreview {
- backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -12, bottom: 0, trailing: -12)
- } else {
- backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -16, bottom: 0, trailing: -16)
- }
- }
- } else {
- backgroundConfig.cornerRadius = 0
- }
-
- let isActive = state.isSwiped || state.isSelected
-
- if state.isSwiped && state.isSelected {
- backgroundConfig.backgroundColor = Assets.Colors.primaryAccent
- } else if state.isSwiped && !state.isSelected {
- backgroundConfig.backgroundColor = .secondarySystemFill
- } else if !state.isSwiped && state.isSelected {
- backgroundConfig.backgroundColor = Assets.Colors.primaryAccent
- } else {
- backgroundConfig.backgroundColor = .clear
- }
-
- // Hide this cell's separator when active, or when the cell
- // directly above is active (so no separator appears below a
- // highlighted row).
- let hideForPreviousCell = cellAboveIsActive()
- topSeparator.alpha = (isActive || hideForPreviousCell) ? 0.0 : 1.0
- adjustArticleContentColor()
- updateIndicatorView(state)
-
- if isPreview {
- backgroundConfig.backgroundColor = traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
- topSeparator.alpha = 0.0
- }
-
- self.backgroundConfiguration = backgroundConfig
- }
-
- private func cellAboveIsActive() -> Bool {
- guard let collectionView = superview as? UICollectionView,
- let myIndexPath = collectionView.indexPath(for: self) else {
- return false
- }
-
- let section = myIndexPath.section
- let item = myIndexPath.item
- guard item > 0 else {
- return false
- }
-
- let previousIndexPath = IndexPath(item: item - 1, section: section)
- guard let previousCell = collectionView.cellForItem(at: previousIndexPath) else {
- return false
- }
-
- let state = previousCell.configurationState
- return state.isSelected || state.isSwiped
- }
-}
diff --git a/iOS/MainTimeline/MainTimelineModernViewController.swift b/iOS/MainTimeline/MainTimelineModernViewController.swift
index 2025945f9..9630332c5 100644
--- a/iOS/MainTimeline/MainTimelineModernViewController.swift
+++ b/iOS/MainTimeline/MainTimelineModernViewController.swift
@@ -18,13 +18,6 @@ import Images
final class MainTimelineModernViewController: UIViewController, UndoableCommandRunner {
- struct CellIdentifier {
- static let standard = "MainTimelineCellStandard"
- static let standardIndex0 = "MainTimelineCellIndexZero"
- static let icon = "MainTimelineCellIcon"
- static let iconIndex0 = "MainTimelineCellIconIndexZero"
- }
-
// MARK: Private Variables
private var numberOfTextLines = 0
private var iconSize = IconSize.medium
@@ -841,33 +834,16 @@ private extension MainTimelineModernViewController {
}
private func makeDataSource(_ collectionView: UICollectionView) -> UICollectionViewDiffableDataSource {
+ collectionView.register(MainTimelineCell.self, forCellWithReuseIdentifier: MainTimelineCell.reuseIdentifier)
+
let dataSource: UICollectionViewDiffableDataSource =
MainTimelineCollectionViewDataSource(collectionView: collectionView, cellProvider: { [weak self] collectionView, indexPath, article in
guard let self else {
return nil
}
- let cellData = self.configure(article: article)
- if self.showIcons {
- if indexPath.row == 0 {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellIdentifier.iconIndex0, for: indexPath) as! MainTimelineCollectionViewCell
- cell.cellData = cellData
- return cell
- } else {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellIdentifier.icon, for: indexPath) as! MainTimelineCollectionViewCell
- cell.cellData = cellData
- return cell
- }
- } else {
- if indexPath.row == 0 {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellIdentifier.standardIndex0, for: indexPath) as! MainTimelineCollectionViewCell
- cell.cellData = cellData
- return cell
- } else {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellIdentifier.standard, for: indexPath) as! MainTimelineCollectionViewCell
- cell.cellData = cellData
- return cell
- }
- }
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainTimelineCell.reuseIdentifier, for: indexPath) as! MainTimelineCell
+ cell.cellData = self.configure(article: article)
+ return cell
})
return dataSource
diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard
index e4e9bce70..5e8a4e2c8 100644
--- a/iOS/Settings/Settings.storyboard
+++ b/iOS/Settings/Settings.storyboard
@@ -796,161 +796,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/iOS/Settings/TimelineCustomizerCollectionViewController.swift b/iOS/Settings/TimelineCustomizerCollectionViewController.swift
index 243ab9a1a..e31bf302a 100644
--- a/iOS/Settings/TimelineCustomizerCollectionViewController.swift
+++ b/iOS/Settings/TimelineCustomizerCollectionViewController.swift
@@ -71,6 +71,8 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController {
withReuseIdentifier: TimelineHeaderView.reuseIdentifier
)
+ collectionView.register(MainTimelineCell.self, forCellWithReuseIdentifier: MainTimelineCell.reuseIdentifier)
+
var config = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
config.showsSeparators = false
config.headerMode = .supplementary
@@ -106,7 +108,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController {
}
if indexPath.section == 2 {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MainTimelineCellStandard", for: indexPath) as! MainTimelineCollectionViewCell
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainTimelineCell.reuseIdentifier, for: indexPath) as! MainTimelineCell
cell.cellData = MainTimelineCellData(article: previewArticle,
showFeedName: .byline,
feedName: "The Fellowship of the Ring",
@@ -120,7 +122,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController {
}
if indexPath.section == 3 {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MainTimelineCellIcon", for: indexPath) as! MainTimelineCollectionViewCell
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainTimelineCell.reuseIdentifier, for: indexPath) as! MainTimelineCell
cell.cellData = MainTimelineCellData(article: previewArticle,
showFeedName: .byline,
feedName: "The Fellowship of the Ring",
@@ -133,7 +135,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController {
return cell
}
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MainTimelineCellStandard", for: indexPath)
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainTimelineCell.reuseIdentifier, for: indexPath)
return cell
}