Create and use AppImages.swift for widely-referenced images.

This commit is contained in:
Brent Simmons 2018-02-17 18:19:25 -08:00
parent 58a1a92481
commit 9d39ae2de4
8 changed files with 32 additions and 15 deletions

View File

@ -99,6 +99,7 @@
849C64681ED37A5D003D8FC0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 849C64671ED37A5D003D8FC0 /* Assets.xcassets */; };
849C646B1ED37A5D003D8FC0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849C64691ED37A5D003D8FC0 /* Main.storyboard */; };
849C64761ED37A5D003D8FC0 /* EvergreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849C64751ED37A5D003D8FC0 /* EvergreenTests.swift */; };
849EE70F203919360082A1EA /* AppImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849EE70E203919360082A1EA /* AppImages.swift */; };
84A14FF320048CA70046AD9A /* SendToMicroBlogCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84A14FF220048CA70046AD9A /* SendToMicroBlogCommand.swift */; };
84A1500320048D660046AD9A /* SendToCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84A1500220048D660046AD9A /* SendToCommand.swift */; };
84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84A1500420048DDF0046AD9A /* SendToMarsEditCommand.swift */; };
@ -621,6 +622,7 @@
849C64711ED37A5D003D8FC0 /* EvergreenTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EvergreenTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
849C64751ED37A5D003D8FC0 /* EvergreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EvergreenTests.swift; sourceTree = "<group>"; };
849C64771ED37A5D003D8FC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
849EE70E203919360082A1EA /* AppImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppImages.swift; path = Evergreen/AppImages.swift; sourceTree = "<group>"; };
84A14FF220048CA70046AD9A /* SendToMicroBlogCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendToMicroBlogCommand.swift; sourceTree = "<group>"; };
84A1500220048D660046AD9A /* SendToCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendToCommand.swift; sourceTree = "<group>"; };
84A1500420048DDF0046AD9A /* SendToMarsEditCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendToMarsEditCommand.swift; sourceTree = "<group>"; };
@ -1098,6 +1100,7 @@
849C64631ED37A5D003D8FC0 /* AppDelegate.swift */,
84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */,
842E45CD1ED8C308000A8B52 /* AppNotifications.swift */,
849EE70E203919360082A1EA /* AppImages.swift */,
84DAEE311F870B390058304B /* DockBadge.swift */,
842E45DC1ED8C54B000A8B52 /* Browser.swift */,
84702AB31FA27AE8006B8943 /* Commands */,
@ -1949,6 +1952,7 @@
845EE7B11FC2366500854A1F /* StarredFeedDelegate.swift in Sources */,
848F6AE51FC29CFB002D422E /* FaviconDownloader.swift in Sources */,
849A97981ED9EFAA007D329B /* Node-Extensions.swift in Sources */,
849EE70F203919360082A1EA /* AppImages.swift in Sources */,
849A97531ED9EAC0007D329B /* AddFeedController.swift in Sources */,
84AAF2BF202CF684004A0BC4 /* TimelineContextualMenuDelegate.swift in Sources */,
849A97831ED9EC63007D329B /* SidebarStatusBarView.swift in Sources */,

View File

@ -31,12 +31,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
@IBOutlet var sortByOldestArticleOnTopMenuItem: NSMenuItem!
@IBOutlet var sortByNewestArticleOnTopMenuItem: NSMenuItem!
lazy var genericFeedImage: NSImage? = {
let path = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns"
let image = NSImage(contentsOfFile: path)
return image
}()
lazy var sendToCommands: [SendToCommand] = {
return [SendToMicroBlogCommand(), SendToMarsEditCommand()]
}()

23
Evergreen/AppImages.swift Normal file
View File

@ -0,0 +1,23 @@
//
// AppImages.swift
// Evergreen
//
// Created by Brent Simmons on 2/17/18.
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import AppKit
extension NSImage.Name {
static let star = NSImage.Name(rawValue: "star")
static let unstar = NSImage.Name(rawValue: "unstar")
}
struct AppImages {
static var genericFeedImage: NSImage? = {
let path = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns"
let image = NSImage(contentsOfFile: path)
return image
}()
}

View File

@ -159,7 +159,7 @@ private extension FeedListViewController {
if let image = appDelegate.faviconDownloader.favicon(withHomePageURL: feed.homePageURL) {
return image
}
return appDelegate.genericFeedImage
return AppImages.genericFeedImage
}
return nil
}

View File

@ -112,7 +112,7 @@ private extension FeedInspectorViewController {
return
}
imageView?.image = appDelegate.genericFeedImage
imageView?.image = AppImages.genericFeedImage
}
func updateName() {

View File

@ -13,10 +13,6 @@ import RSCore
private let kWindowFrameKey = "MainWindow"
extension NSImage.Name {
static let star = NSImage.Name(rawValue: "star")
static let unstar = NSImage.Name(rawValue: "unstar")
}
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
@ -417,7 +413,7 @@ extension MainWindowController: NSSharingServicePickerDelegate {
return nil
}
let image = sendToCommand.image ?? appDelegate.genericFeedImage ?? NSImage()
let image = sendToCommand.image ?? AppImages.genericFeedImage ?? NSImage()
return NSSharingService(title: sendToCommand.title, image: image, alternateImage: nil) {
sendToCommand.sendObject(object, selectedText: nil)
}

View File

@ -576,7 +576,7 @@ extension Feed: SmallIconProvider {
if let image = appDelegate.faviconDownloader.favicon(for: self) {
return image
}
return appDelegate.genericFeedImage
return AppImages.genericFeedImage
}
}

View File

@ -21,7 +21,7 @@ class TimelineTableCellView: NSTableCellView {
imageView.imageScaling = .scaleProportionallyDown
imageView.animates = false
imageView.imageAlignment = .alignCenter
imageView.image = appDelegate.genericFeedImage
imageView.image = AppImages.genericFeedImage
return imageView
}()