From 7619f4470bd014628127f80eee2bec53d6a40d5e Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 10 Aug 2020 09:45:48 -0500 Subject: [PATCH] Add article toolbar items --- Mac/AppAssets.swift | 20 ++++++++++ Mac/MainWindow/MainWindowController.swift | 48 +++++++++++++++++------ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/Mac/AppAssets.swift b/Mac/AppAssets.swift index c713dff5d..eb1e03336 100644 --- a/Mac/AppAssets.swift +++ b/Mac/AppAssets.swift @@ -77,6 +77,11 @@ struct AppAssets { return RSImage(named: "articleExtractorProgress4") }() + @available(macOS 10.16, *) + static var cleanUpImage: RSImage = { + return NSImage(systemSymbolName: "wind", accessibilityDescription: nil)! + }() + static var extensionPointMarsEdit: RSImage = { return RSImage(named: "extensionPointMarsEdit")! }() @@ -131,6 +136,16 @@ struct AppAssets { return RSImage(named: "markAllAsRead")! }() + @available(macOS 10.16, *) + static var nextUnreadImage: RSImage = { + return NSImage(systemSymbolName: "chevron.down.circle", accessibilityDescription: nil)! + }() + + @available(macOS 10.16, *) + static var openInBrowserImage: RSImage = { + return NSImage(systemSymbolName: "safari", accessibilityDescription: nil)! + }() + @available(macOS 10.16, *) static var readClosedImage: RSImage = { return NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)! @@ -149,6 +164,11 @@ struct AppAssets { static var searchFeedImage: IconImage = { return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true) }() + + @available(macOS 10.16, *) + static var shareImage: RSImage = { + return NSImage(systemSymbolName: "square.and.arrow.up", accessibilityDescription: nil)! + }() @available(macOS 10.16, *) static var starClosedImage: RSImage = { diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index c1b28cc84..a4aec3a35 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -65,7 +65,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { DispatchQueue.main.async { let toolbar = NSToolbar(identifier: "MainWindowToolbar") toolbar.allowsUserCustomization = true -// toolbar.autosavesConfiguration = true + toolbar.autosavesConfiguration = true toolbar.displayMode = .iconOnly toolbar.delegate = self self.window?.toolbar = toolbar @@ -745,6 +745,30 @@ extension MainWindowController: NSToolbarDelegate { case .timelineTrackingSeparator: return NSTrackingSeparatorToolbarItem(identifier: .timelineTrackingSeparator, splitView: splitViewController!.splitView, dividerIndex: 1) + case .nextUnread: + let title = NSLocalizedString("Next Unread", comment: "Next Unread") + return toolbarButton(.nextUnread, title, AppAssets.nextUnreadImage, "nextUnread:") + + case .markRead: + let title = NSLocalizedString("Mark Read", comment: "Mark Read") + return toolbarButton(.markRead, title, AppAssets.readClosedImage, "toggleRead:") + + case .markStar: + let title = NSLocalizedString("Star", comment: "Star") + return toolbarButton(.markStar, title, AppAssets.starOpenImage, "toggleStarred:") + + case .openInBrowser: + let title = NSLocalizedString("Open in Browser", comment: "Open in Browser") + return toolbarButton(.openInBrowser, title, AppAssets.openInBrowserImage, "openArticleInBrowser:") + + case .share: + let title = NSLocalizedString("Share", comment: "Share") + return toolbarButton(.share, title, AppAssets.shareImage, "toolbarShowShareMenu:") + + case .cleanUp: + let title = NSLocalizedString("Clean Up", comment: "Clean Up") + return toolbarButton(.cleanUp, title, AppAssets.cleanUpImage, "cleanUp:") + default: break } @@ -764,12 +788,12 @@ extension MainWindowController: NSToolbarDelegate { .markAllAsRead, .timelineTrackingSeparator, .flexibleSpace, -// .nextUnread, -// .markRead, -// .markStar, -// .openInBrowser, -// .share, -// .cleanUp + .nextUnread, + .markRead, + .markStar, + .openInBrowser, + .share, + .cleanUp ] } else { return [ @@ -801,11 +825,11 @@ extension MainWindowController: NSToolbarDelegate { .markAllAsRead, .timelineTrackingSeparator, .flexibleSpace, -// .nextUnread, -// .markRead, -// .markStar, -// .openInBrowser, -// .share + .nextUnread, + .markRead, + .markStar, + .openInBrowser, + .share ] } else { return [