Browse Source

Organizing..

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
78ad8f79e3
  1. 261
      Clocker/Overall App/Themer.swift

261
Clocker/Overall App/Themer.swift

@ -188,117 +188,67 @@ extension Themer {
if let symbolImageForPreference = symbolImage(for: "plus") { if let symbolImageForPreference = symbolImage(for: "plus") {
return symbolImageForPreference return symbolImageForPreference
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Settings"))!,
switch themeIndex { NSImage(named: NSImage.Name("Settings-White"))!,
case .light: NSImage(named: NSImage.actionTemplateName)!,
return NSImage(named: NSImage.Name("Settings"))! NSImage(named: NSImage.Name("Settings"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Settings-White"))!)
return NSImage(named: NSImage.Name("Settings-White"))!
case .system:
return NSImage(named: NSImage.actionTemplateName)!
case .solarizedLight:
return NSImage(named: NSImage.Name("Settings"))!
}
}
return
themeIndex == .light
? NSImage(named: NSImage.Name("Settings"))!
: NSImage(named: NSImage.Name("Settings-White"))!
} }
func pinImage() -> NSImage { func pinImage() -> NSImage {
if let pinImage = symbolImage(for: "macwindow.on.rectangle") { if let pinImage = symbolImage(for: "macwindow.on.rectangle") {
return pinImage return pinImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Float"))!,
switch themeIndex { NSImage(named: NSImage.Name("Float-White"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Pin"))!,
return NSImage(named: NSImage.Name("Float"))! NSImage(named: NSImage.Name("Float"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Float-White"))!)
return NSImage(named: NSImage.Name("Float-White"))!
case .system:
return NSImage(named: NSImage.Name("Pin"))!
}
}
return themeIndex == .light
? NSImage(named: NSImage.Name("Float"))!
: NSImage(named: NSImage.Name("Float-White"))!
} }
func sunriseImage() -> NSImage { func sunriseImage() -> NSImage {
if let symbolImage = symbolImage(for: "sunrise.fill") { if let symbolImage = symbolImage(for: "sunrise.fill") {
return symbolImage return symbolImage
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Sunrise"))!,
if #available(macOS 10.14, *) { NSImage(named: NSImage.Name("WhiteSunrise"))!,
switch themeIndex { NSImage(named: NSImage.Name("Sunrise Dynamic"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Sunrise"))!,
return NSImage(named: NSImage.Name("Sunrise"))! NSImage(named: NSImage.Name("WhiteSunrise"))!)
case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("WhiteSunrise"))!
case .system:
return NSImage(named: NSImage.Name("Sunrise Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Sunrise"))! : NSImage(named: NSImage.Name("WhiteSunrise"))!
} }
func sunsetImage() -> NSImage { func sunsetImage() -> NSImage {
if let symbolImage = symbolImage(for: "sunset.fill") { if let symbolImage = symbolImage(for: "sunset.fill") {
return symbolImage return symbolImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Sunset"))!,
switch themeIndex { NSImage(named: NSImage.Name("WhiteSunset"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Sunset Dynamic"))!,
return NSImage(named: NSImage.Name("Sunset"))! NSImage(named: NSImage.Name("Sunset"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("WhiteSunset"))!)
return NSImage(named: NSImage.Name("WhiteSunset"))!
case .system:
return NSImage(named: NSImage.Name("Sunset Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Sunset"))! : NSImage(named: NSImage.Name("WhiteSunset"))!
} }
func removeImage() -> NSImage { func removeImage() -> NSImage {
if let symbolImage = symbolImage(for: "xmark") { if let symbolImage = symbolImage(for: "xmark") {
return symbolImage return symbolImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Remove"))!,
switch themeIndex { NSImage(named: NSImage.Name("WhiteRemove"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Remove Dynamic"))!,
return NSImage(named: NSImage.Name("Remove"))! NSImage(named: NSImage.Name("Remove"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("WhiteRemove"))!)
return NSImage(named: NSImage.Name("WhiteRemove"))!
case .system:
return NSImage(named: NSImage.Name("Remove Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Remove"))! : NSImage(named: NSImage.Name("WhiteRemove"))!
} }
func extraOptionsImage() -> NSImage { func extraOptionsImage() -> NSImage {
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Extra"))!,
switch themeIndex { NSImage(named: NSImage.Name("ExtraWhite"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Extra Dynamic"))!,
return NSImage(named: NSImage.Name("Extra"))! NSImage(named: NSImage.Name("Extra"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("ExtraWhite"))!)
return NSImage(named: NSImage.Name("ExtraWhite"))!
case .system:
return NSImage(named: NSImage.Name("Extra Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Extra"))! : NSImage(named: NSImage.Name("ExtraWhite"))!
} }
func menubarOnboardingImage() -> NSImage { func menubarOnboardingImage() -> NSImage {
@ -315,18 +265,11 @@ extension Themer {
} }
func extraOptionsHighlightedImage() -> NSImage { func extraOptionsHighlightedImage() -> NSImage {
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("ExtraHighlighted"))!,
switch themeIndex { NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("ExtraHighlighted Dynamic"))!,
return NSImage(named: NSImage.Name("ExtraHighlighted"))! NSImage(named: NSImage.Name("ExtraHighlighted"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!)
return NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!
case .system:
return NSImage(named: NSImage.Name("ExtraHighlighted Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("ExtraHighlighted"))! : NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!
} }
func sharingImage() -> NSImage { func sharingImage() -> NSImage {
@ -334,18 +277,11 @@ extension Themer {
return sharingImage return sharingImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Sharing"))!,
switch themeIndex { NSImage(named: NSImage.Name("SharingDarkIcon"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("Sharing Dynamic"))!,
return NSImage(named: NSImage.Name("Sharing"))! NSImage(named: NSImage.Name("Sharing"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("SharingDarkIcon"))!)
return NSImage(named: NSImage.Name("SharingDarkIcon"))!
case .system:
return NSImage(named: NSImage.Name("Sharing Dynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.shareTemplateName)! : NSImage(named: NSImage.Name("SharingDarkIcon"))!
} }
func currentLocationImage() -> NSImage { func currentLocationImage() -> NSImage {
@ -353,18 +289,11 @@ extension Themer {
return symbolImage return symbolImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("CurrentLocation"))!,
switch themeIndex { NSImage(named: NSImage.Name("CurrentLocationWhite"))!,
case .light, .solarizedLight: NSImage(named: NSImage.Name("CurrentLocationDynamic"))!,
return NSImage(named: NSImage.Name("CurrentLocation"))! NSImage(named: NSImage.Name("CurrentLocation"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("CurrentLocationWhite"))!)
return NSImage(named: NSImage.Name("CurrentLocationWhite"))!
case .system:
return NSImage(named: NSImage.Name("CurrentLocationDynamic"))!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("CurrentLocation"))! : NSImage(named: NSImage.Name("CurrentLocationWhite"))!
} }
func popoverAppearance() -> NSAppearance { func popoverAppearance() -> NSAppearance {
@ -387,18 +316,11 @@ extension Themer {
return symbolImageForPreference return symbolImageForPreference
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Add Icon"))!,
switch themeIndex { NSImage(named: NSImage.Name("Add White"))!,
case .light, .solarizedLight: NSImage(named: .addDynamicIcon)!,
return NSImage(named: NSImage.Name("Add Icon"))! NSImage(named: NSImage.Name("Add Icon"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Add White"))!)
return NSImage(named: NSImage.Name("Add White"))!
case .system:
return NSImage(named: .addDynamicIcon)!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Add Icon"))! : NSImage(named: NSImage.Name("Add White"))!
} }
func addImageHighlighted() -> NSImage { func addImageHighlighted() -> NSImage {
@ -410,18 +332,11 @@ extension Themer {
return privacyTabSFImage return privacyTabSFImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Privacy"))!,
switch themeIndex { NSImage(named: NSImage.Name("Privacy Dark"))!,
case .light, .solarizedLight: NSImage(named: .permissionTabIcon)!,
return NSImage(named: NSImage.Name("Privacy"))! NSImage(named: NSImage.Name("Privacy"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Privacy Dark"))!)
return NSImage(named: NSImage.Name("Privacy Dark"))!
case .system:
return NSImage(named: .permissionTabIcon)!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Privacy"))! : NSImage(named: NSImage.Name("Privacy Dark"))!
} }
func appearanceTabImage() -> NSImage { func appearanceTabImage() -> NSImage {
@ -429,18 +344,11 @@ extension Themer {
return appearanceTabImage return appearanceTabImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Appearance"))!,
switch themeIndex { NSImage(named: NSImage.Name("Appearance Dark"))!,
case .light, .solarizedLight: NSImage(named: .appearanceTabIcon)!,
return NSImage(named: NSImage.Name("Appearance"))! NSImage(named: NSImage.Name("Appearance"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Appearance Dark"))!)
return NSImage(named: NSImage.Name("Appearance Dark"))!
case .system:
return NSImage(named: .appearanceTabIcon)!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Appearance"))! : NSImage(named: NSImage.Name("Appearance Dark"))!
} }
func calendarTabImage() -> NSImage { func calendarTabImage() -> NSImage {
@ -448,18 +356,11 @@ extension Themer {
return calendarTabImage return calendarTabImage
} }
if #available(macOS 10.14, *) { return fallbackImageProvider(NSImage(named: NSImage.Name("Calendar Tab Icon"))!,
switch themeIndex { NSImage(named: NSImage.Name("Calendar Tab Dark"))!,
case .light, .solarizedLight: NSImage(named: .calendarTabIcon)!,
return NSImage(named: NSImage.Name("Calendar Tab Icon"))! NSImage(named: NSImage.Name("Calendar Tab Icon"))!,
case .dark, .solarizedDark: NSImage(named: NSImage.Name("Calendar Tab Dark"))!)
return NSImage(named: NSImage.Name("Calendar Tab Dark"))!
case .system:
return NSImage(named: .calendarTabIcon)!
}
}
return themeIndex == .light ? NSImage(named: NSImage.Name("Calendar Tab Icon"))! : NSImage(named: NSImage.Name("Calendar Tab Dark"))!
} }
func generalTabImage() -> NSImage? { func generalTabImage() -> NSImage? {
@ -549,5 +450,29 @@ extension Themer {
NSApp.appearance = appAppearance NSApp.appearance = appAppearance
} }
} }
private func fallbackImageProvider(_ lightImage: NSImage,
_ darkImage: NSImage,
_ systemImage: NSImage,
_ 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
}
}
return themeIndex == .light ? lightImage : darkImage
}
} }

Loading…
Cancel
Save