Browse Source

New theme + SF Symbols for tab images.

pull/101/head
Abhishek 4 years ago
parent
commit
4235dcbd03
  1. 102
      Clocker/Overall App/Themer.swift
  2. 3
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  3. 7
      Clocker/Preferences/General/PreferencesViewController.swift
  4. 10
      Clocker/Preferences/OneWindowController.swift

102
Clocker/Overall App/Themer.swift

@ -18,6 +18,8 @@ enum Theme: Int {
case light = 0 case light = 0
case dark case dark
case system case system
case solarizedLight
case solarizedDark
} }
class Themer: NSObject { class Themer: NSObject {
@ -39,6 +41,10 @@ class Themer: NSObject {
themeIndex = Theme.dark themeIndex = Theme.dark
case 2: case 2:
themeIndex = Theme.system themeIndex = Theme.system
case 3:
themeIndex = Theme.solarizedLight
case 4:
themeIndex = Theme.solarizedDark
default: default:
themeIndex = Theme.light themeIndex = Theme.light
} }
@ -71,6 +77,10 @@ extension Themer {
themeIndex = Theme.dark themeIndex = Theme.dark
case 2: case 2:
themeIndex = Theme.system themeIndex = Theme.system
case 3:
themeIndex = Theme.solarizedLight
case 4:
themeIndex = Theme.solarizedDark
default: default:
themeIndex = Theme.light themeIndex = Theme.light
} }
@ -114,6 +124,10 @@ extension Themer {
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 retrieveCurrentSystem() == .light ? NSColor.white : NSColor.windowBackgroundColor 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)
} }
} }
@ -145,6 +159,10 @@ extension Themer {
return NSColor.white return NSColor.white
case .system: case .system:
return NSColor.textColor return NSColor.textColor
case .solarizedLight:
return NSColor.black
case .solarizedDark:
return NSColor.white
} }
} }
@ -160,10 +178,12 @@ extension Themer {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSImage(named: NSImage.Name("PowerIcon"))! return NSImage(named: NSImage.Name("PowerIcon"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("PowerIcon-White"))! return NSImage(named: NSImage.Name("PowerIcon-White"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Power"))! return NSImage(named: NSImage.Name("Power"))!
case .solarizedLight:
return NSImage(named: NSImage.Name("PowerIcon"))!
} }
} }
@ -179,10 +199,12 @@ extension Themer {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSImage(named: NSImage.Name("Settings"))! return NSImage(named: NSImage.Name("Settings"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Settings-White"))! return NSImage(named: NSImage.Name("Settings-White"))!
case .system: case .system:
return NSImage(named: NSImage.actionTemplateName)! return NSImage(named: NSImage.actionTemplateName)!
case .solarizedLight:
return NSImage(named: NSImage.Name("Settings"))!
} }
} }
@ -199,9 +221,9 @@ extension Themer {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Float"))! return NSImage(named: NSImage.Name("Float"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Float-White"))! return NSImage(named: NSImage.Name("Float-White"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Pin"))! return NSImage(named: NSImage.Name("Pin"))!
@ -220,9 +242,9 @@ extension Themer {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Sunrise"))! return NSImage(named: NSImage.Name("Sunrise"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("WhiteSunrise"))! return NSImage(named: NSImage.Name("WhiteSunrise"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Sunrise Dynamic"))! return NSImage(named: NSImage.Name("Sunrise Dynamic"))!
@ -239,9 +261,9 @@ extension Themer {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Sunset"))! return NSImage(named: NSImage.Name("Sunset"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("WhiteSunset"))! return NSImage(named: NSImage.Name("WhiteSunset"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Sunset Dynamic"))! return NSImage(named: NSImage.Name("Sunset Dynamic"))!
@ -254,9 +276,9 @@ extension Themer {
func removeImage() -> NSImage { func removeImage() -> NSImage {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Remove"))! return NSImage(named: NSImage.Name("Remove"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("WhiteRemove"))! return NSImage(named: NSImage.Name("WhiteRemove"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Remove Dynamic"))! return NSImage(named: NSImage.Name("Remove Dynamic"))!
@ -269,9 +291,9 @@ extension Themer {
func extraOptionsImage() -> NSImage { func extraOptionsImage() -> NSImage {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Extra"))! return NSImage(named: NSImage.Name("Extra"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("ExtraWhite"))! return NSImage(named: NSImage.Name("ExtraWhite"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Extra Dynamic"))! return NSImage(named: NSImage.Name("Extra Dynamic"))!
@ -297,9 +319,9 @@ extension Themer {
func extraOptionsHighlightedImage() -> NSImage { func extraOptionsHighlightedImage() -> NSImage {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("ExtraHighlighted"))! return NSImage(named: NSImage.Name("ExtraHighlighted"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))! return NSImage(named: NSImage.Name("ExtraWhiteHighlighted"))!
case .system: case .system:
return NSImage(named: NSImage.Name("ExtraHighlighted Dynamic"))! return NSImage(named: NSImage.Name("ExtraHighlighted Dynamic"))!
@ -316,9 +338,9 @@ extension Themer {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Sharing"))! return NSImage(named: NSImage.Name("Sharing"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("SharingDarkIcon"))! return NSImage(named: NSImage.Name("SharingDarkIcon"))!
case .system: case .system:
return NSImage(named: NSImage.Name("Sharing Dynamic"))! return NSImage(named: NSImage.Name("Sharing Dynamic"))!
@ -335,9 +357,9 @@ extension Themer {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("CurrentLocation"))! return NSImage(named: NSImage.Name("CurrentLocation"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("CurrentLocationWhite"))! return NSImage(named: NSImage.Name("CurrentLocationWhite"))!
case .system: case .system:
return NSImage(named: NSImage.Name("CurrentLocationDynamic"))! return NSImage(named: NSImage.Name("CurrentLocationDynamic"))!
@ -350,9 +372,9 @@ extension Themer {
func popoverAppearance() -> NSAppearance { func popoverAppearance() -> NSAppearance {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSAppearance(named: NSAppearance.Name.vibrantLight)! return NSAppearance(named: NSAppearance.Name.vibrantLight)!
case .dark: case .dark, .solarizedDark:
return NSAppearance(named: NSAppearance.Name.vibrantDark)! return NSAppearance(named: NSAppearance.Name.vibrantDark)!
case .system: case .system:
return NSAppearance.current return NSAppearance.current
@ -365,9 +387,9 @@ extension Themer {
func addImage() -> NSImage { func addImage() -> NSImage {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Add Icon"))! return NSImage(named: NSImage.Name("Add Icon"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Add White"))! return NSImage(named: NSImage.Name("Add White"))!
case .system: case .system:
return NSImage(named: .addDynamicIcon)! return NSImage(named: .addDynamicIcon)!
@ -382,11 +404,15 @@ extension Themer {
} }
func privacyTabImage() -> NSImage { func privacyTabImage() -> NSImage {
if let privacyTabSFImage = symbolImage(for: "lock") {
return privacyTabSFImage
}
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Privacy"))! return NSImage(named: NSImage.Name("Privacy"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Privacy Dark"))! return NSImage(named: NSImage.Name("Privacy Dark"))!
case .system: case .system:
return NSImage(named: .permissionTabIcon)! return NSImage(named: .permissionTabIcon)!
@ -397,11 +423,15 @@ extension Themer {
} }
func appearanceTabImage() -> NSImage { func appearanceTabImage() -> NSImage {
if let appearanceTabImage = symbolImage(for: "eye") {
return appearanceTabImage
}
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Appearance"))! return NSImage(named: NSImage.Name("Appearance"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Appearance Dark"))! return NSImage(named: NSImage.Name("Appearance Dark"))!
case .system: case .system:
return NSImage(named: .appearanceTabIcon)! return NSImage(named: .appearanceTabIcon)!
@ -412,11 +442,15 @@ extension Themer {
} }
func calendarTabImage() -> NSImage { func calendarTabImage() -> NSImage {
if let calendarTabImage = symbolImage(for: "calendar") {
return calendarTabImage
}
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light, .solarizedLight:
return NSImage(named: NSImage.Name("Calendar Tab Icon"))! return NSImage(named: NSImage.Name("Calendar Tab Icon"))!
case .dark: case .dark, .solarizedDark:
return NSImage(named: NSImage.Name("Calendar Tab Dark"))! return NSImage(named: NSImage.Name("Calendar Tab Dark"))!
case .system: case .system:
return NSImage(named: .calendarTabIcon)! return NSImage(named: .calendarTabIcon)!
@ -425,6 +459,14 @@ extension Themer {
return themeIndex == .light ? NSImage(named: NSImage.Name("Calendar Tab Icon"))! : NSImage(named: NSImage.Name("Calendar Tab Dark"))! return themeIndex == .light ? NSImage(named: NSImage.Name("Calendar Tab Icon"))! : NSImage(named: NSImage.Name("Calendar Tab Dark"))!
} }
func generalTabImage() -> NSImage? {
return symbolImage(for: "gearshape")
}
func aboutTabImage() -> NSImage? {
return symbolImage(for: "info.circle")
}
func textBackgroundColor() -> NSColor { func textBackgroundColor() -> NSColor {
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -435,6 +477,10 @@ extension Themer {
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 retrieveCurrentSystem() == .light ? NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) : 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
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: 88.0 / 255.0, green: 110.0 / 255.0, blue: 117.0 / 255.0, alpha: 1.0)
} }
} }

3
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -148,6 +148,7 @@ class AppearanceViewController: ParentViewController {
@IBOutlet var menubarModeLabel: NSTextField! @IBOutlet var menubarModeLabel: NSTextField!
@IBOutlet var previewLabel: NSTextField! @IBOutlet var previewLabel: NSTextField!
@IBOutlet var miscelleaneousLabel: NSTextField! @IBOutlet var miscelleaneousLabel: NSTextField!
@IBOutlet weak var dstTransitionField: NSTextField!
// Panel Preview // Panel Preview
@IBOutlet var previewPanelTableView: NSTableView! @IBOutlet var previewPanelTableView: NSTableView!
@ -171,7 +172,7 @@ class AppearanceViewController: ParentViewController {
dayDisplayOptionsLabel, showSliderLabel, dayDisplayOptionsLabel, showSliderLabel,
showSunriseLabel, largerTextLabel, futureSliderRangeLabel, showSunriseLabel, largerTextLabel, futureSliderRangeLabel,
includeDayLabel, includeDateLabel, includePlaceLabel, appDisplayLabel, menubarModeLabel, includeDayLabel, includeDateLabel, includePlaceLabel, appDisplayLabel, menubarModeLabel,
previewLabel, miscelleaneousLabel].forEach { previewLabel, miscelleaneousLabel, dstTransitionField].forEach {
$0?.textColor = Themer.shared().mainTextColor() $0?.textColor = Themer.shared().mainTextColor()
} }
} }

7
Clocker/Preferences/General/PreferencesViewController.swift

@ -45,7 +45,7 @@ class PreferencesViewController: ParentViewController {
let dictionary = NSDictionary(contentsOfFile: path), let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String let apiKey = dictionary["GeocodingKey"] as? String
else { else {
assertionFailure("Unable to find the API key") // assertionFailure("Unable to find the API key")
return "" return ""
} }
return apiKey return apiKey
@ -248,6 +248,11 @@ class PreferencesViewController: ParentViewController {
]) ])
} }
timezoneTableView.backgroundColor = Themer.shared().mainBackgroundColor()
availableTimezoneTableView.backgroundColor = Themer.shared().mainBackgroundColor()
timezonePanel.backgroundColor = Themer.shared().textBackgroundColor()
timezonePanel.contentView?.wantsLayer = true
timezonePanel.contentView?.layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
addTimezoneButton.image = themer.addImage() addTimezoneButton.image = themer.addImage()
deleteButton.image = themer.removeImage() deleteButton.image = themer.removeImage()
} }

10
Clocker/Preferences/OneWindowController.swift

@ -81,9 +81,17 @@ class OneWindowController: NSWindowController {
} }
let themer = Themer.shared() let themer = Themer.shared()
let identifierTOImageMapping: [String: NSImage] = ["Appearance Tab": themer.appearanceTabImage(), var identifierTOImageMapping: [String: NSImage] = ["Appearance Tab": themer.appearanceTabImage(),
"Calendar Tab": themer.calendarTabImage(), "Calendar Tab": themer.calendarTabImage(),
"Permissions Tab": themer.privacyTabImage()] "Permissions Tab": themer.privacyTabImage()]
if let prefsTabImage = themer.generalTabImage() {
identifierTOImageMapping["Preferences Tab"] = prefsTabImage
}
if let aboutTabImage = themer.aboutTabImage() {
identifierTOImageMapping["About Tab"] = aboutTabImage
}
tabViewController.tabViewItems.forEach { tabViewItem in tabViewController.tabViewItems.forEach { tabViewItem in
let identity = (tabViewItem.identifier as? String) ?? "" let identity = (tabViewItem.identifier as? String) ?? ""

Loading…
Cancel
Save