diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index b180261c4..d77797279 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -46,4 +46,6 @@ - (void)menuWillOpen:(NSMenu*)menu; - (void)menuDidClose:(NSMenu*)menu; +- (void)darkModeChanged:(NSNotification*)note; + @end diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 6acac165e..f60ccb6b6 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -44,7 +44,19 @@ name:StatusUpdateKey object:nil]; - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + NSString *osxMode = [defaults stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(darkModeChanged:) + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; [self buildMenu]; @@ -82,6 +94,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification { [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSDistributedNotificationCenter defaultCenter] removeObserver:self + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; } - (void)showNetworks { @@ -277,4 +292,15 @@ } +- (void)darkModeChanged:(NSNotification*)note { + NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } +} + @end diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json index a680b58b8..84b363863 100644 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -7,7 +7,6 @@ }, { "idiom" : "mac", - "filename" : "MenuBar@2x.png", "scale" : "2x" } ], diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png index 84ca66261..ee0d7e3fd 100644 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json new file mode 100644 index 000000000..cd55e6eb4 --- /dev/null +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "filename" : "MenubarWhite.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png similarity index 81% rename from ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png rename to ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png index ce46c151f..7049ae550 100644 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png and b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png differ