mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #3462 from stuartbreckenridge/ios-unread-article-count
Adds unread count indicator to Article view
This commit is contained in:
@@ -87,6 +87,12 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable {
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
|
||||
var currentUnreadCount: Int = 0 {
|
||||
didSet {
|
||||
updateUnreadCountIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@@ -105,6 +111,8 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable {
|
||||
parentNavController.interactivePopGestureRecognizer?.delegate = poppableDelegate
|
||||
}
|
||||
|
||||
navigationItem.leftItemsSupplementBackButton = true
|
||||
|
||||
pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [:])
|
||||
pageViewController.delegate = self
|
||||
pageViewController.dataSource = self
|
||||
@@ -286,6 +294,20 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable {
|
||||
configureAppearanceMenu()
|
||||
}
|
||||
|
||||
public func updateUnreadCountIndicator() {
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
if currentUnreadCount > 0 {
|
||||
let unreadCountView = MasterTimelineUnreadCountView(frame: .zero)
|
||||
unreadCountView.unreadCount = currentUnreadCount
|
||||
unreadCountView.setFrameIfNotEqual(CGRect(x: 0, y: 0, width: unreadCountView.intrinsicContentSize.width, height: unreadCountView.intrinsicContentSize.height))
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: unreadCountView)
|
||||
} else {
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: Notifications
|
||||
|
||||
|
||||
@@ -822,7 +822,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
|
||||
// Mark article as read before navigating to it, so the read status does not flash unread/read on display
|
||||
markArticles(Set([article!]), statusKey: .read, flag: true)
|
||||
|
||||
masterTimelineViewController?.updateArticleSelection(animations: animations)
|
||||
articleViewController?.article = article
|
||||
if let isShowingExtractedArticle = isShowingExtractedArticle, let articleWindowScrollY = articleWindowScrollY {
|
||||
@@ -1404,6 +1403,7 @@ private extension SceneCoordinator {
|
||||
}
|
||||
}
|
||||
timelineUnreadCount = count
|
||||
articleViewController?.currentUnreadCount = timelineUnreadCount
|
||||
}
|
||||
|
||||
func rebuildArticleDictionaries() {
|
||||
|
||||
Reference in New Issue
Block a user