Continue moving from AppAssets to AppAsset.

This commit is contained in:
Brent Simmons 2024-07-09 21:08:34 -07:00
parent ba44b94220
commit 030d101634
10 changed files with 39 additions and 52 deletions

View File

@ -15,9 +15,18 @@ extension AppAsset {
struct Mac {
static let iconLightBackgroundColor = NSColor(named: NSColor.Name("iconLightBackgroundColor"))!
static let iconDarkBackgroundColor = NSColor(named: NSColor.Name("iconDarkBackgroundColor"))!
static let marsEditIcon = RSImage.appImage("MarsEditIcon")
static let microblogIcon = RSImage.appImage("MicroblogIcon")
struct Toolbar {
static let addNewSidebarItem = RSImage.systemImage("plus")
static let sidebarToggle = RSImage.systemImage("sidebar.left")
static let refresh = RSImage.systemImage("arrow.clockwise")
static let articleTheme = RSImage.systemImage("doc.richtext")
static let cleanUpImage = RSImage.systemImage("wind")
}
}
}
@ -25,23 +34,7 @@ extension AppAsset {
struct AppAssets {
static let articleTheme = NSImage(systemSymbolName: "doc.richtext", accessibilityDescription: nil)!
static let cleanUpImage = NSImage(systemSymbolName: "wind", accessibilityDescription: nil)!
static let marsEditIcon = NSImage(named: "MarsEditIcon")!
static let microblogIcon = NSImage(named: "MicroblogIcon")!
static let faviconTemplateImage = NSImage(named: "faviconTemplateImage")!
static let filterActive = NSImage(systemSymbolName: "line.horizontal.3.decrease.circle.fill", accessibilityDescription: nil)!
static let filterInactive = NSImage(systemSymbolName: "line.horizontal.3.decrease.circle", accessibilityDescription: nil)!
static let iconLightBackgroundColor = NSColor(named: NSColor.Name("iconLightBackgroundColor"))!
static let iconDarkBackgroundColor = NSColor(named: NSColor.Name("iconDarkBackgroundColor"))!
static let legacyArticleExtractor = NSImage(named: "legacyArticleExtractor")!
@ -67,8 +60,6 @@ struct AppAssets {
return IconImage(coloredImage, isSymbol: true, isBackgroundSupressed: true, preferredColor: preferredColor.cgColor)
}()
static let markAllAsReadImage = NSImage(named: "markAllAsRead")!
static let nextUnreadImage = NSImage(systemSymbolName: "chevron.down.circle", accessibilityDescription: nil)!
static let openInBrowserImage = NSImage(systemSymbolName: "safari", accessibilityDescription: nil)!
@ -83,7 +74,6 @@ struct AppAssets {
static let readOpenImage = NSImage(systemSymbolName: "circle", accessibilityDescription: nil)!
static let refreshImage = NSImage(systemSymbolName: "arrow.clockwise", accessibilityDescription: nil)!
@MainActor
static let searchFeedImage: IconImage = {
@ -92,8 +82,6 @@ struct AppAssets {
static let shareImage = NSImage(systemSymbolName: "square.and.arrow.up", accessibilityDescription: nil)!
static let sidebarToggleImage = NSImage(systemSymbolName: "sidebar.left", accessibilityDescription: nil)!
static let starClosedImage = NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)!
static let starOpenImage = NSImage(systemSymbolName: "star", accessibilityDescription: nil)!

View File

@ -164,7 +164,7 @@ import Sparkle
os_log(.debug, "Is first run.")
}
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
FaviconGenerator.faviconTemplateImage = AppAsset.faviconTemplate
importFeedsIfNeeded()
updateSortMenuItems()

View File

@ -796,11 +796,11 @@ extension MainWindowController: NSToolbarDelegate {
case .sidebarToggle:
let title = NSLocalizedString("Toggle Sidebar", comment: "Toggle Sidebar")
return buildToolbarButton(.toggleSidebar, title, AppAssets.sidebarToggleImage, "toggleTheSidebar:")
return buildToolbarButton(.toggleSidebar, title, AppAsset.Mac.Toolbar.sidebarToggle, "toggleTheSidebar:")
case .refresh:
let title = NSLocalizedString("Refresh", comment: "Refresh")
return buildToolbarButton(.refresh, title, AppAssets.refreshImage, "refreshAll:")
return buildToolbarButton(.refresh, title, AppAsset.Mac.Toolbar.refresh, "refreshAll:")
case .newSidebarItemMenu:
let toolbarItem = NSMenuToolbarItem(itemIdentifier: .newSidebarItemMenu)
@ -813,11 +813,11 @@ extension MainWindowController: NSToolbarDelegate {
case .markAllAsRead:
let title = NSLocalizedString("Mark All as Read", comment: "Mark All as Read")
return buildToolbarButton(.markAllAsRead, title, AppAssets.markAllAsReadImage, "markAllAsRead:")
return buildToolbarButton(.markAllAsRead, title, AppAsset.markAllAsRead, "markAllAsRead:")
case .toggleReadArticlesFilter:
let title = NSLocalizedString("Read Articles Filter", comment: "Read Articles Filter")
return buildToolbarButton(.toggleReadArticlesFilter, title, AppAssets.filterInactive, "toggleReadArticlesFilter:")
return buildToolbarButton(.toggleReadArticlesFilter, title, AppAsset.filterInactive, "toggleReadArticlesFilter:")
case .timelineTrackingSeparator:
return NSTrackingSeparatorToolbarItem(identifier: .timelineTrackingSeparator, splitView: splitViewController!.splitView, dividerIndex: 1)
@ -854,7 +854,7 @@ extension MainWindowController: NSToolbarDelegate {
return buildToolbarButton(.openInBrowser, title, AppAssets.openInBrowserImage, "openArticleInBrowser:")
case .articleThemeMenu:
articleThemeMenuToolbarItem.image = AppAssets.articleTheme
articleThemeMenuToolbarItem.image = AppAsset.Mac.Toolbar.articleTheme
let description = NSLocalizedString("Article Theme", comment: "Article Theme")
articleThemeMenuToolbarItem.toolTip = description
articleThemeMenuToolbarItem.label = description
@ -869,7 +869,7 @@ extension MainWindowController: NSToolbarDelegate {
case .cleanUp:
let title = NSLocalizedString("Clean Up", comment: "Clean Up")
return buildToolbarButton(.cleanUp, title, AppAssets.cleanUpImage, "cleanUp:")
return buildToolbarButton(.cleanUp, title, AppAsset.Mac.Toolbar.cleanUpImage, "cleanUp:")
default:
break
@ -1190,7 +1190,7 @@ private extension MainWindowController {
(item as? NSMenuItem)?.title = hideCommand
if let toolbarItem = item as? NSToolbarItem, let button = toolbarItem.view as? NSButton {
toolbarItem.toolTip = hideCommand
button.image = AppAssets.filterInactive
button.image = AppAsset.filterInactive
}
return false
}
@ -1199,13 +1199,13 @@ private extension MainWindowController {
(item as? NSMenuItem)?.title = showCommand
if let toolbarItem = item as? NSToolbarItem, let button = toolbarItem.view as? NSButton {
toolbarItem.toolTip = showCommand
button.image = AppAssets.filterActive
button.image = AppAsset.filterActive
}
} else {
(item as? NSMenuItem)?.title = hideCommand
if let toolbarItem = item as? NSToolbarItem, let button = toolbarItem.view as? NSButton {
toolbarItem.toolTip = hideCommand
button.image = AppAssets.filterInactive
button.image = AppAsset.filterInactive
}
}

View File

@ -210,9 +210,9 @@ private extension TimelineContainerViewController {
readFilteredButton.isHidden = false
if isReadFiltered {
readFilteredButton.image = AppAssets.filterActive
readFilteredButton.image = AppAsset.filterActive
} else {
readFilteredButton.image = AppAssets.filterInactive
readFilteredButton.image = AppAsset.filterInactive
}
}

View File

@ -17,6 +17,10 @@ import Account
final class AppAsset {
static let markAllAsRead = RSImage.appImage("markAllAsRead")
static let faviconTemplate = RSImage.appImage("faviconTemplateImage")
struct Account {
static let bazQux = RSImage.appImage("accountBazQux")
@ -76,4 +80,7 @@ final class AppAsset {
static let on = RSImage.appImage("articleExtractorOn")
static let onSF = RSImage.appImage("articleExtractorOnSF")
}
static let filterActive = RSImage.systemImage("line.horizontal.3.decrease.circle.fill")
static let filterInactive = RSImage.systemImage("line.horizontal.3.decrease.circle")
}

View File

@ -14,7 +14,7 @@ import Core
@MainActor final class SendToMarsEditCommand: SendToCommand {
let title = "MarsEdit"
let image: RSImage? = AppAssets.marsEditIcon
let image: RSImage? = AppAsset.Mac.marsEditIcon
private let marsEditApps = [UserApp(bundleID: "com.red-sweater.marsedit4"), UserApp(bundleID: "com.red-sweater.marsedit")]

View File

@ -16,7 +16,7 @@ import Core
@MainActor final class SendToMicroBlogCommand: SendToCommand {
let title = "Micro.blog"
let image: RSImage? = AppAssets.microblogIcon
let image: RSImage? = AppAsset.Mac.microblogIcon
private let microBlogApp = UserApp(bundleID: "blog.micro.mac")

View File

@ -37,20 +37,12 @@ struct AppAssets {
static let editImage = UIImage(systemName: "square.and.pencil")!
static let faviconTemplateImage = RSImage(named: "faviconTemplateImage")!
static let filterInactiveImage = UIImage(systemName: "line.horizontal.3.decrease.circle")!
static let filterActiveImage = UIImage(systemName: "line.horizontal.3.decrease.circle.fill")!
static let folderOutlinePlus = UIImage(systemName: "folder.badge.plus")!
static let fullScreenBackgroundColor = UIColor(named: "fullScreenBackgroundColor")!
static let infoImage = UIImage(systemName: "info.circle")!
static let markAllAsReadImage = UIImage(named: "markAllAsRead")!
static let markBelowAsReadImage = UIImage(systemName: "arrowtriangle.down.circle")!
static let markAboveAsReadImage = UIImage(systemName: "arrowtriangle.up.circle")!

View File

@ -705,12 +705,12 @@ private extension SidebarViewController {
}
func setFilterButtonToActive() {
filterButton?.image = AppAssets.filterActiveImage
filterButton?.image = AppAsset.filterActive
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Feeds", comment: "Selected - Filter Read Feeds")
}
func setFilterButtonToInactive() {
filterButton?.image = AppAssets.filterInactiveImage
filterButton?.image = AppAsset.filterInactive
filterButton?.accLabelText = NSLocalizedString("Filter Read Feeds", comment: "Filter Read Feeds")
}
@ -1101,7 +1101,7 @@ private extension SidebarViewController {
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
let action = UIAction(title: title, image: AppAssets.markAllAsReadImage) { [weak self] action in
let action = UIAction(title: title, image: AppAsset.markAllAsRead) { [weak self] action in
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
Task { @MainActor in
@ -1122,7 +1122,7 @@ private extension SidebarViewController {
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, account.nameForDisplay) as String
let action = UIAction(title: title, image: AppAssets.markAllAsReadImage) { [weak self] action in
let action = UIAction(title: title, image: AppAsset.markAllAsRead) { [weak self] action in
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
// If you don't have this delay the screen flashes when it executes this code
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {

View File

@ -63,7 +63,7 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
// Initialize Programmatic Buttons
filterButton = UIBarButtonItem(image: AppAssets.filterInactiveImage, style: .plain, target: self, action: #selector(toggleFilter(_:)))
filterButton = UIBarButtonItem(image: AppAsset.filterInactive, style: .plain, target: self, action: #selector(toggleFilter(_:)))
firstUnreadButton = UIBarButtonItem(image: AppAssets.nextUnreadArticleImage, style: .plain, target: self, action: #selector(firstUnread(_:)))
// Setup the Search Controller
@ -656,10 +656,10 @@ private extension TimelineViewController {
}
if coordinator.isReadArticlesFiltered {
filterButton?.image = AppAssets.filterActiveImage
filterButton?.image = AppAsset.filterActive
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles")
} else {
filterButton?.image = AppAssets.filterInactiveImage
filterButton?.image = AppAsset.filterInactive
filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles")
}
@ -886,7 +886,7 @@ private extension TimelineViewController {
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
let action = UIAction(title: title, image: AppAssets.markAllAsReadImage) { [weak self] action in
let action = UIAction(title: title, image: AppAsset.markAllAsRead) { [weak self] action in
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
Task { @MainActor in