From cb9c4aff85751d05dbb796cd38c464e3cc96769f Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 7 Nov 2026 21:20:39 -0800 Subject: [PATCH] Add full-titles setting on iOS. --- Shared/Localizable.xcstrings | 3 +++ .../Cell/MainTimelineCellData.swift | 11 ++++++++--- .../Cell/MainTimelineCellLayout.swift | 3 ++- .../MainTimelineViewController.swift | 13 ++++++++++++- ...ineCustomizerCollectionViewController.swift | 18 +++++++++++++++++- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Shared/Localizable.xcstrings b/Shared/Localizable.xcstrings index ccc4a8c9d..49546dc97 100644 --- a/Shared/Localizable.xcstrings +++ b/Shared/Localizable.xcstrings @@ -675,6 +675,9 @@ "from cache" : { "comment" : "Activity log — appended when a download was served from cache instead of the network" }, + "Full Titles, No Preview" : { + "comment" : "Timeline Layout: switch that shows whole titles, without the article preview, in the timeline" + }, "General" : { "comment" : "Preferences", "localizations" : { diff --git a/iOS/MainTimeline/Cell/MainTimelineCellData.swift b/iOS/MainTimeline/Cell/MainTimelineCellData.swift index 9887f84a5..3956cf4bb 100644 --- a/iOS/MainTimeline/Cell/MainTimelineCellData.swift +++ b/iOS/MainTimeline/Cell/MainTimelineCellData.swift @@ -13,6 +13,7 @@ import Images @MainActor struct MainTimelineCellData { private static let noText = NSLocalizedString("(No Text)", comment: "No Text") + static let fullTitleMaximumNumberOfLines = 12 let accountID: String let articleID: String @@ -27,15 +28,17 @@ import Images let showIcon: Bool // Make space even when icon is nil let read: Bool let starred: Bool - let numberOfLines: Int + let numberOfLines: Int // Shared by the title and summary, or the title alone with showsFullTitles let iconSize: IconSize let thumbnail: UIImage? let showThumbnail: Bool // Make space even when thumbnail is nil let thumbnailsDisplay: TimelineThumbnailsDisplay let fadesReadArticles: Bool let feedNameAndDateAboveTitle: Bool + let showsFullTitles: Bool - init(article: Article, showFeedName: ShowFeedName, feedName: String?, byline: String?, iconImage: IconImage?, showIcon: Bool, numberOfLines: Int, iconSize: IconSize, thumbnail: UIImage?, showThumbnail: Bool, thumbnailsDisplay: TimelineThumbnailsDisplay, fadesReadArticles: Bool, feedNameAndDateAboveTitle: Bool) { + /// With `showsFullTitles`, the title gets up to `fullTitleMaximumNumberOfLines` lines and there’s no summary. + init(article: Article, showFeedName: ShowFeedName, feedName: String?, byline: String?, iconImage: IconImage?, showIcon: Bool, numberOfLines: Int, iconSize: IconSize, thumbnail: UIImage?, showThumbnail: Bool, thumbnailsDisplay: TimelineThumbnailsDisplay, fadesReadArticles: Bool, feedNameAndDateAboveTitle: Bool, showsFullTitles: Bool) { self.accountID = article.accountID self.articleID = article.articleID @@ -70,13 +73,14 @@ import Images self.read = article.status.read self.starred = article.status.starred - self.numberOfLines = numberOfLines + self.numberOfLines = showsFullTitles ? Self.fullTitleMaximumNumberOfLines : numberOfLines self.iconSize = iconSize self.thumbnail = thumbnail self.showThumbnail = showThumbnail self.thumbnailsDisplay = thumbnailsDisplay self.fadesReadArticles = fadesReadArticles self.feedNameAndDateAboveTitle = feedNameAndDateAboveTitle + self.showsFullTitles = showsFullTitles } init() { // Empty @@ -100,6 +104,7 @@ import Images self.thumbnailsDisplay = .none self.fadesReadArticles = false self.feedNameAndDateAboveTitle = false + self.showsFullTitles = false } } diff --git a/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift b/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift index 18ba71e1d..99c6ec4c3 100644 --- a/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift +++ b/iOS/MainTimeline/Cell/MainTimelineCellLayout.swift @@ -68,7 +68,8 @@ extension MainTimelineCellLayout { 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 { + // With full titles, the summary shows only when there’s no title. + if cellData.summary.isEmpty || linesLeft < 1 || (cellData.showsFullTitles && linesUsed > 0) { return r } r.origin = point diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index f9e699b6a..810862d32 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -24,6 +24,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner private var thumbnailsDisplay = TimelineThumbnailsDisplay.none private var fadesReadArticles = false private var feedNameAndDateAboveTitle = false + private var showsFullTitles = false private var articleIDsToReload = Set() private lazy var feedTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showFeedInspector(_:))) private lazy var filterButton = UIBarButtonItem(image: Assets.Images.filter, style: .plain, target: self, action: #selector(toggleFilter(_:))) @@ -193,6 +194,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner thumbnailsDisplay = AppDefaults.timelineThumbnailsDisplay fadesReadArticles = AppDefaults.timelineFadeReadArticles feedNameAndDateAboveTitle = AppDefaults.timelineFeedNameAndDateAboveTitle + showsFullTitles = AppDefaults.timelineShowFullTitles assert(collectionView?.refreshControl != nil) collectionView?.refreshControl = UIRefreshControl() @@ -763,6 +765,7 @@ private extension MainTimelineViewController { NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineThumbnailsDisplayDidChange(_:)), name: .timelineThumbnailsDisplayDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineFadeReadArticlesDidChange(_:)), name: .timelineFadeReadArticlesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineFeedNameAndDateAboveTitleDidChange(_:)), name: .timelineFeedNameAndDateAboveTitleDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineShowFullTitlesDidChange(_:)), name: .timelineShowFullTitlesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleThumbnailDidBecomeAvailable(_:)), name: .thumbnailDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleArticleThumbnailDownloadDidFail(_:)), name: .articleThumbnailDownloadDidFail, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleNetworkStatusDidChange(_:)), name: .networkStatusDidChange, object: nil) @@ -997,7 +1000,7 @@ private extension MainTimelineViewController { showThumbnail = true thumbnail = ThumbnailDownloader.shared.thumbnail(url: thumbnailURL, mode: thumbnailMode, articleTitle: article.title) } - let cellData = MainTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, numberOfLines: numberOfTextLines, iconSize: iconSize, thumbnail: thumbnail, showThumbnail: showThumbnail, thumbnailsDisplay: thumbnailsDisplay, fadesReadArticles: fadesReadArticles, feedNameAndDateAboveTitle: feedNameAndDateAboveTitle) + let cellData = MainTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, byline: article.byline(), iconImage: iconImage, showIcon: showIcon, numberOfLines: numberOfTextLines, iconSize: iconSize, thumbnail: thumbnail, showThumbnail: showThumbnail, thumbnailsDisplay: thumbnailsDisplay, fadesReadArticles: fadesReadArticles, feedNameAndDateAboveTitle: feedNameAndDateAboveTitle, showsFullTitles: showsFullTitles) return cellData } @@ -1206,6 +1209,14 @@ private extension MainTimelineViewController { reloadAllCells() } + @objc func handleTimelineShowFullTitlesDidChange(_ notification: Notification) { + guard showsFullTitles != AppDefaults.timelineShowFullTitles else { + return + } + showsFullTitles = AppDefaults.timelineShowFullTitles + reloadAllCells() + } + @objc func handleThumbnailDidBecomeAvailable(_ notification: Notification) { guard let thumbnailMode, let collectionView, let dataSource, let url = notification.userInfo?[ThumbnailDownloader.urlKey] as? String else { return diff --git a/iOS/Settings/TimelineCustomizerCollectionViewController.swift b/iOS/Settings/TimelineCustomizerCollectionViewController.swift index 0ed5c9475..cb24f694a 100644 --- a/iOS/Settings/TimelineCustomizerCollectionViewController.swift +++ b/iOS/Settings/TimelineCustomizerCollectionViewController.swift @@ -35,6 +35,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController { private enum OptionsRow: Int, CaseIterable { case feedIcons case thumbnails + case fullTitles case fadeReadArticles case feedNameAndDateAboveTitle } @@ -97,6 +98,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController { } NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineFeedIconsDisplayDidChange(_:)), name: .timelineFeedIconsDisplayDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineThumbnailsDisplayDidChange(_:)), name: .timelineThumbnailsDisplayDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineShowFullTitlesDidChange(_:)), name: .timelineShowFullTitlesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineFadeReadArticlesDidChange(_:)), name: .timelineFadeReadArticlesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(handleTimelineFeedNameAndDateAboveTitleDidChange(_:)), name: .timelineFeedNameAndDateAboveTitleDidChange, object: nil) @@ -155,6 +157,8 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController { case .numberOfLines: let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "NumberOfLinesSelector", for: indexPath) as! TimelineCustomizerCell cell.sliderConfiguration = .numberOfLines + // The number of lines applies only to the title and summary. + cell.slider.isEnabled = !AppDefaults.timelineShowFullTitles return cell case .options: let optionsRow = OptionsRow(rawValue: indexPath.item) ?? .feedIcons @@ -222,6 +226,11 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController { reloadOptionsRowsAndPreviews() } + @objc func handleTimelineShowFullTitlesDidChange(_ notification: Notification) { + collectionView.reloadSections(IndexSet(integer: Section.numberOfLines.rawValue)) + reloadOptionsRowsAndPreviews() + } + @objc func handleTimelineFadeReadArticlesDidChange(_ notification: Notification) { reloadOptionsRowsAndPreviews() } @@ -286,7 +295,8 @@ private extension TimelineCustomizerCollectionViewController { showThumbnail: section.showsThumbnail, thumbnailsDisplay: AppDefaults.timelineThumbnailsDisplay, fadesReadArticles: AppDefaults.timelineFadeReadArticles, - feedNameAndDateAboveTitle: AppDefaults.timelineFeedNameAndDateAboveTitle) + feedNameAndDateAboveTitle: AppDefaults.timelineFeedNameAndDateAboveTitle, + showsFullTitles: AppDefaults.timelineShowFullTitles) cell.isPreview = true return cell } @@ -303,6 +313,12 @@ private extension TimelineCustomizerCollectionViewController { content.text = NSLocalizedString("Thumbnail Size", comment: "Thumbnail Size") content.secondaryText = AppDefaults.timelineThumbnailsDisplay.description cell.accessories = [.popUpMenu(timelineThumbnailsDisplayMenu())] + case .fullTitles: + content = UIListContentConfiguration.cell() + content.text = NSLocalizedString("Full Titles, No Preview", comment: "Timeline Layout: switch that shows whole titles, without the article preview, in the timeline") + configureSwitch(cell, isOn: AppDefaults.timelineShowFullTitles) { isOn in + AppDefaults.timelineShowFullTitles = isOn + } case .fadeReadArticles: content = UIListContentConfiguration.cell() content.text = NSLocalizedString("Fade Read Articles", comment: "Timeline Layout: switch that fades read articles in the timeline")