mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix how the Article Unread Count is updated
This commit is contained in:
@@ -102,7 +102,6 @@ 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)
|
||||
@@ -349,9 +348,8 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable {
|
||||
/// 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 {
|
||||
public func updateUnreadCountIndicator(forDisplayMode displayMode: UISplitViewController.DisplayMode? = nil) {
|
||||
func changeUnreadCountIndicator() {
|
||||
if currentUnreadCount > 0 {
|
||||
let unreadCountView = MasterTimelineUnreadCountView(frame: .zero)
|
||||
unreadCountView.unreadCount = currentUnreadCount
|
||||
@@ -360,17 +358,13 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable {
|
||||
} else {
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
changeUnreadCountIndicator()
|
||||
} 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
|
||||
}
|
||||
if displayMode == nil || displayMode == .secondaryOnly {
|
||||
changeUnreadCountIndicator()
|
||||
} else {
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
}
|
||||
|
||||
@@ -1323,6 +1323,10 @@ extension SceneCoordinator: UISplitViewControllerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) {
|
||||
articleViewController?.updateUnreadCountIndicator(forDisplayMode: displayMode)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: UINavigationControllerDelegate
|
||||
|
||||
Reference in New Issue
Block a user