mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
NetNewsWire-Mac AppDefaults is now a singleton
This commit is contained in:
@@ -44,7 +44,7 @@ struct TimelineCellAppearance: Equatable {
|
||||
|
||||
init(showIcon: Bool, fontSize: FontSize) {
|
||||
|
||||
let actualFontSize = AppDefaults.actualFontSize(for: fontSize)
|
||||
let actualFontSize = AppDefaults.shared.actualFontSize(for: fontSize)
|
||||
let smallItemFontSize = floor(actualFontSize * 0.90)
|
||||
let largeItemFontSize = actualFontSize
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||
return [self.dateView, self.feedNameView, self.titleView, self.summaryView, self.textView]
|
||||
}()
|
||||
|
||||
private var showsSeparator: Bool = AppDefaults.timelineShowsSeparators {
|
||||
private var showsSeparator: Bool = AppDefaults.shared.timelineShowsSeparators {
|
||||
didSet {
|
||||
separatorView.isHidden = !showsSeparator
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||
}
|
||||
|
||||
func timelineShowsSeparatorsDefaultDidChange() {
|
||||
showsSeparator = AppDefaults.timelineShowsSeparators
|
||||
showsSeparator = AppDefaults.shared.timelineShowsSeparators
|
||||
}
|
||||
|
||||
override func setFrameSize(_ newSize: NSSize) {
|
||||
@@ -209,7 +209,7 @@ private extension TimelineTableCellView {
|
||||
addSubviewAtInit(feedNameView, hidden: true)
|
||||
addSubviewAtInit(iconView, hidden: true)
|
||||
addSubviewAtInit(starView, hidden: true)
|
||||
addSubviewAtInit(separatorView, hidden: !AppDefaults.timelineShowsSeparators)
|
||||
addSubviewAtInit(separatorView, hidden: !AppDefaults.shared.timelineShowsSeparators)
|
||||
|
||||
makeTextFieldColorsNormal()
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ private extension TimelineContainerViewController {
|
||||
func updateViewOptionsPopUpButton() {
|
||||
let localizedTitle = NSLocalizedString("Sort %@", comment: "Sort")
|
||||
|
||||
if AppDefaults.timelineSortDirection == .orderedAscending {
|
||||
if AppDefaults.shared.timelineSortDirection == .orderedAscending {
|
||||
newestToOldestMenuItem.state = .off
|
||||
oldestToNewestMenuItem.state = .on
|
||||
let title = NSString.localizedStringWithFormat(localizedTitle as NSString, oldestToNewestMenuItem.title) as String
|
||||
@@ -179,7 +179,7 @@ private extension TimelineContainerViewController {
|
||||
viewOptionsPopUpButton.setTitle(title)
|
||||
}
|
||||
|
||||
if AppDefaults.timelineGroupByFeed == true {
|
||||
if AppDefaults.shared.timelineGroupByFeed == true {
|
||||
groupByFeedMenuItem.state = .on
|
||||
} else {
|
||||
groupByFeedMenuItem.state = .off
|
||||
|
||||
@@ -142,21 +142,21 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
private var didRegisterForNotifications = false
|
||||
static let fetchAndMergeArticlesQueue = CoalescingQueue(name: "Fetch and Merge Articles", interval: 0.5, maxInterval: 2.0)
|
||||
|
||||
private var sortDirection = AppDefaults.timelineSortDirection {
|
||||
private var sortDirection = AppDefaults.shared.timelineSortDirection {
|
||||
didSet {
|
||||
if sortDirection != oldValue {
|
||||
sortParametersDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var groupByFeed = AppDefaults.timelineGroupByFeed {
|
||||
private var groupByFeed = AppDefaults.shared.timelineGroupByFeed {
|
||||
didSet {
|
||||
if groupByFeed != oldValue {
|
||||
sortParametersDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var fontSize: FontSize = AppDefaults.timelineFontSize {
|
||||
private var fontSize: FontSize = AppDefaults.shared.timelineFontSize {
|
||||
didSet {
|
||||
if fontSize != oldValue {
|
||||
fontSizeDidChange()
|
||||
@@ -611,9 +611,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
self.fontSize = AppDefaults.timelineFontSize
|
||||
self.sortDirection = AppDefaults.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.timelineGroupByFeed
|
||||
self.fontSize = AppDefaults.shared.timelineFontSize
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
}
|
||||
|
||||
// MARK: - Reloading Data
|
||||
|
||||
Reference in New Issue
Block a user