diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift
index ba4916dda..5c10c3d9d 100644
--- a/Mac/AppDelegate.swift
+++ b/Mac/AppDelegate.swift
@@ -121,6 +121,7 @@ let appName = "NetNewsWire"
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: AccountManager.shared)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(handleUserInterfaceColorPaletteDidUpdate(_:)), name: .userInterfaceColorPaletteDidUpdate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(importDownloadedTheme(_:)), name: .didEndDownloadingTheme, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(themeImportError(_:)), name: .didFailToImportThemeWithError, object: nil)
@@ -144,6 +145,7 @@ let appName = "NetNewsWire"
func applicationWillFinishLaunching(_ notification: Notification) {
FaviconGenerator.templateImage = Assets.Images.faviconTemplate
+ applyUserInterfaceColorPalette()
installAppleEventHandlers()
@@ -366,6 +368,10 @@ let appName = "NetNewsWire"
updateDockBadge()
}
+ @objc func handleUserInterfaceColorPaletteDidUpdate(_ notification: Notification) {
+ applyUserInterfaceColorPalette()
+ }
+
@objc func inspectableObjectsDidChange(_ note: Notification) {
MainActor.assumeIsolated {
guard let inspectorWindowController = inspectorWindowController, inspectorWindowController.isOpen else {
@@ -1058,6 +1064,17 @@ extension AppDelegate: NSWindowRestoration {
private extension AppDelegate {
+ func applyUserInterfaceColorPalette() {
+ switch AppDefaults.userInterfaceColorPalette {
+ case .automatic:
+ NSApp.appearance = nil
+ case .light:
+ NSApp.appearance = NSAppearance(named: .aqua)
+ case .dark:
+ NSApp.appearance = NSAppearance(named: .darkAqua)
+ }
+ }
+
func handleMarkAsRead(userInfo: [AnyHashable: Any]) {
handleStatusNotification(userInfo: userInfo, statusKey: .read)
}
diff --git a/Mac/Preferences/Appearance/AppearancePreferencesViewController.swift b/Mac/Preferences/Appearance/AppearancePreferencesViewController.swift
index dac7e037a..f17fc6a07 100644
--- a/Mac/Preferences/Appearance/AppearancePreferencesViewController.swift
+++ b/Mac/Preferences/Appearance/AppearancePreferencesViewController.swift
@@ -51,6 +51,7 @@ final class AppearancePreferencesViewController: NSViewController {
override func viewWillAppear() {
super.viewWillAppear()
+ updateAppearancePopup()
updateArticleThemePopup()
}
@@ -64,8 +65,19 @@ final class AppearancePreferencesViewController: NSViewController {
updateArticleThemePopup()
}
+ @objc func handleUserInterfaceColorPaletteDidUpdate(_ notification: Notification) {
+ updateAppearancePopup()
+ }
+
// MARK: - Actions
+ @IBAction func appearancePopUpDidChange(_ sender: Any) {
+ guard let tag = appearancePopup?.selectedTag(), let colorPalette = UserInterfaceColorPalette(rawValue: tag) else {
+ return
+ }
+ AppDefaults.userInterfaceColorPalette = colorPalette
+ }
+
@IBAction func showThemesFolder(_ sender: Any) {
let url = URL(fileURLWithPath: ArticleThemesManager.shared.folderPath)
NSWorkspace.shared.open(url)
@@ -87,6 +99,7 @@ private extension AppearancePreferencesViewController {
func commonInit() {
NotificationCenter.default.addObserver(self, selector: #selector(handleApplicationWillBecomeActive(_:)), name: NSApplication.willBecomeActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleArticleThemeNamesDidChange(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(handleUserInterfaceColorPaletteDidUpdate(_:)), name: .userInterfaceColorPaletteDidUpdate, object: nil)
}
/// On macOS 15 the "Article Text Size:" label is vertically misaligned
@@ -120,6 +133,10 @@ private extension AppearancePreferencesViewController {
}
}
+ func updateAppearancePopup() {
+ appearancePopup?.selectItem(withTag: AppDefaults.userInterfaceColorPalette.rawValue)
+ }
+
func updateArticleThemePopup() {
guard let articleThemePopup, let menu = articleThemePopup.menu else {
return
diff --git a/Mac/Preferences/Appearance/Base.lproj/AppearancePreferencesView.xib b/Mac/Preferences/Appearance/Base.lproj/AppearancePreferencesView.xib
index 40d08178f..9397ed66f 100644
--- a/Mac/Preferences/Appearance/Base.lproj/AppearancePreferencesView.xib
+++ b/Mac/Preferences/Appearance/Base.lproj/AppearancePreferencesView.xib
@@ -59,6 +59,9 @@
+
+
+
diff --git a/Shared/AppDefaults.swift b/Shared/AppDefaults.swift
index bd521e5dd..1b8b30029 100644
--- a/Shared/AppDefaults.swift
+++ b/Shared/AppDefaults.swift
@@ -24,6 +24,7 @@ enum AppDefaults {
static let unreadCountDisplay = "unreadCountDisplay"
static let timelineThumbnailsDisplay = "timelineThumbnailsDisplay"
static let timelineFeedIconsDisplay = "timelineFeedIconsDisplay"
+ static let userInterfaceColorPalette = "userInterfaceColorPalette"
}
/// Registered by both platforms. Each platform’s registerDefaults adds its own.
@@ -34,7 +35,8 @@ enum AppDefaults {
Key.currentThemeName: defaultThemeName,
Key.articleContentJavascriptEnabled: true,
Key.timelineThumbnailsDisplay: TimelineThumbnailsDisplay.none.rawValue,
- Key.timelineFeedIconsDisplay: TimelineFeedIconsDisplay.automatic.rawValue
+ Key.timelineFeedIconsDisplay: TimelineFeedIconsDisplay.automatic.rawValue,
+ Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue
]
}
@@ -127,6 +129,16 @@ enum AppDefaults {
NotificationCenter.default.post(name: .timelineFeedIconsDisplayDidChange, object: nil)
}
}
+
+ static var userInterfaceColorPalette: UserInterfaceColorPalette {
+ get {
+ UserInterfaceColorPalette(rawValue: UserDefaults.standard.integer(forKey: Key.userInterfaceColorPalette)) ?? .automatic
+ }
+ set {
+ UserDefaults.standard.set(newValue.rawValue, forKey: Key.userInterfaceColorPalette)
+ NotificationCenter.default.post(name: .userInterfaceColorPaletteDidUpdate, object: nil)
+ }
+ }
}
// MARK: - Helpers
diff --git a/Shared/UserInterfaceColorPalette.swift b/Shared/UserInterfaceColorPalette.swift
new file mode 100644
index 000000000..736e20614
--- /dev/null
+++ b/Shared/UserInterfaceColorPalette.swift
@@ -0,0 +1,30 @@
+//
+// UserInterfaceColorPalette.swift
+// NetNewsWire
+//
+// Created by Brent Simmons on 11/6/26.
+//
+
+import Foundation
+
+extension Notification.Name {
+ static let userInterfaceColorPaletteDidUpdate = Notification.Name("UserInterfaceColorPaletteDidUpdateNotification")
+}
+
+/// Whether the app follows the system appearance or is forced to light or dark.
+enum UserInterfaceColorPalette: Int, CustomStringConvertible, CaseIterable {
+ case automatic = 0 // Follows the system
+ case light = 1
+ case dark = 2
+
+ var description: String {
+ switch self {
+ case .automatic:
+ NSLocalizedString("Automatic", comment: "Automatic")
+ case .light:
+ NSLocalizedString("Light", comment: "Light")
+ case .dark:
+ NSLocalizedString("Dark", comment: "Dark")
+ }
+ }
+}
diff --git a/iOS/AppDefaults+iOS.swift b/iOS/AppDefaults+iOS.swift
index 046d3a0be..efdb74fe6 100644
--- a/iOS/AppDefaults+iOS.swift
+++ b/iOS/AppDefaults+iOS.swift
@@ -13,31 +13,12 @@ import Account
import Articles
import Images
-enum UserInterfaceColorPalette: Int, CustomStringConvertible, CaseIterable {
- case automatic = 0
- case light = 1
- case dark = 2
-
- var description: String {
- switch self {
- case .automatic:
- NSLocalizedString("Automatic", comment: "Automatic")
- case .light:
- NSLocalizedString("Light", comment: "Light")
- case .dark:
- NSLocalizedString("Dark", comment: "Dark")
- }
- }
-}
-
extension Notification.Name {
- public static let userInterfaceColorPaletteDidUpdate = Notification.Name("UserInterfaceColorPaletteDidUpdateNotification")
public static let timelineIconSizeDidChange = Notification.Name("TimelineIconSizeDidChangeNotification")
public static let timelineNumberOfLinesDidChange = Notification.Name("TimelineNumberOfLinesDidChangeNotification")
}
extension AppDefaults.Key {
- static let userInterfaceColorPalette = "userInterfaceColorPalette"
static let refreshClearsReadArticles = "refreshClearsReadArticles"
static let timelineNumberOfLines = "timelineNumberOfLines"
static let timelineIconDimension = "timelineIconSize"
@@ -69,19 +50,6 @@ extension AppDefaults {
fileprivate static let logger = Logger(subsystem: Logger.nnwSubsystem, category: "AppDefaults")
- static var userInterfaceColorPalette: UserInterfaceColorPalette {
- get {
- if let result = UserInterfaceColorPalette(rawValue: UserDefaults.standard.integer(forKey: Key.userInterfaceColorPalette)) {
- return result
- }
- return .automatic
- }
- set {
- UserDefaults.standard.set(newValue.rawValue, forKey: Key.userInterfaceColorPalette)
- NotificationCenter.default.post(name: .userInterfaceColorPaletteDidUpdate, object: nil)
- }
- }
-
static var useSystemBrowser: Bool {
get {
UserDefaults.standard.bool(forKey: Key.useSystemBrowser)
@@ -341,7 +309,6 @@ extension AppDefaults {
migrateAppGroupDefaultsIfNeeded()
let platformDefaults: [String: Any] = [
- Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue,
Key.refreshClearsReadArticles: false,
Key.timelineNumberOfLines: 2,
Key.timelineIconDimension: IconSize.medium.rawValue,