Skip to content

Commit

Permalink
use textColor for automatic adaptability
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jan 27, 2020
1 parent 55e2049 commit d55cf84
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions shell/browser/browser_mac.mm
Expand Up @@ -379,20 +379,16 @@ void RemoveFromLoginItems() {
// Credits must be a NSAttributedString instead of NSString
NSString* credits = (NSString*)options[@"Credits"];
if (credits != nil) {
// Check if app is running in dark mode
NSString* mode = [[NSUserDefaults standardUserDefaults]
stringForKey:@"AppleInterfaceStyle"];
BOOL isDarkMode = [mode isEqualToString:@"Dark"];

// Set color of credits depending on if we're in dark mode or not.
NSColor* color = isDarkMode ? [NSColor whiteColor] : [NSColor blackColor];
NSAttributedString* creditString = [[NSAttributedString alloc]
initWithString:credits
attributes:@{NSForegroundColorAttributeName : color}];

// Cast back to NSDictionary with updated options
NSMutableDictionary* mutable_options = [options mutableCopy];
mutable_options[@"Credits"] = creditString;
base::scoped_nsobject<NSMutableDictionary> mutable_options(
[options mutableCopy]);
base::scoped_nsobject<NSAttributedString> creditString(
[[NSAttributedString alloc]
initWithString:credits
attributes:@{
NSForegroundColorAttributeName : [NSColor textColor]
}]);

[mutable_options setValue:creditString forKey:@"Credits"];
options = [NSDictionary dictionaryWithDictionary:mutable_options];
}

Expand Down

0 comments on commit d55cf84

Please sign in to comment.