Merge pull request #3462 from stuartbreckenridge/ios-unread-article-count

Adds unread count indicator to Article view
This commit is contained in:
Maurice Parker
2022-02-12 16:09:54 -08:00
committed by GitHub
2 changed files with 23 additions and 1 deletions

View File

@@ -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

View File

@@ -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() {