diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 378204d91..eb30d3a90 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -30,6 +30,7 @@ final class AppDefaults: Sendable { static let timelineFontSize = "timelineFontSize" static let timelineSortDirection = "timelineSortDirection" static let timelineGroupByFeed = "timelineGroupByFeed" + static let useColumnLayout = "useColumnLayout" static let detailFontSize = "detailFontSize" static let openInBrowserInBackground = "openInBrowserInBackground" static let subscribeToFeedsInDefaultBrowser = "subscribeToFeedsInDefaultBrowser" @@ -268,11 +269,21 @@ final class AppDefaults: Sendable { // Sorting is per window and lives in TimelineWindowState. These two are read-only seeds // for a window that has no saved sort, so a setting from before per-window sorting carries over. var timelineSortDirection: ComparisonResult { - return AppDefaults.sortDirection(for: Key.timelineSortDirection) + AppDefaults.sortDirection(for: Key.timelineSortDirection) } var timelineGroupByFeed: Bool { - return AppDefaults.bool(for: Key.timelineGroupByFeed) + AppDefaults.bool(for: Key.timelineGroupByFeed) + } + + /// Column layout: multi-column timeline table with the article view below it, like Mail’s View > Use Column Layout. Applies to all windows. + var useColumnLayout: Bool { + get { + AppDefaults.bool(for: Key.useColumnLayout) + } + set { + AppDefaults.setBool(for: Key.useColumnLayout, newValue) + } } var timelineShowsSeparators: Bool { @@ -332,6 +343,7 @@ final class AppDefaults: Sendable { Key.detailFontSize: FontSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, Key.timelineGroupByFeed: false, + Key.useColumnLayout: false, "NSScrollViewShouldScrollUnderTitlebar": false, Key.refreshInterval: RefreshInterval.every2Hours.rawValue, Key.showDebugMenu: showDebugMenu, diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index f9983b60a..2ac97f037 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -52,6 +52,7 @@ let appName = "NetNewsWire" private var isShutDownSyncDone = false @IBOutlet var debugMenuItem: NSMenuItem! + @IBOutlet var useColumnLayoutMenuItem: NSMenuItem! @IBOutlet var checkForUpdatesMenuItem: NSMenuItem! var unreadCount = 0 { @@ -201,6 +202,8 @@ let appName = "NetNewsWire" DefaultFeedsImporter.importDefaultFeeds(account: localAccount) } + updateColumnLayoutMenuItem() + if mainWindowController == nil { let mainWindowController = createAndShowMainWindow() mainWindowController.restoreStateFromUserDefaults() @@ -387,6 +390,8 @@ let appName = "NetNewsWire" } func userDefaultsDidChange() { + updateColumnLayoutMenuItem() + if lastRefreshInterval != AppDefaults.shared.refreshInterval { refreshTimer?.update() lastRefreshInterval = AppDefaults.shared.refreshInterval @@ -738,6 +743,10 @@ let appName = "NetNewsWire" aboutWindowController?.window?.makeKeyAndOrderFront(nil) } + @IBAction func toggleColumnLayout(_ sender: Any?) { + AppDefaults.shared.useColumnLayout.toggle() + } + @IBAction func checkForUpdates(_ sender: Any?) { softwareUpdater?.checkForUpdates() } @@ -853,6 +862,10 @@ extension AppDelegate { dinosaurWindowController?.saveState() } + @MainActor func updateColumnLayoutMenuItem() { + useColumnLayoutMenuItem.state = AppDefaults.shared.useColumnLayout ? .on : .off + } + func importTheme(url: URL) { guard let window = mainWindowController?.window else { return } diff --git a/Mac/MainMenu/Base.lproj/MainMenu.xib b/Mac/MainMenu/Base.lproj/MainMenu.xib index 30adc8988..e1293517f 100644 --- a/Mac/MainMenu/Base.lproj/MainMenu.xib +++ b/Mac/MainMenu/Base.lproj/MainMenu.xib @@ -16,6 +16,7 @@ + @@ -406,6 +407,12 @@ + + + + + + diff --git a/Mac/MainMenu/mul.lproj/MainMenu.xcstrings b/Mac/MainMenu/mul.lproj/MainMenu.xcstrings index def38c4ea..da67bd46f 100644 --- a/Mac/MainMenu/mul.lproj/MainMenu.xcstrings +++ b/Mac/MainMenu/mul.lproj/MainMenu.xcstrings @@ -1945,6 +1945,24 @@ } } }, + "ucL-ay-0ut.title" : { + "comment" : "Class = \"NSMenuItem\"; title = \"Use Column Layout\"; ObjectID = \"ucL-ay-0ut\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Use Column Layout" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Usar disposición en columnas" + } + } + } + }, "UEZ-Bs-lqG.title" : { "comment" : "Class = \"NSMenuItem\"; title = \"Capitalize\"; ObjectID = \"UEZ-Bs-lqG\";", "extractionState" : "extracted_with_value", diff --git a/Shared/Timeline/ArticleArray.swift b/Shared/Timeline/ArticleArray.swift index 4c0d1bb97..b4e552895 100644 --- a/Shared/Timeline/ArticleArray.swift +++ b/Shared/Timeline/ArticleArray.swift @@ -59,7 +59,7 @@ typealias ArticleArray = [Article] } func sorted(by parameters: ArticleSortParameters) -> ArticleArray { - return ArticleSorter.sorted(articles: self, parameters: parameters) + ArticleSorter.sorted(articles: self, parameters: parameters) } func canMarkAllAsRead() -> Bool {