mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge branch 'master' into accent-color-experimental
This commit is contained in:
@@ -20,6 +20,7 @@ protocol SidebarDelegate: class {
|
||||
|
||||
@objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSMenuDelegate, UndoableCommandRunner {
|
||||
|
||||
@IBOutlet weak var readFilteredButton: NSButton!
|
||||
@IBOutlet var outlineView: SidebarOutlineView!
|
||||
|
||||
weak var delegate: SidebarDelegate?
|
||||
@@ -129,6 +130,8 @@ protocol SidebarDelegate: class {
|
||||
if let readFeedsFilterState = state[UserInfoKey.readFeedsFilterState] as? Bool {
|
||||
isReadFiltered = readFeedsFilterState
|
||||
}
|
||||
|
||||
updateReadFilterButton()
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
@@ -446,6 +449,7 @@ protocol SidebarDelegate: class {
|
||||
}
|
||||
delegate?.sidebarInvalidatedRestorationState(self)
|
||||
rebuildTreeAndRestoreSelection()
|
||||
updateReadFilterButton()
|
||||
}
|
||||
|
||||
func cleanUp() {
|
||||
@@ -815,6 +819,14 @@ private extension SidebarViewController {
|
||||
func revealAndSelectRepresentedObject(_ representedObject: AnyObject) -> Bool {
|
||||
return outlineView.revealAndSelectRepresentedObject(representedObject, treeController)
|
||||
}
|
||||
|
||||
func updateReadFilterButton() {
|
||||
if isReadFiltered {
|
||||
readFilteredButton.image = AppAssets.filterActive
|
||||
} else {
|
||||
readFilteredButton.image = AppAssets.filterInactive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension Node {
|
||||
|
||||
@@ -19,6 +19,12 @@ protocol TimelineContainerViewControllerDelegate: class {
|
||||
|
||||
final class TimelineContainerViewController: NSViewController {
|
||||
|
||||
@IBOutlet weak var viewOptionsPopUpButton: NSPopUpButton!
|
||||
@IBOutlet weak var newestToOldestMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var oldestToNewestMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var groupByFeedMenuItem: NSMenuItem!
|
||||
|
||||
@IBOutlet weak var readFilteredButton: NSButton!
|
||||
@IBOutlet var containerView: TimelineContainerView!
|
||||
|
||||
var currentTimelineViewController: TimelineViewController? {
|
||||
@@ -52,12 +58,22 @@ final class TimelineContainerViewController: NSViewController {
|
||||
super.viewDidLoad()
|
||||
setRepresentedObjects(nil, mode: .regular)
|
||||
showTimeline(for: .regular)
|
||||
updateViewOptionsPopUpButton()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
updateViewOptionsPopUpButton()
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
|
||||
func setRepresentedObjects(_ objects: [AnyObject]?, mode: TimelineSourceMode) {
|
||||
timelineViewController(for: mode).representedObjects = objects
|
||||
updateReadFilterButton()
|
||||
}
|
||||
|
||||
func showTimeline(for mode: TimelineSourceMode) {
|
||||
@@ -95,6 +111,7 @@ final class TimelineContainerViewController: NSViewController {
|
||||
|
||||
func toggleReadFilter() {
|
||||
regularTimelineViewController.toggleReadFilter()
|
||||
updateReadFilterButton()
|
||||
}
|
||||
|
||||
// MARK: State Restoration
|
||||
@@ -105,6 +122,7 @@ final class TimelineContainerViewController: NSViewController {
|
||||
|
||||
func restoreState(from state: [AnyHashable : Any]) {
|
||||
regularTimelineViewController.restoreState(from: state)
|
||||
updateReadFilterButton()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,4 +163,42 @@ private extension TimelineContainerViewController {
|
||||
assertionFailure("Expected timelineViewController to match either regular or search timelineViewController, but it doesn’t.")
|
||||
return .regular // Should never get here.
|
||||
}
|
||||
|
||||
func updateViewOptionsPopUpButton() {
|
||||
let localizedTitle = NSLocalizedString("Sort %@", comment: "Sort")
|
||||
|
||||
if AppDefaults.timelineSortDirection == .orderedAscending {
|
||||
newestToOldestMenuItem.state = .off
|
||||
oldestToNewestMenuItem.state = .on
|
||||
let title = NSString.localizedStringWithFormat(localizedTitle as NSString, oldestToNewestMenuItem.title) as String
|
||||
viewOptionsPopUpButton.setTitle(title)
|
||||
} else {
|
||||
newestToOldestMenuItem.state = .on
|
||||
oldestToNewestMenuItem.state = .off
|
||||
let title = NSString.localizedStringWithFormat(localizedTitle as NSString, newestToOldestMenuItem.title) as String
|
||||
viewOptionsPopUpButton.setTitle(title)
|
||||
}
|
||||
|
||||
if AppDefaults.timelineGroupByFeed == true {
|
||||
groupByFeedMenuItem.state = .on
|
||||
} else {
|
||||
groupByFeedMenuItem.state = .off
|
||||
}
|
||||
}
|
||||
|
||||
func updateReadFilterButton() {
|
||||
guard let isReadFiltered = regularTimelineViewController.isReadFiltered else {
|
||||
readFilteredButton.isHidden = true
|
||||
return
|
||||
}
|
||||
|
||||
readFilteredButton.isHidden = false
|
||||
|
||||
if isReadFiltered {
|
||||
readFilteredButton.image = AppAssets.filterActive
|
||||
} else {
|
||||
readFilteredButton.image = AppAssets.filterInactive
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user