Create AppAsset shared class, which will replace the separate Mac and iOS AppAssets classes.
This commit is contained in:
parent
89a967106d
commit
ba44b94220
@ -9,35 +9,22 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import Account
|
import Account
|
||||||
import Images
|
import Images
|
||||||
|
import Core
|
||||||
|
|
||||||
|
extension AppAsset {
|
||||||
|
|
||||||
|
struct Mac {
|
||||||
|
|
||||||
|
struct Toolbar {
|
||||||
|
static let addNewSidebarItem = RSImage.systemImage("plus")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct AppAssets {
|
struct AppAssets {
|
||||||
|
|
||||||
static let accountBazQux = NSImage(named: "accountBazQux")
|
|
||||||
|
|
||||||
static let accountCloudKit = NSImage(named: "accountCloudKit")
|
|
||||||
|
|
||||||
static let accountFeedbin = NSImage(named: "accountFeedbin")
|
|
||||||
|
|
||||||
static let accountFeedly = NSImage(named: "accountFeedly")
|
|
||||||
|
|
||||||
static let accountFreshRSS = NSImage(named: "accountFreshRSS")
|
|
||||||
|
|
||||||
static let accountInoreader = NSImage(named: "accountInoreader")
|
|
||||||
|
|
||||||
static let accountLocal = NSImage(named: "accountLocal")
|
|
||||||
|
|
||||||
static let accountNewsBlur = NSImage(named: "accountNewsBlur")
|
|
||||||
|
|
||||||
static let accountTheOldReader = NSImage(named: "accountTheOldReader")
|
|
||||||
|
|
||||||
static let addNewSidebarItemImage = NSImage(systemSymbolName: "plus", accessibilityDescription: nil)!
|
|
||||||
|
|
||||||
static let articleExtractorError = NSImage(named: "articleExtractorError")!
|
|
||||||
|
|
||||||
static let articleExtractorOff = NSImage(named: "articleExtractorOff")!
|
|
||||||
|
|
||||||
static let articleExtractorOn = NSImage(named: "articleExtractorOn")!
|
|
||||||
|
|
||||||
static let articleTheme = NSImage(systemSymbolName: "doc.richtext", accessibilityDescription: nil)!
|
static let articleTheme = NSImage(systemSymbolName: "doc.richtext", accessibilityDescription: nil)!
|
||||||
|
|
||||||
static let cleanUpImage = NSImage(systemSymbolName: "wind", accessibilityDescription: nil)!
|
static let cleanUpImage = NSImage(systemSymbolName: "wind", accessibilityDescription: nil)!
|
||||||
@ -154,27 +141,4 @@ struct AppAssets {
|
|||||||
.withSymbolConfiguration(.init(scale: .large))!
|
.withSymbolConfiguration(.init(scale: .large))!
|
||||||
|
|
||||||
static let starColor = NSColor(named: NSColor.Name("StarColor"))!
|
static let starColor = NSColor(named: NSColor.Name("StarColor"))!
|
||||||
|
|
||||||
static func image(for accountType: AccountType) -> NSImage? {
|
|
||||||
switch accountType {
|
|
||||||
case .onMyMac:
|
|
||||||
return AppAssets.accountLocal
|
|
||||||
case .cloudKit:
|
|
||||||
return AppAssets.accountCloudKit
|
|
||||||
case .bazQux:
|
|
||||||
return AppAssets.accountBazQux
|
|
||||||
case .feedbin:
|
|
||||||
return AppAssets.accountFeedbin
|
|
||||||
case .feedly:
|
|
||||||
return AppAssets.accountFeedly
|
|
||||||
case .freshRSS:
|
|
||||||
return AppAssets.accountFreshRSS
|
|
||||||
case .inoreader:
|
|
||||||
return AppAssets.accountInoreader
|
|
||||||
case .newsBlur:
|
|
||||||
return AppAssets.accountNewsBlur
|
|
||||||
case .theOldReader:
|
|
||||||
return AppAssets.accountTheOldReader
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,16 @@ final class ArticleExtractorButton: NSButton {
|
|||||||
switch buttonState {
|
switch buttonState {
|
||||||
case .error:
|
case .error:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
image = AppAssets.articleExtractorError
|
image = AppAsset.ArticleExtractor.error
|
||||||
case .animated:
|
case .animated:
|
||||||
image = nil
|
image = nil
|
||||||
needsLayout = true
|
needsLayout = true
|
||||||
case .on:
|
case .on:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
image = AppAssets.articleExtractorOn
|
image = AppAsset.ArticleExtractor.on
|
||||||
case .off:
|
case .off:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
image = AppAssets.articleExtractorOff
|
image = AppAsset.ArticleExtractor.off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ final class ArticleExtractorButton: NSButton {
|
|||||||
private func commonInit() {
|
private func commonInit() {
|
||||||
wantsLayer = true
|
wantsLayer = true
|
||||||
bezelStyle = .texturedRounded
|
bezelStyle = .texturedRounded
|
||||||
image = AppAssets.articleExtractorOff
|
image = AppAsset.ArticleExtractor.off
|
||||||
imageScaling = .scaleProportionallyDown
|
imageScaling = .scaleProportionallyDown
|
||||||
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
||||||
}
|
}
|
||||||
@ -85,12 +85,12 @@ final class ArticleExtractorButton: NSButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func addAnimatedSublayer(to hostedLayer: CALayer) {
|
private func addAnimatedSublayer(to hostedLayer: CALayer) {
|
||||||
let image1 = AppAssets.articleExtractorOff.tinted(with: NSColor.controlTextColor)
|
let image1 = AppAsset.ArticleExtractor.off.tinted(with: NSColor.controlTextColor)
|
||||||
let image2 = AppAssets.articleExtractorOn.tinted(with: NSColor.controlTextColor)
|
let image2 = AppAsset.ArticleExtractor.on.tinted(with: NSColor.controlTextColor)
|
||||||
let images = [image1, image2, image1]
|
let images = [image1, image2, image1]
|
||||||
|
|
||||||
animatedLayer = CALayer()
|
animatedLayer = CALayer()
|
||||||
let imageSize = AppAssets.articleExtractorOff.size
|
let imageSize = AppAsset.ArticleExtractor.off.size
|
||||||
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
|
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
|
||||||
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ extension MainWindowController: NSToolbarDelegate {
|
|||||||
|
|
||||||
case .newSidebarItemMenu:
|
case .newSidebarItemMenu:
|
||||||
let toolbarItem = NSMenuToolbarItem(itemIdentifier: .newSidebarItemMenu)
|
let toolbarItem = NSMenuToolbarItem(itemIdentifier: .newSidebarItemMenu)
|
||||||
toolbarItem.image = AppAssets.addNewSidebarItemImage
|
toolbarItem.image = AppAsset.Mac.Toolbar.addNewSidebarItem
|
||||||
let description = NSLocalizedString("Add Item", comment: "Add Item")
|
let description = NSLocalizedString("Add Item", comment: "Add Item")
|
||||||
toolbarItem.toolTip = description
|
toolbarItem.toolTip = description
|
||||||
toolbarItem.label = description
|
toolbarItem.label = description
|
||||||
|
@ -40,23 +40,23 @@ class AccountsReaderAPIWindowController: NSWindowController {
|
|||||||
if let accountType = accountType {
|
if let accountType = accountType {
|
||||||
switch accountType {
|
switch accountType {
|
||||||
case .freshRSS:
|
case .freshRSS:
|
||||||
titleImageView.image = AppAssets.accountFreshRSS
|
titleImageView.image = AppAsset.Account.freshRSS
|
||||||
titleLabel.stringValue = NSLocalizedString("Sign in to your FreshRSS account.", comment: "FreshRSS")
|
titleLabel.stringValue = NSLocalizedString("Sign in to your FreshRSS account.", comment: "FreshRSS")
|
||||||
noAccountTextField.stringValue = NSLocalizedString("Don’t have a FreshRSS instance?", comment: "No FreshRSS")
|
noAccountTextField.stringValue = NSLocalizedString("Don’t have a FreshRSS instance?", comment: "No FreshRSS")
|
||||||
createAccountButton.title = NSLocalizedString("Find out more", comment: "No FreshRSS Button")
|
createAccountButton.title = NSLocalizedString("Find out more", comment: "No FreshRSS Button")
|
||||||
apiURLTextField.placeholderString = NSLocalizedString("fresh.rss.net/api/greader.php", comment: "FreshRSS API Helper")
|
apiURLTextField.placeholderString = NSLocalizedString("fresh.rss.net/api/greader.php", comment: "FreshRSS API Helper")
|
||||||
case .inoreader:
|
case .inoreader:
|
||||||
titleImageView.image = AppAssets.accountInoreader
|
titleImageView.image = AppAsset.Account.inoReader
|
||||||
titleLabel.stringValue = NSLocalizedString("Sign in to your InoReader account.", comment: "InoReader")
|
titleLabel.stringValue = NSLocalizedString("Sign in to your InoReader account.", comment: "InoReader")
|
||||||
gridView.row(at: 2).isHidden = true
|
gridView.row(at: 2).isHidden = true
|
||||||
noAccountTextField.stringValue = NSLocalizedString("Don’t have an InoReader account?", comment: "No InoReader")
|
noAccountTextField.stringValue = NSLocalizedString("Don’t have an InoReader account?", comment: "No InoReader")
|
||||||
case .bazQux:
|
case .bazQux:
|
||||||
titleImageView.image = AppAssets.accountBazQux
|
titleImageView.image = AppAsset.Account.bazQux
|
||||||
titleLabel.stringValue = NSLocalizedString("Sign in to your BazQux account.", comment: "BazQux")
|
titleLabel.stringValue = NSLocalizedString("Sign in to your BazQux account.", comment: "BazQux")
|
||||||
gridView.row(at: 2).isHidden = true
|
gridView.row(at: 2).isHidden = true
|
||||||
noAccountTextField.stringValue = NSLocalizedString("Don’t have a BazQux account?", comment: "No BazQux")
|
noAccountTextField.stringValue = NSLocalizedString("Don’t have a BazQux account?", comment: "No BazQux")
|
||||||
case .theOldReader:
|
case .theOldReader:
|
||||||
titleImageView.image = AppAssets.accountTheOldReader
|
titleImageView.image = AppAsset.Account.theOldReader
|
||||||
titleLabel.stringValue = NSLocalizedString("Sign in to your The Old Reader account.", comment: "The Old Reader")
|
titleLabel.stringValue = NSLocalizedString("Sign in to your The Old Reader account.", comment: "The Old Reader")
|
||||||
gridView.row(at: 2).isHidden = true
|
gridView.row(at: 2).isHidden = true
|
||||||
noAccountTextField.stringValue = NSLocalizedString("Don’t have a The Old Reader account?", comment: "No OldReader")
|
noAccountTextField.stringValue = NSLocalizedString("Don’t have a The Old Reader account?", comment: "No OldReader")
|
||||||
|
@ -20,6 +20,22 @@ public typealias RSImage = UIImage
|
|||||||
|
|
||||||
public extension RSImage {
|
public extension RSImage {
|
||||||
|
|
||||||
|
static func appImage(_ name: String) -> RSImage {
|
||||||
|
|
||||||
|
RSImage(named: name)!
|
||||||
|
}
|
||||||
|
|
||||||
|
static func systemImage(_ symbolName: String) -> RSImage {
|
||||||
|
|
||||||
|
#if canImport(AppKit)
|
||||||
|
NSImage(systemSymbolName: symbolName, accessibilityDescription: nil)!
|
||||||
|
|
||||||
|
#else
|
||||||
|
UIImage(systemName: symbolName)!
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a colored image from the source image using a specified color.
|
/// Create a colored image from the source image using a specified color.
|
||||||
///
|
///
|
||||||
/// - Parameter color: The color with which to fill the mask image.
|
/// - Parameter color: The color with which to fill the mask image.
|
||||||
|
@ -344,6 +344,9 @@
|
|||||||
840D617F2029031C009BC708 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D617E2029031C009BC708 /* AppDelegate.swift */; };
|
840D617F2029031C009BC708 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D617E2029031C009BC708 /* AppDelegate.swift */; };
|
||||||
8410C4A52BC1E28200D4F799 /* ReaderAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 8410C4A42BC1E28200D4F799 /* ReaderAPI */; };
|
8410C4A52BC1E28200D4F799 /* ReaderAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 8410C4A42BC1E28200D4F799 /* ReaderAPI */; };
|
||||||
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
|
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
|
||||||
|
8417E6342C3B913200C75D84 /* AppAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8417E6332C3B913200C75D84 /* AppAsset.swift */; };
|
||||||
|
8417E6352C3B913200C75D84 /* AppAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8417E6332C3B913200C75D84 /* AppAsset.swift */; };
|
||||||
|
8417E6372C3B9FE400C75D84 /* AppAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8417E6332C3B913200C75D84 /* AppAsset.swift */; };
|
||||||
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
|
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
|
||||||
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
|
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
|
||||||
841ABA6020145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */; };
|
841ABA6020145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */; };
|
||||||
@ -1000,6 +1003,7 @@
|
|||||||
840D61952029031D009BC708 /* NetNewsWire_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetNewsWire_iOSTests.swift; sourceTree = "<group>"; };
|
840D61952029031D009BC708 /* NetNewsWire_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetNewsWire_iOSTests.swift; sourceTree = "<group>"; };
|
||||||
840D61972029031D009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
840D61972029031D009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
|
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
|
||||||
|
8417E6332C3B913200C75D84 /* AppAsset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAsset.swift; sourceTree = "<group>"; };
|
||||||
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.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>"; };
|
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>"; };
|
841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltinSmartFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
||||||
@ -2112,6 +2116,7 @@
|
|||||||
children = (
|
children = (
|
||||||
84DC5FFD2BCE37A300F04682 /* AppDelegate+Shared.swift */,
|
84DC5FFD2BCE37A300F04682 /* AppDelegate+Shared.swift */,
|
||||||
842E45CD1ED8C308000A8B52 /* AppNotifications.swift */,
|
842E45CD1ED8C308000A8B52 /* AppNotifications.swift */,
|
||||||
|
8417E6332C3B913200C75D84 /* AppAsset.swift */,
|
||||||
511B9805237DCAC90028BCAA /* UserInfoKey.swift */,
|
511B9805237DCAC90028BCAA /* UserInfoKey.swift */,
|
||||||
844933D12BA953590068AC51 /* ArticlePathInfo.swift */,
|
844933D12BA953590068AC51 /* ArticlePathInfo.swift */,
|
||||||
8454C3F2263F2D8700E3F9C7 /* IconImageCache.swift */,
|
8454C3F2263F2D8700E3F9C7 /* IconImageCache.swift */,
|
||||||
@ -3214,6 +3219,7 @@
|
|||||||
files = (
|
files = (
|
||||||
51B5C8B923F368D000032075 /* ExtensionContainers.swift in Sources */,
|
51B5C8B923F368D000032075 /* ExtensionContainers.swift in Sources */,
|
||||||
515D4FCA23257CB500EE1167 /* Node-Extensions.swift in Sources */,
|
515D4FCA23257CB500EE1167 /* Node-Extensions.swift in Sources */,
|
||||||
|
8417E6372C3B9FE400C75D84 /* AppAsset.swift in Sources */,
|
||||||
513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */,
|
513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */,
|
||||||
51707439232AA97100A461A3 /* ShareFolderPickerController.swift in Sources */,
|
51707439232AA97100A461A3 /* ShareFolderPickerController.swift in Sources */,
|
||||||
51B5C8BE23F37B2400032075 /* ShareDefaultContainer.swift in Sources */,
|
51B5C8BE23F37B2400032075 /* ShareDefaultContainer.swift in Sources */,
|
||||||
@ -3353,6 +3359,7 @@
|
|||||||
51B5C87D23F2346200032075 /* ExtensionContainersFile.swift in Sources */,
|
51B5C87D23F2346200032075 /* ExtensionContainersFile.swift in Sources */,
|
||||||
51102165233A7D6C0007A5F7 /* ArticleExtractorButton.swift in Sources */,
|
51102165233A7D6C0007A5F7 /* ArticleExtractorButton.swift in Sources */,
|
||||||
5141E7392373C18B0013FF27 /* FeedInspectorViewController.swift in Sources */,
|
5141E7392373C18B0013FF27 /* FeedInspectorViewController.swift in Sources */,
|
||||||
|
8417E6352C3B913200C75D84 /* AppAsset.swift in Sources */,
|
||||||
C5A6ED6D23C9B0C800AB6BE2 /* UIActivityViewController-Extensions.swift in Sources */,
|
C5A6ED6D23C9B0C800AB6BE2 /* UIActivityViewController-Extensions.swift in Sources */,
|
||||||
5108F6D42375EEEF001ABC45 /* TimelinePreviewTableViewController.swift in Sources */,
|
5108F6D42375EEEF001ABC45 /* TimelinePreviewTableViewController.swift in Sources */,
|
||||||
84CAFCA522BC8C08007694F0 /* FetchRequestQueue.swift in Sources */,
|
84CAFCA522BC8C08007694F0 /* FetchRequestQueue.swift in Sources */,
|
||||||
@ -3479,6 +3486,7 @@
|
|||||||
51FE10032345529D0056195D /* UserNotificationManager.swift in Sources */,
|
51FE10032345529D0056195D /* UserNotificationManager.swift in Sources */,
|
||||||
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
|
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
|
||||||
51BC4AFF247277E0000A6ED8 /* URL-Extensions.swift in Sources */,
|
51BC4AFF247277E0000A6ED8 /* URL-Extensions.swift in Sources */,
|
||||||
|
8417E6342C3B913200C75D84 /* AppAsset.swift in Sources */,
|
||||||
849A978A1ED9ECEF007D329B /* ArticleThemesManager.swift in Sources */,
|
849A978A1ED9ECEF007D329B /* ArticleThemesManager.swift in Sources */,
|
||||||
8405DD8A2213E0E3008CE1BF /* DetailContainerView.swift in Sources */,
|
8405DD8A2213E0E3008CE1BF /* DetailContainerView.swift in Sources */,
|
||||||
844933D22BA953590068AC51 /* ArticlePathInfo.swift in Sources */,
|
844933D22BA953590068AC51 /* ArticlePathInfo.swift in Sources */,
|
||||||
|
79
Shared/AppAsset.swift
Normal file
79
Shared/AppAsset.swift
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
//
|
||||||
|
// AppAsset.swift
|
||||||
|
// NetNewsWire
|
||||||
|
//
|
||||||
|
// Created by Brent Simmons on 7/7/24.
|
||||||
|
// Copyright © 2024 Ranchero Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if canImport(AppKit)
|
||||||
|
import AppKit
|
||||||
|
#elseif canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import Core
|
||||||
|
import Account
|
||||||
|
|
||||||
|
final class AppAsset {
|
||||||
|
|
||||||
|
struct Account {
|
||||||
|
|
||||||
|
static let bazQux = RSImage.appImage("accountBazQux")
|
||||||
|
static let cloudKit = RSImage.appImage("accountCloudKit")
|
||||||
|
static let feedbin = RSImage.appImage("accountFeedbin")
|
||||||
|
static let feedly = RSImage.appImage("accountFeedly")
|
||||||
|
static let freshRSS = RSImage.appImage("accountFreshRSS")
|
||||||
|
static let inoReader = RSImage.appImage("accountInoreader")
|
||||||
|
static let local = RSImage.appImage("accountLocal")
|
||||||
|
static let localPad = RSImage.appImage("accountLocalPad")
|
||||||
|
static let localPhone = RSImage.appImage("accountLocalPhone")
|
||||||
|
static let newsBlur = RSImage.appImage("accountNewsBlur")
|
||||||
|
static let theOldReader = RSImage.appImage("accountTheOldReader")
|
||||||
|
|
||||||
|
@MainActor static func image(for accountType: AccountType) -> RSImage {
|
||||||
|
|
||||||
|
switch accountType {
|
||||||
|
case .onMyMac:
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
return AppAsset.Account.local
|
||||||
|
|
||||||
|
#elseif os(iOS)
|
||||||
|
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||||
|
return AppAsset.Account.localPad
|
||||||
|
} else {
|
||||||
|
return AppAsset.Account.localPhone
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case .cloudKit:
|
||||||
|
return AppAsset.Account.cloudKit
|
||||||
|
case .bazQux:
|
||||||
|
return AppAsset.Account.bazQux
|
||||||
|
case .feedbin:
|
||||||
|
return AppAsset.Account.feedbin
|
||||||
|
case .feedly:
|
||||||
|
return AppAsset.Account.feedly
|
||||||
|
case .freshRSS:
|
||||||
|
return AppAsset.Account.freshRSS
|
||||||
|
case .inoreader:
|
||||||
|
return AppAsset.Account.inoReader
|
||||||
|
case .newsBlur:
|
||||||
|
return AppAsset.Account.newsBlur
|
||||||
|
case .theOldReader:
|
||||||
|
return AppAsset.Account.theOldReader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ArticleExtractor {
|
||||||
|
|
||||||
|
static let error = RSImage.appImage("articleExtractorError")
|
||||||
|
static let off = RSImage.appImage("articleExtractorOff")
|
||||||
|
static let offSF = RSImage.systemImage("doc.plaintext")
|
||||||
|
static let on = RSImage.appImage("articleExtractorOn")
|
||||||
|
static let onSF = RSImage.appImage("articleExtractorOnSF")
|
||||||
|
}
|
||||||
|
}
|
@ -18,11 +18,9 @@ protocol SmallIconProvider {
|
|||||||
|
|
||||||
extension Account: SmallIconProvider {
|
extension Account: SmallIconProvider {
|
||||||
var smallIcon: IconImage? {
|
var smallIcon: IconImage? {
|
||||||
if let image = AppAssets.image(for: accountType) {
|
let image = AppAsset.Account.image(for: accountType)
|
||||||
return IconImage(image)
|
return IconImage(image)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Feed: SmallIconProvider {
|
extension Feed: SmallIconProvider {
|
||||||
|
@ -56,7 +56,7 @@ class CloudKitAccountViewController: UITableViewController {
|
|||||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||||
if section == 0 {
|
if section == 0 {
|
||||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||||
headerView.imageView.image = AppAssets.image(for: .cloudKit)
|
headerView.imageView.image = AppAsset.Account.image(for: .cloudKit)
|
||||||
return headerView
|
return headerView
|
||||||
} else {
|
} else {
|
||||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||||
|
@ -69,7 +69,7 @@ class FeedbinAccountViewController: UITableViewController {
|
|||||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||||
if section == 0 {
|
if section == 0 {
|
||||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||||
headerView.imageView.image = AppAssets.image(for: .feedbin)
|
headerView.imageView.image = AppAsset.Account.image(for: .feedbin)
|
||||||
return headerView
|
return headerView
|
||||||
} else {
|
} else {
|
||||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||||
|
@ -46,7 +46,7 @@ class LocalAccountViewController: UITableViewController {
|
|||||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||||
if section == 0 {
|
if section == 0 {
|
||||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||||
headerView.imageView.image = AppAssets.image(for: .onMyMac)
|
headerView.imageView.image = AppAsset.Account.image(for: .onMyMac)
|
||||||
return headerView
|
return headerView
|
||||||
} else {
|
} else {
|
||||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||||
|
@ -63,7 +63,7 @@ class NewsBlurAccountViewController: UITableViewController {
|
|||||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||||
if section == 0 {
|
if section == 0 {
|
||||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||||
headerView.imageView.image = AppAssets.image(for: .newsBlur)
|
headerView.imageView.image = AppAsset.Account.image(for: .newsBlur)
|
||||||
return headerView
|
return headerView
|
||||||
} else {
|
} else {
|
||||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||||
|
@ -230,13 +230,13 @@ class ReaderAPIAccountViewController: UITableViewController {
|
|||||||
if let accountType = accountType {
|
if let accountType = accountType {
|
||||||
switch accountType {
|
switch accountType {
|
||||||
case .bazQux:
|
case .bazQux:
|
||||||
return AppAssets.accountBazQuxImage
|
return AppAsset.Account.bazQux
|
||||||
case .inoreader:
|
case .inoreader:
|
||||||
return AppAssets.accountInoreaderImage
|
return AppAsset.Account.inoReader
|
||||||
case .theOldReader:
|
case .theOldReader:
|
||||||
return AppAssets.accountTheOldReaderImage
|
return AppAsset.Account.theOldReader
|
||||||
case .freshRSS:
|
case .freshRSS:
|
||||||
return AppAssets.accountFreshRSSImage
|
return AppAsset.Account.freshRSS
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -13,41 +13,11 @@ import Images
|
|||||||
|
|
||||||
struct AppAssets {
|
struct AppAssets {
|
||||||
|
|
||||||
static let accountBazQuxImage = UIImage(named: "accountBazQux")!
|
|
||||||
|
|
||||||
static let accountCloudKitImage = UIImage(named: "accountCloudKit")!
|
|
||||||
|
|
||||||
static let accountFeedbinImage = UIImage(named: "accountFeedbin")!
|
|
||||||
|
|
||||||
static let accountFeedlyImage = UIImage(named: "accountFeedly")!
|
|
||||||
|
|
||||||
static let accountFreshRSSImage = UIImage(named: "accountFreshRSS")!
|
|
||||||
|
|
||||||
static let accountInoreaderImage = UIImage(named: "accountInoreader")!
|
|
||||||
|
|
||||||
static let accountLocalPadImage = UIImage(named: "accountLocalPad")!
|
|
||||||
|
|
||||||
static let accountLocalPhoneImage = UIImage(named: "accountLocalPhone")!
|
|
||||||
|
|
||||||
static let accountNewsBlurImage = UIImage(named: "accountNewsBlur")!
|
|
||||||
|
|
||||||
static let accountTheOldReaderImage = UIImage(named: "accountTheOldReader")!
|
|
||||||
|
|
||||||
static let articleExtractorError = UIImage(named: "articleExtractorError")!
|
|
||||||
|
|
||||||
static let articleExtractorOff = UIImage(named: "articleExtractorOff")!
|
|
||||||
|
|
||||||
static let articleExtractorOffSF = UIImage(systemName: "doc.plaintext")!
|
|
||||||
|
|
||||||
@MainActor static let articleExtractorOffTinted: UIImage = {
|
@MainActor static let articleExtractorOffTinted: UIImage = {
|
||||||
let image = UIImage(named: "articleExtractorOff")!
|
let image = UIImage(named: "articleExtractorOff")!
|
||||||
return image.tinted(color: AppAssets.primaryAccentColor)!
|
return image.tinted(color: AppAssets.primaryAccentColor)!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static let articleExtractorOn = UIImage(named: "articleExtractorOn")!
|
|
||||||
|
|
||||||
static let articleExtractorOnSF = UIImage(named: "articleExtractorOnSF")!
|
|
||||||
|
|
||||||
@MainActor static let articleExtractorOnTinted: UIImage = {
|
@MainActor static let articleExtractorOnTinted: UIImage = {
|
||||||
let image = UIImage(named: "articleExtractorOn")!
|
let image = UIImage(named: "articleExtractorOn")!
|
||||||
return image.tinted(color: AppAssets.primaryAccentColor)!
|
return image.tinted(color: AppAssets.primaryAccentColor)!
|
||||||
@ -148,31 +118,4 @@ struct AppAssets {
|
|||||||
static let vibrantTextColor = UIColor(named: "vibrantTextColor")!
|
static let vibrantTextColor = UIColor(named: "vibrantTextColor")!
|
||||||
|
|
||||||
static let controlBackgroundColor = UIColor(named: "controlBackgroundColor")!
|
static let controlBackgroundColor = UIColor(named: "controlBackgroundColor")!
|
||||||
|
|
||||||
@MainActor static func image(for accountType: AccountType) -> UIImage? {
|
|
||||||
switch accountType {
|
|
||||||
case .onMyMac:
|
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
|
||||||
return AppAssets.accountLocalPadImage
|
|
||||||
} else {
|
|
||||||
return AppAssets.accountLocalPhoneImage
|
|
||||||
}
|
|
||||||
case .cloudKit:
|
|
||||||
return AppAssets.accountCloudKitImage
|
|
||||||
case .feedbin:
|
|
||||||
return AppAssets.accountFeedbinImage
|
|
||||||
case .feedly:
|
|
||||||
return AppAssets.accountFeedlyImage
|
|
||||||
case .freshRSS:
|
|
||||||
return AppAssets.accountFreshRSSImage
|
|
||||||
case .newsBlur:
|
|
||||||
return AppAssets.accountNewsBlurImage
|
|
||||||
case .inoreader:
|
|
||||||
return AppAssets.accountInoreaderImage
|
|
||||||
case .bazQux:
|
|
||||||
return AppAssets.accountBazQuxImage
|
|
||||||
case .theOldReader:
|
|
||||||
return AppAssets.accountTheOldReaderImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,16 @@ enum ArticleExtractorButtonState {
|
|||||||
switch buttonState {
|
switch buttonState {
|
||||||
case .error:
|
case .error:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
setImage(AppAssets.articleExtractorError, for: .normal)
|
setImage(AppAsset.ArticleExtractor.error, for: .normal)
|
||||||
case .animated:
|
case .animated:
|
||||||
setImage(nil, for: .normal)
|
setImage(nil, for: .normal)
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
case .on:
|
case .on:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
setImage(AppAssets.articleExtractorOn, for: .normal)
|
setImage(AppAsset.ArticleExtractor.on, for: .normal)
|
||||||
case .off:
|
case .off:
|
||||||
stripAnimatedSublayer()
|
stripAnimatedSublayer()
|
||||||
setImage(AppAssets.articleExtractorOff, for: .normal)
|
setImage(AppAsset.ArticleExtractor.off, for: .normal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ enum ArticleExtractorButtonState {
|
|||||||
let images = [image1, image2, image1]
|
let images = [image1, image2, image1]
|
||||||
|
|
||||||
animatedLayer = CALayer()
|
animatedLayer = CALayer()
|
||||||
let imageSize = AppAssets.articleExtractorOff.size
|
let imageSize = AppAsset.ArticleExtractor.off.size
|
||||||
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
|
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
|
||||||
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ final class ArticleViewController: UIViewController {
|
|||||||
private var articleExtractorButton: ArticleExtractorButton = {
|
private var articleExtractorButton: ArticleExtractorButton = {
|
||||||
let button = ArticleExtractorButton(type: .system)
|
let button = ArticleExtractorButton(type: .system)
|
||||||
button.frame = CGRect(x: 0, y: 0, width: 44.0, height: 44.0)
|
button.frame = CGRect(x: 0, y: 0, width: 44.0, height: 44.0)
|
||||||
button.setImage(AppAssets.articleExtractorOff, for: .normal)
|
button.setImage(AppAsset.ArticleExtractor.off, for: .normal)
|
||||||
return button
|
return button
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@ private extension WebViewController {
|
|||||||
func toggleArticleExtractorAction() -> UIAction {
|
func toggleArticleExtractorAction() -> UIAction {
|
||||||
let extracted = articleExtractorButtonState == .on
|
let extracted = articleExtractorButtonState == .on
|
||||||
let title = extracted ? NSLocalizedString("Show Feed Article", comment: "Show Feed Article") : NSLocalizedString("Show Reader View", comment: "Show Reader View")
|
let title = extracted ? NSLocalizedString("Show Feed Article", comment: "Show Feed Article") : NSLocalizedString("Show Reader View", comment: "Show Reader View")
|
||||||
let extractorImage = extracted ? AppAssets.articleExtractorOffSF : AppAssets.articleExtractorOnSF
|
let extractorImage = extracted ? AppAsset.ArticleExtractor.offSF : AppAsset.ArticleExtractor.onSF
|
||||||
return UIAction(title: title, image: extractorImage) { [weak self] action in
|
return UIAction(title: title, image: extractorImage) { [weak self] action in
|
||||||
self?.toggleArticleExtractor()
|
self?.toggleArticleExtractor()
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ extension AccountInspectorViewController {
|
|||||||
|
|
||||||
if section == 0 {
|
if section == 0 {
|
||||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||||
headerView.imageView.image = AppAssets.image(for: account.accountType)
|
headerView.imageView.image = AppAsset.Account.image(for: account.accountType)
|
||||||
return headerView
|
return headerView
|
||||||
} else {
|
} else {
|
||||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||||
|
@ -133,17 +133,17 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
|
|||||||
switch indexPath.section {
|
switch indexPath.section {
|
||||||
case AddAccountSections.local.rawValue:
|
case AddAccountSections.local.rawValue:
|
||||||
cell.comboNameLabel?.text = AddAccountSections.local.sectionContent[indexPath.row].localizedAccountName()
|
cell.comboNameLabel?.text = AddAccountSections.local.sectionContent[indexPath.row].localizedAccountName()
|
||||||
cell.comboImage?.image = AppAssets.image(for: .onMyMac)
|
cell.comboImage?.image = AppAsset.Account.image(for: .onMyMac)
|
||||||
case AddAccountSections.icloud.rawValue:
|
case AddAccountSections.icloud.rawValue:
|
||||||
cell.comboNameLabel?.text = AddAccountSections.icloud.sectionContent[indexPath.row].localizedAccountName()
|
cell.comboNameLabel?.text = AddAccountSections.icloud.sectionContent[indexPath.row].localizedAccountName()
|
||||||
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])
|
cell.comboImage?.image = AppAsset.Account.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])
|
||||||
if AppDefaults.shared.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.accountType == .cloudKit }) {
|
if AppDefaults.shared.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.accountType == .cloudKit }) {
|
||||||
cell.isUserInteractionEnabled = false
|
cell.isUserInteractionEnabled = false
|
||||||
cell.comboNameLabel?.isEnabled = false
|
cell.comboNameLabel?.isEnabled = false
|
||||||
}
|
}
|
||||||
case AddAccountSections.web.rawValue:
|
case AddAccountSections.web.rawValue:
|
||||||
cell.comboNameLabel?.text = AddAccountSections.web.sectionContent[indexPath.row].localizedAccountName()
|
cell.comboNameLabel?.text = AddAccountSections.web.sectionContent[indexPath.row].localizedAccountName()
|
||||||
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.web.sectionContent[indexPath.row])
|
cell.comboImage?.image = AppAsset.Account.image(for: AddAccountSections.web.sectionContent[indexPath.row])
|
||||||
let type = AddAccountSections.web.sectionContent[indexPath.row]
|
let type = AddAccountSections.web.sectionContent[indexPath.row]
|
||||||
if (type == .feedly || type == .inoreader) && AppDefaults.shared.isDeveloperBuild {
|
if (type == .feedly || type == .inoreader) && AppDefaults.shared.isDeveloperBuild {
|
||||||
cell.isUserInteractionEnabled = false
|
cell.isUserInteractionEnabled = false
|
||||||
@ -151,7 +151,7 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
|
|||||||
}
|
}
|
||||||
case AddAccountSections.selfhosted.rawValue:
|
case AddAccountSections.selfhosted.rawValue:
|
||||||
cell.comboNameLabel?.text = AddAccountSections.selfhosted.sectionContent[indexPath.row].localizedAccountName()
|
cell.comboNameLabel?.text = AddAccountSections.selfhosted.sectionContent[indexPath.row].localizedAccountName()
|
||||||
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.selfhosted.sectionContent[indexPath.row])
|
cell.comboImage?.image = AppAsset.Account.image(for: AddAccountSections.selfhosted.sectionContent[indexPath.row])
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return cell
|
return cell
|
||||||
|
@ -146,7 +146,7 @@ final class SettingsViewController: UITableViewController {
|
|||||||
let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsComboTableViewCell", for: indexPath) as! SettingsComboTableViewCell
|
let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsComboTableViewCell", for: indexPath) as! SettingsComboTableViewCell
|
||||||
acctCell.applyThemeProperties()
|
acctCell.applyThemeProperties()
|
||||||
let account = sortedAccounts[indexPath.row]
|
let account = sortedAccounts[indexPath.row]
|
||||||
acctCell.comboImage?.image = AppAssets.image(for: account.accountType)
|
acctCell.comboImage?.image = AppAsset.Account.image(for: account.accountType)
|
||||||
acctCell.comboNameLabel?.text = account.nameForDisplay
|
acctCell.comboNameLabel?.text = account.nameForDisplay
|
||||||
cell = acctCell
|
cell = acctCell
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Account
|
import Account
|
||||||
|
import Core
|
||||||
|
|
||||||
protocol ShareFolderPickerControllerDelegate: AnyObject {
|
protocol ShareFolderPickerControllerDelegate: AnyObject {
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class ShareFolderPickerController: UITableViewController {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if let account = container as? ExtensionAccount {
|
if let account = container as? ExtensionAccount {
|
||||||
cell.icon.image = AppAssets.image(for: account.type)
|
cell.icon.image = AppAsset.Account.image(for: account.type)
|
||||||
} else {
|
} else {
|
||||||
cell.icon.image = AppAssets.folderImage.image
|
cell.icon.image = AppAssets.folderImage.image
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user