Make mark-as-starred menu item work; make it validate; change its name as needed.

This commit is contained in:
Brent Simmons 2018-02-17 12:01:14 -08:00
parent ce5b60cfe8
commit 21f262e953
5 changed files with 40 additions and 17 deletions

View File

@ -0,0 +1,22 @@
//
// MarkCommandValidationStatus.swift
// Evergreen
//
// Created by Brent Simmons on 2/17/18.
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import Foundation
enum MarkCommandValidationStatus {
case canMark, canUnmark, canDoNothing
static func statusFor(_ articles: ArticleArray, _ canMarkTest: ((ArticleArray) -> Bool)) -> MarkCommandValidationStatus {
if articles.isEmpty {
return .canDoNothing
}
return canMarkTest(articles) ? .canMark : .canUnmark
}
}

View File

@ -16,6 +16,7 @@
840D61962029031D009BC708 /* Evergreen_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61952029031D009BC708 /* Evergreen_iOSTests.swift */; };
840D61A12029031E009BC708 /* Evergreen_iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61A02029031E009BC708 /* Evergreen_iOSUITests.swift */; };
8414AD251FCF5A1E00955102 /* TimelineHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */; };
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
841ABA6020145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */; };
@ -532,6 +533,7 @@
840D61A02029031E009BC708 /* Evergreen_iOSUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Evergreen_iOSUITests.swift; sourceTree = "<group>"; };
840D61A22029031E009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineHeaderView.swift; sourceTree = "<group>"; };
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.swift; sourceTree = "<group>"; };
841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderInspectorViewController.swift; sourceTree = "<group>"; };
841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltinSmartFeedInspectorViewController.swift; sourceTree = "<group>"; };
@ -899,6 +901,7 @@
isa = PBXGroup;
children = (
84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */,
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */,
84B99C9C1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift */,
84A1500220048D660046AD9A /* SendToCommand.swift */,
84A14FF220048CA70046AD9A /* SendToMicroBlogCommand.swift */,
@ -1918,6 +1921,7 @@
849A97651ED9EB96007D329B /* SidebarTreeControllerDelegate.swift in Sources */,
849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */,
8426118A1FCB67AA0086A189 /* FeedIconDownloader.swift in Sources */,
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */,
84E95D241FB1087500552D99 /* ArticlePasteboardWriter.swift in Sources */,
849A975B1ED9EB0D007D329B /* ArticleUtilities.swift in Sources */,
84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */,

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14092" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14092"/>
</dependencies>
<scenes>
<!--Application-->
@ -426,7 +426,11 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gB0-WX-2Gd"/>
<menuItem title="Mark as Starred" keyEquivalent="L" id="vvo-ZM-8kl"/>
<menuItem title="Mark as Starred" keyEquivalent="L" id="vvo-ZM-8kl">
<connections>
<action selector="toggleStarred:" target="Ady-hI-5gd" id="vIK-kP-re7"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="qgr-Gl-Xhw"/>
<menuItem title="Open in Browser" keyEquivalent="" id="4iQ-1v-dTa">
<connections>

View File

@ -205,13 +205,19 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
result = false
}
let commandName = starring ? NSLocalizedString("Mark as Starred", comment: "Command") : NSLocalizedString("Mark as Unstarred", comment: "Command")
if let toolbarItem = item as? NSToolbarItem {
toolbarItem.toolTip = starring ? NSLocalizedString("Mark as Starred", comment: "Command") : NSLocalizedString("Mark as Unstarred", comment: "Command")
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
}
return result
}

View File

@ -12,19 +12,6 @@ import RSTextDrawing
import Data
import Account
enum MarkCommandValidationStatus {
case canMark, canUnmark, canDoNothing
static func statusFor(_ articles: ArticleArray, _ canMarkTest: ((ArticleArray) -> Bool)) -> MarkCommandValidationStatus {
if articles.isEmpty {
return .canDoNothing
}
return canMarkTest(articles) ? .canMark : .canUnmark
}
}
class TimelineViewController: NSViewController, UndoableCommandRunner {
@IBOutlet var tableView: TimelineTableView!