mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 09:18:18 +00:00
Add full-titles setting on iOS.
This commit is contained in:
1 parent
ff92ce46db
commit
cb9c4aff85
5 files changed
+42
-6
No files matched your search
@@ -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" : {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<String>()
|
||||
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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user