Skip to content

Commit

Permalink
Use Xcode's generated asset symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Eitot committed Jul 3, 2024
1 parent 07a6e01 commit 5acc49d
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 36 deletions.
4 changes: 4 additions & 0 deletions Vienna.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,7 @@
buildSettings = {
APPLY_RULES_IN_COPY_FILES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = AppKit;
CODE_SIGN_ENTITLEMENTS = Vienna/Vienna.entitlements;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
Expand Down Expand Up @@ -2989,6 +2990,7 @@
buildSettings = {
APPLY_RULES_IN_COPY_FILES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = AppKit;
CODE_SIGN_ENTITLEMENTS = Vienna/ViennaDeployment.entitlements;
COMBINE_HIDPI_IMAGES = YES;
DEPLOYMENT_POSTPROCESSING = YES;
Expand Down Expand Up @@ -3027,6 +3029,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -3088,6 +3091,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down
9 changes: 5 additions & 4 deletions Vienna/Sources/Application/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#import "FolderView.h"
#import "SubscriptionModel.h"
#import "Vienna-Swift.h"
#import "GeneratedAssetSymbols.h"

#define VNA_LOG os_log_create("--", "AppController")

Expand Down Expand Up @@ -1512,13 +1513,13 @@ -(void)setAppStatusBarIcon
{
if (appStatusItem != nil) {
if (lastCountOfUnread == 0) {
NSImage *statusBarImage = [NSImage imageNamed:@"statusBarIcon"];
NSImage *statusBarImage = [NSImage imageNamed:ACImageNameStatusBarIcon];
statusBarImage.template = YES;
appStatusItem.button.image = statusBarImage;
appStatusItem.button.title = @"";
appStatusItem.button.imagePosition = NSImageOnly;
} else {
NSImage *statusBarImage = [NSImage imageNamed:@"statusBarIconUnread"];
NSImage *statusBarImage = [NSImage imageNamed:ACImageNameStatusBarIconUnread];
statusBarImage.template = YES;
appStatusItem.button.image = statusBarImage;
appStatusItem.button.title = [NSString stringWithFormat:@"%ld", (long)lastCountOfUnread];
Expand Down Expand Up @@ -1764,7 +1765,7 @@ -(void)handleRefreshStatusChange:(NSNotification *)nc
// Toggle the refresh button
NSToolbarItem *item = [self toolbarItemWithIdentifier:@"Refresh"];
item.action = @selector(cancelAllRefreshesToolbar:);
item.image = [NSImage imageNamed:@"CancelTemplate"];
item.image = [NSImage imageNamed:ACImageNameCancelTemplate];
} else {
// Run the auto-expire now
Preferences * prefs = [Preferences standardPreferences];
Expand All @@ -1773,7 +1774,7 @@ -(void)handleRefreshStatusChange:(NSNotification *)nc
// Toggle the refresh button
NSToolbarItem *item = [self toolbarItemWithIdentifier:@"Refresh"];
item.action = @selector(refreshAllSubscriptions:);
item.image = [NSImage imageNamed:@"SyncTemplate"];
item.image = [NSImage imageNamed:ACImageNameSyncTemplate];

[self showUnreadCountOnApplicationIconAndWindowTitle];

Expand Down
15 changes: 8 additions & 7 deletions Vienna/Sources/Main window/ArticleListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "EnclosureView.h"
#import "Database.h"
#import "Vienna-Swift.h"
#import "GeneratedAssetSymbols.h"

// Shared defaults key
NSString * const MAPref_ShowEnclosureBar = @"ShowEnclosureBar";
Expand Down Expand Up @@ -482,11 +483,11 @@ -(void)updateVisibleColumns
[articleList setTableColumnHeaderImage:enclImage
forColumnWithIdentifier:MA_Field_HasEnclosure];
} else {
[articleList setTableColumnHeaderImage:[NSImage imageNamed:@"unread_header"]
[articleList setTableColumnHeaderImage:[NSImage imageNamed:ACImageNameUnreadHeader]
forColumnWithIdentifier:MA_Field_Read];
[articleList setTableColumnHeaderImage:[NSImage imageNamed:@"flagged_header"]
[articleList setTableColumnHeaderImage:[NSImage imageNamed:ACImageNameFlaggedHeader]
forColumnWithIdentifier:MA_Field_Flagged];
[articleList setTableColumnHeaderImage:[NSImage imageNamed:@"enclosure_header"]
[articleList setTableColumnHeaderImage:[NSImage imageNamed:ACImageNameEnclosureHeader]
forColumnWithIdentifier:MA_Field_HasEnclosure];
}

Expand Down Expand Up @@ -1213,9 +1214,9 @@ -(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColum
return image;
} else {
if (theArticle.revised) {
return [NSImage imageNamed:@"revised"];
return [NSImage imageNamed:ACImageNameRevised];
} else {
return [NSImage imageNamed:@"unread"];
return [NSImage imageNamed:ACImageNameUnread];
}
}
}
Expand All @@ -1230,7 +1231,7 @@ -(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColum
image.template = NO;
return image;
} else {
return [NSImage imageNamed:@"flagged"];
return [NSImage imageNamed:ACImageNameFlagged];
}
}
return nil;
Expand All @@ -1242,7 +1243,7 @@ -(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColum
accessibilityDescription:nil];
return image;
} else {
return [NSImage imageNamed:@"enclosure"];
return [NSImage imageNamed:ACImageNameEnclosure];
}
}
return nil;
Expand Down
3 changes: 2 additions & 1 deletion Vienna/Sources/Main window/EnclosureView.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "DSClickableURLTextField.h"
#import "NSWorkspace+OpenWithMenu.h"
#import "HelperFunctions.h"
#import "GeneratedAssetSymbols.h"

@interface EnclosureView ()

Expand Down Expand Up @@ -149,7 +150,7 @@ -(IBAction)openFile:(id)sender
* Paint the enclosure background.
*/
- (void)drawRect:(NSRect)rect {
[[NSColor colorNamed:@"AttachmentView"] setFill];
[[NSColor colorNamed:ACColorNameAttachmentViewBackground] setFill];
NSRectFill(self.bounds);
}

Expand Down
2 changes: 1 addition & 1 deletion Vienna/Sources/Main window/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ extension MainWindowController: NSToolbarDelegate {
if #available(macOS 11, *) {
item.image = NSImage(systemSymbolName: "envelope", accessibilityDescription: nil)
} else {
item.image = NSImage(named: "MailTemplate")
item.image = NSImage(resource: .mailTemplate)
}
return item
}
Expand Down
20 changes: 4 additions & 16 deletions Vienna/Sources/Main window/OverlayStatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class OverlayStatusBar: NSView {
private var addressField: NSTextField = {
let addressField = NSTextField(labelWithString: "")
addressField.font = .systemFont(ofSize: 12, weight: .medium)
addressField.textColor = .overlayStatusBarPrimaryLabelColor
addressField.textColor = NSColor(resource: .overlayStatusBarPrimaryText)
addressField.lineBreakMode = .byTruncatingMiddle
addressField.allowsDefaultTighteningForTruncation = true

Expand Down Expand Up @@ -185,15 +185,15 @@ final class OverlayStatusBar: NSView {
urlFormatter.defaultAttributes = [
.font: NSFont.systemFont(ofSize: 12, weight: .medium),
.paragraphStyle: paragraphStyle,
.foregroundColor: NSColor.overlayStatusBarPrimaryLabelColor
.foregroundColor: NSColor(resource: .overlayStatusBarPrimaryText)
]
urlFormatter.primaryAttributes = [
.font: NSFont.systemFont(ofSize: 12, weight: .medium),
.foregroundColor: NSColor.overlayStatusBarPrimaryLabelColor
.foregroundColor: NSColor(resource: .overlayStatusBarPrimaryText)
]
urlFormatter.secondaryAttributes = [
.font: NSFont.systemFont(ofSize: 12, weight: .regular),
.foregroundColor: NSColor.overlayStatusBarSecondaryLabelColor
.foregroundColor: NSColor(resource: .overlayStatusBarSecondaryText)
]

return urlFormatter
Expand Down Expand Up @@ -344,15 +344,3 @@ final class OverlayStatusBar: NSView {
}

}

private extension NSColor {

class var overlayStatusBarPrimaryLabelColor: NSColor {
return NSColor(named: "OverlayStatusBarPrimaryTextColor")!
}

class var overlayStatusBarSecondaryLabelColor: NSColor {
return NSColor(named: "OverlayStatusBarSecondaryTextColor")!
}

}
15 changes: 8 additions & 7 deletions Vienna/Sources/Models/Folder.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "ArticleRef.h"
#import "Database.h"
#import "Article.h"
#import "GeneratedAssetSymbols.h"

@interface Folder ()

Expand Down Expand Up @@ -136,39 +137,39 @@ -(NSImage * _Nullable)image {
folderImage = [NSImage imageWithSystemSymbolName:@"gearshape"
accessibilityDescription:nil];
} else {
folderImage = [NSImage imageNamed:@"smartFolder"];
folderImage = [NSImage imageNamed:ACImageNameSmartFolder];
}
break;
case VNAFolderTypeGroup:
if (@available(macOS 11, *)) {
folderImage = [NSImage imageWithSystemSymbolName:@"folder"
accessibilityDescription:nil];
} else {
folderImage = [NSImage imageNamed:@"rssFolder"];
folderImage = [NSImage imageNamed:ACImageNameRSSFolder];
}
break;
case VNAFolderTypeTrash:
if (@available(macOS 11, *)) {
folderImage = [NSImage imageWithSystemSymbolName:@"trash"
accessibilityDescription:nil];
} else {
folderImage = [NSImage imageNamed:@"trashFolder"];
folderImage = [NSImage imageNamed:ACImageNameTrashFolder];
}
break;
case VNAFolderTypeSearch:
if (@available(macOS 11, *)) {
folderImage = [NSImage imageWithSystemSymbolName:@"magnifyingglass"
accessibilityDescription:nil];
} else {
folderImage = [NSImage imageNamed:@"searchFolder"];
folderImage = [NSImage imageNamed:ACImageNameSearchFolder];
}
break;
case VNAFolderTypeRSS:
case VNAFolderTypeOpenReader: {
NSString *homePageSiteRoot = self.homePage.vna_host.vna_convertStringToValidPath;
folderImage = [FolderImageCache.defaultCache retrieveImage:homePageSiteRoot];
if (!folderImage) {
folderImage = [NSImage imageNamed:@"rssFeed"];
folderImage = [NSImage imageNamed:ACImageNameRSSFeed];
}
break;
}
Expand All @@ -177,7 +178,7 @@ -(NSImage * _Nullable)image {
folderImage = [NSImage imageWithSystemSymbolName:@"folder.badge.questionmark"
accessibilityDescription:nil];
} else {
folderImage = [NSImage imageNamed:@"smallFolder"];
folderImage = [NSImage imageNamed:ACImageNameSmallFolder];
}
break;
}
Expand Down Expand Up @@ -208,7 +209,7 @@ -(NSImage *)standardImage {
switch (self.type) {
case VNAFolderTypeRSS:
case VNAFolderTypeOpenReader:
return [NSImage imageNamed:@"rssFeed"];
return [NSImage imageNamed:ACImageNameRSSFeed];
default:
return self.image;
}
Expand Down

0 comments on commit 5acc49d

Please sign in to comment.