@ -49,10 +49,8 @@ class Themer: NSObject {
name : . interfaceStyleDidChange ,
object : nil )
if #available ( macOS 10.14 , * ) {
effectiveApperanceObserver = NSApp . observe ( \ . effectiveAppearance ) { _ , _ in
NotificationCenter . default . post ( name : . themeDidChangeNotification , object : nil )
}
effectiveApperanceObserver = NSApp . observe ( \ . effectiveAppearance ) { _ , _ in
NotificationCenter . default . post ( name : . themeDidChangeNotification , object : nil )
}
}
}
@ -116,62 +114,48 @@ extension Themer {
}
func mainBackgroundColor ( ) -> NSColor {
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . light :
return NSColor . white
case . dark :
return NSColor ( deviceRed : 42.0 / 255.0 , green : 42.0 / 255.0 , blue : 42.0 / 255.0 , alpha : 1.0 )
case . system :
return retrieveCurrentSystem ( ) = = . light ? NSColor . white : NSColor . windowBackgroundColor
case . solarizedLight :
return NSColor ( deviceRed : 253.0 / 255.0 , green : 246.0 / 255.0 , blue : 227.0 / 255.0 , alpha : 1.0 )
case . solarizedDark :
return NSColor ( deviceRed : 7.0 / 255.0 , green : 54.0 / 255.0 , blue : 66.0 / 255.0 , alpha : 1.0 )
}
switch themeIndex {
case . light :
return NSColor . white
case . dark :
return NSColor ( deviceRed : 42.0 / 255.0 , green : 42.0 / 255.0 , blue : 42.0 / 255.0 , alpha : 1.0 )
case . system :
return retrieveCurrentSystem ( ) = = . light ? NSColor . white : NSColor . windowBackgroundColor
case . solarizedLight :
return NSColor ( deviceRed : 253.0 / 255.0 , green : 246.0 / 255.0 , blue : 227.0 / 255.0 , alpha : 1.0 )
case . solarizedDark :
return NSColor ( deviceRed : 7.0 / 255.0 , green : 54.0 / 255.0 , blue : 66.0 / 255.0 , alpha : 1.0 )
}
return themeIndex = = . light ? NSColor . white : NSColor ( deviceRed : 55.0 / 255.0 , green : 71.0 / 255.0 , blue : 79.0 / 255.0 , alpha : 1.0 )
}
func textBackgroundColor ( ) -> NSColor {
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . light :
return NSColor ( deviceRed : 241.0 / 255.0 , green : 241.0 / 255.0 , blue : 241.0 / 255.0 , alpha : 1.0 )
case . dark :
return NSColor ( deviceRed : 42.0 / 255.0 , green : 55.0 / 255.0 , blue : 62.0 / 255.0 , alpha : 1.0 )
case . system :
return retrieveCurrentSystem ( ) = = . light ? NSColor ( deviceRed : 241.0 / 255.0 , green : 241.0 / 255.0 , blue : 241.0 / 255.0 , alpha : 1.0 ) : NSColor . controlBackgroundColor
case . solarizedLight :
return NSColor ( deviceRed : 238.0 / 255.0 , green : 232.0 / 255.0 , blue : 213.0 / 255.0 , alpha : 1.0 )
case . solarizedDark :
return NSColor ( deviceRed : 0.0 / 255.0 , green : 43.0 / 255.0 , blue : 54.0 / 255.0 , alpha : 1.0 )
}
switch themeIndex {
case . light :
return NSColor ( deviceRed : 241.0 / 255.0 , green : 241.0 / 255.0 , blue : 241.0 / 255.0 , alpha : 1.0 )
case . dark :
return NSColor ( deviceRed : 42.0 / 255.0 , green : 55.0 / 255.0 , blue : 62.0 / 255.0 , alpha : 1.0 )
case . system :
return retrieveCurrentSystem ( ) = = . light ? NSColor ( deviceRed : 241.0 / 255.0 , green : 241.0 / 255.0 , blue : 241.0 / 255.0 , alpha : 1.0 ) : NSColor . controlBackgroundColor
case . solarizedLight :
return NSColor ( deviceRed : 238.0 / 255.0 , green : 232.0 / 255.0 , blue : 213.0 / 255.0 , alpha : 1.0 )
case . solarizedDark :
return NSColor ( deviceRed : 0.0 / 255.0 , green : 43.0 / 255.0 , blue : 54.0 / 255.0 , alpha : 1.0 )
}
return themeIndex = = . light ?
NSColor ( deviceRed : 241.0 / 255.0 , green : 241.0 / 255.0 , blue : 241.0 / 255.0 , alpha : 1.0 ) :
NSColor ( deviceRed : 42.0 / 255.0 , green : 55.0 / 255.0 , blue : 62.0 / 255.0 , alpha : 1.0 )
}
func mainTextColor ( ) -> NSColor {
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . light :
return NSColor . black
case . dark :
return NSColor . white
case . system :
return NSColor . textColor
case . solarizedLight :
return NSColor . black
case . solarizedDark :
return NSColor . white
}
switch themeIndex {
case . light :
return NSColor . black
case . dark :
return NSColor . white
case . system :
return NSColor . textColor
case . solarizedLight :
return NSColor . black
case . solarizedDark :
return NSColor . white
}
return themeIndex = = . light ? NSColor . black : NSColor . white
}
// MARK: I m a g e s
@ -256,18 +240,14 @@ extension Themer {
}
func menubarOnboardingImage ( ) -> NSImage {
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . system :
return NSImage ( named : NSImage . Name ( " Dynamic Menubar " ) ) !
case . light , . solarizedLight :
return NSImage ( named : NSImage . Name ( " Light Menubar " ) ) !
case . dark , . solarizedDark :
return NSImage ( named : NSImage . Name ( " Dark Menubar " ) ) !
}
switch themeIndex {
case . system :
return NSImage ( named : NSImage . Name ( " Dynamic Menubar " ) ) !
case . light , . solarizedLight :
return NSImage ( named : NSImage . Name ( " Light Menubar " ) ) !
case . dark , . solarizedDark :
return NSImage ( named : NSImage . Name ( " Dark Menubar " ) ) !
}
return retrieveCurrentSystem ( ) = = . dark ? NSImage ( named : NSImage . Name ( " Dark Menubar " ) ) ! : NSImage ( named : NSImage . Name ( " Light Menubar " ) ) !
}
func extraOptionsHighlightedImage ( ) -> NSImage {
@ -319,18 +299,14 @@ extension Themer {
}
func popoverAppearance ( ) -> NSAppearance {
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . light , . solarizedLight :
return NSAppearance ( named : NSAppearance . Name . vibrantLight ) !
case . dark , . solarizedDark :
return NSAppearance ( named : NSAppearance . Name . vibrantDark ) !
case . system :
return NSAppearance . current
}
switch themeIndex {
case . light , . solarizedLight :
return NSAppearance ( named : NSAppearance . Name . vibrantLight ) !
case . dark , . solarizedDark :
return NSAppearance ( named : NSAppearance . Name . vibrantDark ) !
case . system :
return NSAppearance . current
}
return themeIndex = = . light ? NSAppearance ( named : NSAppearance . Name . vibrantLight ) ! : NSAppearance ( named : NSAppearance . Name . vibrantDark ) !
}
func addImage ( ) -> NSImage {
@ -457,18 +433,17 @@ extension Themer {
}
private func setAppAppearance ( ) {
if #available ( OSX 10.14 , * ) {
var appAppearance = NSAppearance ( named : . aqua )
var appAppearance = NSAppearance ( named : . aqua )
if themeIndex = = . dark || themeIndex = = . solarizedDark {
appAppearance = NSAppearance ( named : . darkAqua )
} else if themeIndex = = . system {
appAppearance = retrieveCurrentSystem ( ) = = . dark ? NSAppearance ( named : . darkAqua ) : NSAppearance ( named : . aqua )
}
if NSApp . appearance != appAppearance {
NSApp . appearance = appAppearance
}
if themeIndex = = . dark || themeIndex = = . solarizedDark {
appAppearance = NSAppearance ( named : . darkAqua )
} else if themeIndex = = . system {
appAppearance = retrieveCurrentSystem ( ) = = . dark ? NSAppearance ( named : . darkAqua ) : NSAppearance ( named : . aqua )
}
if NSApp . appearance != appAppearance {
NSApp . appearance = appAppearance
}
}
private func fallbackImageProvider ( _ lightImage : NSImage ,
@ -477,21 +452,17 @@ extension Themer {
_ solarizedLightImage : NSImage ,
_ solarizedDarkImage : NSImage ) -> NSImage
{
if #available ( macOS 10.14 , * ) {
switch themeIndex {
case . light :
return lightImage
case . dark :
return darkImage
case . system :
return systemImage
case . solarizedLight :
return solarizedLightImage
case . solarizedDark :
return solarizedDarkImage
}
switch themeIndex {
case . light :
return lightImage
case . dark :
return darkImage
case . system :
return systemImage
case . solarizedLight :
return solarizedLightImage
case . solarizedDark :
return solarizedDarkImage
}
return themeIndex = = . light ? lightImage : darkImage
}
}