Skip to content
Permalink
Browse files

#2485: Remove unncessary dark mode check.

  • Loading branch information
stuconnolly committed Oct 3, 2018
1 parent d0fc907 commit 020bc1d5320c6fea3e941ccc6310538420a224da
Showing with 8 additions and 51 deletions.
  1. +8 −51 Source/SPAboutController.m
@@ -39,27 +39,17 @@
static NSString *SPAboutPanelNibName = @"AboutPanel";
static NSString *SPShortVersionHashKey = @"SPVersionShortHash";

static BOOL isOSAtLeast10_14 = NO;

@interface SPAboutController ()

- (BOOL)_isInDarkMode;
- (void)_setVersionLabel:(BOOL)isNightly;
- (NSAttributedString *)_getCreditsText;
- (NSAttributedString *)_getLicenseText;
- (NSAttributedString *)_applyTextAttributes:(NSMutableAttributedString *)text;
- (NSMutableAttributedString *)_loadRtfResource:(NSString *)filename;

@end

@implementation SPAboutController

#pragma mark -

+ (void)initialize
{
isOSAtLeast10_14 = [SPOSInfo isOSVersionAtLeastMajor:10 minor:14 patch:0];
}

- (id)init
{
return [super initWithWindowNibName:SPAboutPanelNibName];
@@ -80,10 +70,10 @@ - (void)awakeFromNib
[self _setVersionLabel:isSnapshotBuild];

// Set the credits
[[appCreditsTextView textStorage] appendAttributedString:[self _getCreditsText]];
[[appCreditsTextView textStorage] appendAttributedString:[self _loadRtfResource:SPCreditsFilename]];

// Set the license
[[appLicenseTextView textStorage] appendAttributedString:[self _getLicenseText]];
[[appLicenseTextView textStorage] appendAttributedString:[self _loadRtfResource:SPLicenseFilename]];
}

#pragma mark -
@@ -109,19 +99,6 @@ - (IBAction)closeApplicationLicenseSheet:(id)sender;
#pragma mark -
#pragma mark Private API

- (BOOL)_isInDarkMode
{
if (isOSAtLeast10_14) {
NSString *match = [[NSAppearance currentAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];

if ([NSAppearanceNameDarkAqua isEqualToString:match]) {
return YES;
}
}

return NO;
}

/**
* Set the UI version labels.
*
@@ -154,35 +131,15 @@ - (void)_setVersionLabel:(BOOL)isSnapshotBuild
}

/**
* Returns the credits string to display in the about dialog.
* Loads the resource with the supplied name and sets any necessary string attributes.
*/
- (NSAttributedString *)_getCreditsText
- (NSAttributedString *)_loadRtfResource:(NSString *)filename
{
NSMutableAttributedString *credits = [[NSMutableAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:SPCreditsFilename ofType:@"rtf"] documentAttributes:nil];

return [[self _applyTextAttributes:credits] autorelease];
}
NSMutableAttributedString *resouece = [[NSMutableAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:@"rtf"] documentAttributes:nil];

This comment has been minimized.

Copy link
@kamui545

This comment has been minimized.

Copy link
@stuconnolly

stuconnolly Oct 4, 2018

Author Member

Ah, thanks.


/**
* Returns the license string to display in the about dialog.
*/
- (NSAttributedString *)_getLicenseText
{
NSMutableAttributedString *license = [[NSMutableAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:SPLicenseFilename ofType:@"rtf"] documentAttributes:nil];

return [[self _applyTextAttributes:license] autorelease];
}

/**
*
*/
- (NSAttributedString *)_applyTextAttributes:(NSMutableAttributedString *)text
{
if ([self _isInDarkMode]) {
[text addAttribute:NSForegroundColorAttributeName value:[NSColor textColor] range:NSMakeRange(0, [text length])];
}
[resouece addAttribute:NSForegroundColorAttributeName value:[NSColor textColor] range:NSMakeRange(0, [resouece length])];

return text;
return [resouece autorelease];
}

@end

0 comments on commit 020bc1d

Please sign in to comment.
You can’t perform that action at this time.