Browse Source

Better looksy when system theme mode is chosen.

pull/101/head
Abhishek 3 years ago
parent
commit
2fab0984fa
  1. 31
      Clocker/Overall App/Themer.swift

31
Clocker/Overall App/Themer.swift

@ -105,7 +105,7 @@ extension Themer {
return themeIndex == .dark ? NSColor.white : NSColor.gray return themeIndex == .dark ? NSColor.white : NSColor.gray
} }
func mainControlColor() -> NSColor { func mainBackgroundColor() -> NSColor {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
@ -113,26 +113,27 @@ extension Themer {
case .dark: case .dark:
return NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) return NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0)
case .system: case .system:
return NSColor.controlBackgroundColor return retrieveCurrentSystem() == .light ? NSColor.white : NSColor.windowBackgroundColor
} }
} }
return themeIndex == .light ? NSColor.white : NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.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 mainBackgroundColor() -> NSColor { private func retrieveCurrentSystem() -> Theme {
if #available(macOS 10.14, *) { if #available(OSX 10.15, *) {
switch themeIndex { let appearanceDescription = NSApplication.shared.effectiveAppearance.debugDescription.lowercased()
case .light: if appearanceDescription.contains("dark") {
return NSColor.white return .dark
case .dark: }
return NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) } else if #available(OSX 10.14, *) {
case .system: if let appleInterfaceStyle = UserDefaults.standard.object(forKey: "AppleInterfaceStyle") as? String {
return NSColor.windowBackgroundColor if appleInterfaceStyle.lowercased().contains("dark") {
return .dark
}
} }
} }
return .light
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 mainTextColor() -> NSColor { func mainTextColor() -> NSColor {
@ -433,7 +434,7 @@ extension Themer {
case .dark: case .dark:
return NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) return NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0)
case .system: case .system:
return NSColor.controlBackgroundColor return retrieveCurrentSystem() == .light ? NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) : NSColor.controlBackgroundColor
} }
} }

Loading…
Cancel
Save