diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 05310ab86..d8eacf804 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -102,6 +102,7 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(reloadDueToThemeChange(_:)), name: .CurrentArticleThemeDidChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(configureAppearanceMenu(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(updateUnreadCountIndicator(_:)), name: UIDevice.orientationDidChangeNotification, object: nil) articleExtractorButton.addTarget(self, action: #selector(toggleArticleExtractor(_:)), for: .touchUpInside) toolbarItems?.insert(UIBarButtonItem(customView: articleExtractorButton), at: 6) @@ -294,7 +295,14 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { configureAppearanceMenu() } - public func updateUnreadCountIndicator() { + + /// Updates the indicator count in the navigation bar. + /// For iPhone, this indicator is visible if the unread count is > 0. + /// For iPad, this indicator is visible if it is in `portrait` or `unknown` + /// orientation, **and** the unread count is > 0. + /// - Parameter sender: `Any` (optional) + @objc + public func updateUnreadCountIndicator(_ sender: Any? = nil) { if UIDevice.current.userInterfaceIdiom == .phone { if currentUnreadCount > 0 { let unreadCountView = MasterTimelineUnreadCountView(frame: .zero) @@ -304,6 +312,20 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { } else { navigationItem.leftBarButtonItem = nil } + } else { + + if UIDevice.current.orientation.isPortrait || !UIDevice.current.orientation.isValidInterfaceOrientation { + 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 + } + } else { + navigationItem.leftBarButtonItem = nil + } } }