From 9f48176145c424aef08a33d54a43d02f68bcaed4 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 23 Jan 2020 15:05:17 -0800 Subject: [PATCH] fix: about panel credits should be dark mode aware --- shell/browser/browser_mac.mm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index 2b9625e1dfb64..9e07b800a7557 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -377,11 +377,22 @@ void RemoveFromLoginItems() { NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_); // Credits must be a NSAttributedString instead of NSString - id credits = options[@"Credits"]; + 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"] = [[[NSAttributedString alloc] - initWithString:(NSString*)credits] autorelease]; + mutable_options[@"Credits"] = creditString; options = [NSDictionary dictionaryWithDictionary:mutable_options]; }