diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 26d22aa01..05310ab86 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -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 diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 73d9c58b6..d884975d7 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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() {