From a91927dd9e1bff0947986cebddbb515b50e17536 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 2 Nov 2024 11:32:52 -0700 Subject: [PATCH] Require macOS 14. Remove unneeded uses of #available. --- Mac/AppAssets.swift | 127 +--- Mac/AppDelegate.swift | 30 +- Mac/Base.lproj/MainWindow.storyboard | 619 ------------------ Mac/Base.lproj/UnifiedWindow.storyboard | 22 +- ...ltinSmartFeedInspectorViewController.swift | 4 +- .../FolderInspectorViewController.swift | 8 +- Mac/MainWindow/Detail/DetailWebView.swift | 50 +- .../Detail/DetailWebViewController.swift | 5 +- Mac/MainWindow/MainWindowController.swift | 456 +++++-------- .../Sidebar/Cell/SidebarCellAppearance.swift | 6 +- .../Cell/TimelineCellAppearance.swift | 6 +- .../Timeline/TimelineTableRowView.swift | 23 +- .../Timeline/TimelineViewController.swift | 5 +- ...AccountsFeedWranglerWindowController.swift | 9 +- .../AccountsFeedbinWindowController.swift | 2 - .../AccountsNewsBlurWindowController.swift | 9 +- .../AccountsReaderAPIWindowController.swift | 9 +- NetNewsWire.xcodeproj/project.pbxproj | 12 - Shared/Extensions/NSView-Extensions.swift | 19 +- xcconfig/NetNewsWire_project.xcconfig | 2 +- .../NetNewsWire_mac_target_common.xcconfig | 5 +- 21 files changed, 277 insertions(+), 1151 deletions(-) delete mode 100644 Mac/Base.lproj/MainWindow.storyboard diff --git a/Mac/AppAssets.swift b/Mac/AppAssets.swift index 94725f96d..15935d317 100644 --- a/Mac/AppAssets.swift +++ b/Mac/AppAssets.swift @@ -92,19 +92,11 @@ struct AppAssets { }() static var filterActive: RSImage = { - if #available(macOS 11.0, *) { - return NSImage(systemSymbolName: "line.horizontal.3.decrease.circle.fill", accessibilityDescription: nil)! - } else { - return RSImage(named: "filterActive")! - } + return NSImage(systemSymbolName: "line.horizontal.3.decrease.circle.fill", accessibilityDescription: nil)! }() static var filterInactive: RSImage = { - if #available(macOS 11.0, *) { - return NSImage(systemSymbolName: "line.horizontal.3.decrease.circle", accessibilityDescription: nil)! - } else { - return RSImage(named: "filterInactive")! - } + return NSImage(systemSymbolName: "line.horizontal.3.decrease.circle", accessibilityDescription: nil)! }() static var iconLightBackgroundColor: NSColor = { @@ -148,14 +140,10 @@ struct AppAssets { }() static var masterFolderImage: IconImage { - if #available(macOS 11.0, *) { - let image = NSImage(systemSymbolName: "folder", accessibilityDescription: nil)! - let preferredColor = NSColor(named: "AccentColor")! - let coloredImage = image.tinted(with: preferredColor) - return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) - } else { - return IconImage(RSImage(named: NSImage.folderName)!) - } + let image = NSImage(systemSymbolName: "folder", accessibilityDescription: nil)! + let preferredColor = NSColor(named: "AccentColor")! + let coloredImage = image.tinted(with: preferredColor) + return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) } static var markAllAsReadImage: RSImage = { @@ -173,48 +161,29 @@ struct AppAssets { }() static var preferencesToolbarAccountsImage: RSImage = { - if #available(macOS 11.0, *) { - return NSImage(systemSymbolName: "at", accessibilityDescription: nil)! - } else { - return NSImage(named: NSImage.userAccountsName)! - } + return NSImage(systemSymbolName: "at", accessibilityDescription: nil)! }() static var preferencesToolbarExtensionsImage: RSImage = { - if #available(macOS 11.0, *) { - return RSImage(named: "preferencesToolbarExtensions")! - } else { - return NSImage(contentsOfFile: "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/KEXT.icns")! - } + return RSImage(named: "preferencesToolbarExtensions")! }() static var preferencesToolbarGeneralImage: RSImage = { - if #available(macOS 11.0, *) { - return NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil)! - } else { - return NSImage(named: NSImage.preferencesGeneralName)! - } + return NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil)! }() static var preferencesToolbarAdvancedImage: RSImage = { - if #available(macOS 11.0, *) { - return NSImage(systemSymbolName: "gearshape.2", accessibilityDescription: nil)! - } else { - return NSImage(named: NSImage.advancedName)! - } + return NSImage(systemSymbolName: "gearshape.2", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var readClosedImage: RSImage = { return NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var readOpenImage: RSImage = { return NSImage(systemSymbolName: "circle", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var refreshImage: RSImage = { return NSImage(systemSymbolName: "arrow.clockwise", accessibilityDescription: nil)! }() @@ -223,35 +192,27 @@ struct AppAssets { return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true, isBackgroundSupressed: true) }() - @available(macOS 11.0, *) static var shareImage: RSImage = { return NSImage(systemSymbolName: "square.and.arrow.up", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var sidebarToggleImage: RSImage = { return NSImage(systemSymbolName: "sidebar.left", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var starClosedImage: RSImage = { return NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)! }() - @available(macOS 11.0, *) static var starOpenImage: RSImage = { return NSImage(systemSymbolName: "star", accessibilityDescription: nil)! }() - + static var starredFeedImage: IconImage = { - if #available(macOS 11.0, *) { - let image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)! - let preferredColor = NSColor(named: "StarColor")! - let coloredImage = image.tinted(with: preferredColor) - return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) - } else { - return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isBackgroundSupressed: true) - } + let image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)! + let preferredColor = NSColor(named: "StarColor")! + let coloredImage = image.tinted(with: preferredColor) + return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) }() static var timelineSeparatorColor: NSColor = { @@ -267,63 +228,37 @@ struct AppAssets { }() static var todayFeedImage: IconImage = { - if #available(macOS 11.0, *) { - let image = NSImage(systemSymbolName: "sun.max.fill", accessibilityDescription: nil)! - let preferredColor = NSColor.orange - let coloredImage = image.tinted(with: preferredColor) - return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) - } else { - return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isBackgroundSupressed: true) - } + let image = NSImage(systemSymbolName: "sun.max.fill", accessibilityDescription: nil)! + let preferredColor = NSColor.orange + let coloredImage = image.tinted(with: preferredColor) + return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) }() static var unreadFeedImage: IconImage = { - if #available(macOS 11.0, *) { - let image = NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)! - let preferredColor = NSColor(named: "AccentColor")! - let coloredImage = image.tinted(with: preferredColor) - return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) - } else { - return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isBackgroundSupressed: true) - } + let image = NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)! + let preferredColor = NSColor(named: "AccentColor")! + let coloredImage = image.tinted(with: preferredColor) + return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor) }() static var swipeMarkReadImage: RSImage = { - if #available(OSX 11.0, *) { - return RSImage(systemSymbolName: "circle", accessibilityDescription: "Mark Read")! - .withSymbolConfiguration(.init(scale: .large))! - } else { - // TODO: remove swipeMarkRead asset when dropping support for macOS 10.15 - return RSImage(named: "swipeMarkRead")! - } + return RSImage(systemSymbolName: "circle", accessibilityDescription: "Mark Read")! + .withSymbolConfiguration(.init(scale: .large))! }() static var swipeMarkUnreadImage: RSImage = { - if #available(OSX 11.0, *) { - return RSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: "Mark Unread")! - .withSymbolConfiguration(.init(scale: .large))! - } else { - // TODO: remove swipeMarkUnread asset when dropping support for macOS 10.15 - return RSImage(named: "swipeMarkUnread")! - } + return RSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: "Mark Unread")! + .withSymbolConfiguration(.init(scale: .large))! }() static var swipeMarkStarredImage: RSImage = { - if #available(OSX 11.0, *) { - return RSImage(systemSymbolName: "star.fill", accessibilityDescription: "Star")! - .withSymbolConfiguration(.init(scale: .large))! - } else { - return RSImage(named: "swipeMarkStarred")! - } + return RSImage(systemSymbolName: "star.fill", accessibilityDescription: "Star")! + .withSymbolConfiguration(.init(scale: .large))! }() static var swipeMarkUnstarredImage: RSImage = { - if #available(OSX 11.0, *) { - return RSImage(systemSymbolName: "star", accessibilityDescription: "Unstar")! - .withSymbolConfiguration(.init(scale: .large))! - } else { - return RSImage(named: "swipeMarkUnstarred")! - } + return RSImage(systemSymbolName: "star", accessibilityDescription: "Unstar")! + .withSymbolConfiguration(.init(scale: .large))! }() static var starColor: NSColor = { diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index ab9056c67..e9c2ff9b8 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -394,13 +394,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, // MARK: Main Window func createMainWindowController() -> MainWindowController { - let controller: MainWindowController - if #available(macOS 11.0, *) { - controller = windowControllerWithName("UnifiedWindow") as! MainWindowController - } else { - controller = windowControllerWithName("MainWindow") as! MainWindowController - } - + let controller: MainWindowController = windowControllerWithName("UnifiedWindow") as! MainWindowController + if !(mainWindowController?.isOpen ?? false) { mainWindowControllers.removeAll() } @@ -800,30 +795,19 @@ internal extension AppDelegate { attrs[.font] = NSFont.systemFont(ofSize: NSFont.smallSystemFontSize) attrs[.foregroundColor] = NSColor.textColor - if #available(macOS 11.0, *) { - let titleParagraphStyle = NSMutableParagraphStyle() - titleParagraphStyle.alignment = .center - attrs[.paragraphStyle] = titleParagraphStyle - } + let titleParagraphStyle = NSMutableParagraphStyle() + titleParagraphStyle.alignment = .center + attrs[.paragraphStyle] = titleParagraphStyle let websiteText = NSMutableAttributedString() websiteText.append(NSAttributedString(string: NSLocalizedString("Author‘s website:", comment: "Author's Website"), attributes: attrs)) - if #available(macOS 11.0, *) { - websiteText.append(NSAttributedString(string: "\n")) - } else { - websiteText.append(NSAttributedString(string: " ")) - } + websiteText.append(NSAttributedString(string: "\n")) attrs[.link] = theme.creatorHomePage websiteText.append(NSAttributedString(string: theme.creatorHomePage, attributes: attrs)) - let textViewWidth: CGFloat - if #available(macOS 11.0, *) { - textViewWidth = 200 - } else { - textViewWidth = 400 - } + let textViewWidth: CGFloat = 200 let textView = NSTextView(frame: CGRect(x: 0, y: 0, width: textViewWidth, height: 15)) textView.isEditable = false diff --git a/Mac/Base.lproj/MainWindow.storyboard b/Mac/Base.lproj/MainWindow.storyboard deleted file mode 100644 index 3b6350a2a..000000000 --- a/Mac/Base.lproj/MainWindow.storyboard +++ /dev/null @@ -1,619 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mac/Base.lproj/UnifiedWindow.storyboard b/Mac/Base.lproj/UnifiedWindow.storyboard index 2a537adbc..e53e9b398 100644 --- a/Mac/Base.lproj/UnifiedWindow.storyboard +++ b/Mac/Base.lproj/UnifiedWindow.storyboard @@ -1,8 +1,8 @@ - + - + @@ -90,13 +90,13 @@ - + - + @@ -119,7 +119,7 @@ - + @@ -174,7 +174,7 @@ -