fix: use effectiveAppearance to check dark mode on mojave and above (#18666)

* fix: use effectiveAppearance to check dark mode on mojave and above

* chore: add forward declarations for dark appearance
This commit is contained in:
Samuel Attard 2019-06-07 12:01:04 -07:00 committed by GitHub
parent bb19142389
commit ad54d38678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,8 +7,10 @@
#include <string>
#include <vector>
#include "atom/browser/mac/atom_application.h"
#include "atom/browser/ui/cocoa/NSString+ANSI.h"
#include "atom/browser/ui/cocoa/atom_menu_controller.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
#include "ui/display/screen.h"
#include "ui/events/cocoa/cocoa_event_utils.h"
@ -146,6 +148,10 @@ const CGFloat kVerticalTitleMargin = 2;
}
- (BOOL)isDarkMode {
if (@available(macOS 10.14, *)) {
return [[NSApplication sharedApplication].effectiveAppearance.name
isEqualToString:NSAppearanceNameDarkAqua];
}
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString* mode = [defaults stringForKey:@"AppleInterfaceStyle"];
return mode && [mode isEqualToString:@"Dark"];