Add separator for timeline and make buttons stateful

This commit is contained in:
Maurice Parker 2020-08-09 06:02:48 -05:00
parent 57d988da95
commit afe8d23365
5 changed files with 207 additions and 6 deletions

View File

@ -127,10 +127,30 @@ struct AppAssets {
}
}()
@available(macOS 10.16, *)
static var readClosedImage: RSImage = {
return NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)!
}()
@available(macOS 10.16, *)
static var readOpenImage: RSImage = {
return NSImage(systemSymbolName: "circle", accessibilityDescription: nil)!
}()
static var searchFeedImage: IconImage = {
return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true)
}()
@available(macOS 10.16, *)
static var starClosedImage: RSImage = {
return NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)!
}()
@available(macOS 10.16, *)
static var starOpenImage: RSImage = {
return NSImage(systemSymbolName: "star", accessibilityDescription: nil)!
}()
static var starredFeedImage: IconImage = {
if #available(macOS 10.16, *) {
let image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)!

View File

@ -4,6 +4,7 @@
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17147"/>
<capability name="NSView safe area layout guides" minToolsVersion="12.0"/>
<capability name="Search Toolbar Item" minToolsVersion="12.0" minSystemVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -269,12 +270,151 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<toolbar key="toolbar" implicitIdentifier="F82AF654-C4E7-4D89-8DD6-35FB7FC7405A" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="4wH-0N-M2I">
<toolbar key="toolbar" implicitIdentifier="F82AF654-C4E7-4D89-8DD6-35FB7FC7405A" displayMode="iconOnly" sizeMode="regular" id="4wH-0N-M2I">
<allowedToolbarItems>
<toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="NkL-XI-XbY"/>
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="1rv-ob-E5Y"/>
<toolbarItem implicitItemIdentifier="85D5559D-7E93-4640-B490-E45FCC6DEEFC" label="Mark All as Read" paletteLabel="Mark All as Read" toolTip="Mark All as Read" image="markAllAsRead" sizingBehavior="auto" id="kCl-RN-C8U" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="pma-GT-lQ6">
<rect key="frame" x="29" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="markAllAsRead" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="TPq-5K-4FI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="markAllAsRead:" target="oDX-XL-3t0" id="ZJZ-f1-VpE"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="E0330BEC-A31C-4734-9E98-DC684AE0188B" label="Mark Read" paletteLabel="Mark Read" toolTip="Mark Read or Unread" image="circle" catalog="system" sizingBehavior="auto" id="aBG-KW-0rC" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="ogU-Zg-MEq">
<rect key="frame" x="13" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="circle" catalog="system" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="S9F-pa-vC7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="toggleRead:" target="RpU-Uf-KSH" id="vmC-mT-McD"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="7F38EDBC-3754-4A46-B1C5-ECCA6FA0E2EB" label="Refresh" paletteLabel="Refresh" toolTip="Refresh" image="arrow.clockwise" catalog="system" sizingBehavior="auto" id="saA-2q-Exi" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="NOF-FH-5ht">
<rect key="frame" x="5" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="arrow.clockwise" catalog="system" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="bev-B0-Rm9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="refreshAll:" target="oDX-XL-3t0" id="fAJ-7N-WHH"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="98FE3AB9-1527-442F-A2AD-37A16D281F6C" label="Reader" paletteLabel="Reader" toolTip="Reader View" sizingBehavior="auto" id="z8Y-kH-YkM" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="Gj7-2v-wnj" customClass="ArticleExtractorButton" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="3" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Fcj-WC-4ef">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="toggleArticleExtractor:" target="B8D-0N-5wS" id="VGv-tQ-zSw"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="5E605EAD-F9C6-46B1-AB4A-4F8B41EA8D71" label="Clean UP" paletteLabel="Clean Up" toolTip="Clean Up" image="cleanUp" sizingBehavior="auto" id="gbb-1C-xgT" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="3mT-0D-slf">
<rect key="frame" x="12" y="14" width="32" height="23"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="cleanUp" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="c2Z-gF-mZk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="cleanUp:" target="oDX-XL-3t0" id="ZI7-sh-FxF"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="D843F871-CE3E-4562-864D-468D253F7017" label="Next Unread" paletteLabel="Next Unread" toolTip="Go to Next Unread" image="chevron.down.circle" catalog="system" sizingBehavior="auto" id="Em1-AN-RSV" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="f65-dC-yVw" customClass="RSDarkModeAdaptingToolbarButton" customModule="RSCore">
<rect key="frame" x="18" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="chevron.down.circle" catalog="system" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="20M-ji-Qfb">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="nextUnread:" target="oDX-XL-3t0" id="Njy-rJ-nwV"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="DF97E70F-6C5A-4E11-8F23-F92C0DFDD20C" label="Star" paletteLabel="Star" toolTip="Star or Unstar" image="star" catalog="system" sizingBehavior="auto" id="w0G-8M-ORk" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="PH8-Ep-8RY">
<rect key="frame" x="0.0" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="star" catalog="system" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="Dwm-37-obJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="toggleStarred:" target="oDX-XL-3t0" id="8CC-3h-U4D"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="0C1590CE-2F2C-4B1C-B8E2-FB95E26B3247" label="Open in Browser" paletteLabel="Open in Browser" toolTip="Open in Browser" image="safari" catalog="system" sizingBehavior="auto" id="r1w-Ep-Fxv" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" allowsExpansionToolTips="YES" id="0qi-r3-cJ7">
<rect key="frame" x="28" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="safari" catalog="system" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="upn-Uv-4pt">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="openArticleInBrowser:" target="oDX-XL-3t0" id="llu-Yi-oJ3"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="5DC1C687-AF4A-477B-BACD-C28FA65145B8" explicitItemIdentifier="share" label="Share" paletteLabel="Share" toolTip="Share" image="square.and.arrow.up" catalog="system" sizingBehavior="auto" id="G63-IG-tKX" customClass="RSToolbarItem" customModule="RSCore">
<button key="view" verticalHuggingPriority="750" id="BDf-kK-Izc">
<rect key="frame" x="0.0" y="14" width="38" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="square.and.arrow.up" catalog="system" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="4zk-xN-QSG">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="toolbarShowShareMenu:" target="oDX-XL-3t0" id="Jnn-YA-XUu"/>
</connections>
</toolbarItem>
<searchToolbarItem implicitItemIdentifier="B7230336-8AEE-41E4-A45A-97033AE39514" label="Search" paletteLabel="Search" id="ZKI-Wi-Azg">
<nil key="toolTip"/>
<searchField key="view" verticalHuggingPriority="750" textCompletion="NO" id="dKj-A6-Jhr">
<rect key="frame" x="0.0" y="0.0" width="100" height="21"/>
<autoresizingMask key="autoresizingMask"/>
<searchFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" usesSingleLineMode="YES" bezelStyle="round" sendsSearchStringImmediately="YES" id="mWX-qu-TTX">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</searchFieldCell>
</searchField>
</searchToolbarItem>
</allowedToolbarItems>
<defaultToolbarItems/>
<defaultToolbarItems>
<searchToolbarItem reference="ZKI-Wi-Azg"/>
<toolbarItem reference="kCl-RN-C8U"/>
<toolbarItem reference="saA-2q-Exi"/>
<toolbarItem reference="1rv-ob-E5Y"/>
<toolbarItem reference="Em1-AN-RSV"/>
<toolbarItem reference="aBG-KW-0rC"/>
<toolbarItem reference="w0G-8M-ORk"/>
<toolbarItem reference="r1w-Ep-Fxv"/>
<toolbarItem reference="G63-IG-tKX"/>
</defaultToolbarItems>
<connections>
<outlet property="delegate" destination="RpU-Uf-KSH" id="676-nf-53M"/>
</connections>
@ -289,7 +429,7 @@
</windowController>
<customObject id="oDX-XL-3t0" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1309" y="401"/>
<point key="canvasLocation" x="-1472" y="394"/>
</scene>
<!--View Controller-->
<scene sceneID="ZPA-jO-OkH">
@ -663,13 +803,20 @@
<image name="NSAddTemplate" width="15" height="13"/>
<image name="NSRefreshTemplate" width="14" height="16"/>
<image name="NSShareTemplate" width="16" height="17"/>
<image name="arrow.clockwise" catalog="system" width="14" height="16"/>
<image name="chevron.down.circle" catalog="system" width="15" height="15"/>
<image name="circle" catalog="system" width="15" height="15"/>
<image name="cleanUp" width="149" height="113"/>
<image name="filterInactive" width="100" height="101"/>
<image name="markAllAsRead" width="13" height="20"/>
<image name="markAllRead" width="22" height="19"/>
<image name="markRead" width="19" height="19"/>
<image name="newFolder" width="19" height="19"/>
<image name="nextUnread" width="24" height="19"/>
<image name="openInBrowser" width="19" height="19"/>
<image name="safari" catalog="system" width="15" height="15"/>
<image name="square.and.arrow.up" catalog="system" width="16" height="17"/>
<image name="star" catalog="system" width="17" height="16"/>
<image name="star" width="19" height="19"/>
</resources>
</document>

View File

@ -62,6 +62,11 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
sharingServicePickerDelegate = SharingServicePickerDelegate(self.window)
if #available(macOS 10.16, *) {
DispatchQueue.main.async {
if self.window?.toolbar?.existingItem(withIdentifier: .TrackingSeparator) == nil {
self.window?.toolbar?.insertItem(withItemIdentifier: .TrackingSeparator, at: 2)
}
}
} else {
if !AppDefaults.shared.showTitleOnMainWindow {
window?.titleVisibility = .hidden
@ -687,12 +692,20 @@ extension MainWindowController : ScriptingMainWindowController {
// MARK: - NSToolbarDelegate
extension NSToolbarItem.Identifier {
static let TrackingSeparator = NSToolbarItem.Identifier("trackingSeparator")
static let Share = NSToolbarItem.Identifier("share")
static let Search = NSToolbarItem.Identifier("search")
}
extension MainWindowController: NSToolbarDelegate {
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
if #available(macOS 10.16, *), itemIdentifier == .TrackingSeparator {
return NSTrackingSeparatorToolbarItem(identifier: .TrackingSeparator, splitView: splitViewController!.splitView, dividerIndex: 1)
}
return nil
}
func toolbarWillAddItem(_ notification: Notification) {
guard let item = notification.userInfo?["item"] as? NSToolbarItem else {
return
@ -831,6 +844,10 @@ private extension MainWindowController {
menuItem.title = commandName
}
if #available(macOS 10.16, *), let toolbarItem = item as? NSToolbarItem, let button = toolbarItem.view as? NSButton {
button.image = markingRead ? AppAssets.readClosedImage : AppAssets.readOpenImage
}
return result
}
@ -908,15 +925,16 @@ private extension MainWindowController {
if let toolbarItem = item as? NSToolbarItem {
toolbarItem.toolTip = commandName
// if let button = toolbarItem.view as? NSButton {
// button.image = NSImage(named: starring ? .star : .unstar)
// }
}
if let menuItem = item as? NSMenuItem {
menuItem.title = commandName
}
if #available(macOS 10.16, *), let toolbarItem = item as? NSToolbarItem, let button = toolbarItem.view as? NSButton {
button.image = starring ? AppAssets.starOpenImage : AppAssets.starClosedImage
}
return result
}

View File

@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "markAllAsRead.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}