Browse Source

Gracefully handle symbol image for pre 11.00.

pull/92/head
Abhishek 4 years ago
parent
commit
f2b1849001
  1. 27
      Clocker/Overall App/Themer.swift

27
Clocker/Overall App/Themer.swift

@ -151,8 +151,8 @@ extension Themer {
} }
func shutdownImage() -> NSImage { func shutdownImage() -> NSImage {
if #available(macOS 10.16, *) { if let symbolImageForShutdown = symbolImage(for: "ellipsis.circle") {
return symbolImage(for: "ellipsis.circle") return symbolImageForShutdown
} }
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -170,8 +170,8 @@ extension Themer {
} }
func preferenceImage() -> NSImage { func preferenceImage() -> NSImage {
if #available(macOS 10.16, *) { if let symbolImageForPreference = symbolImage(for: "gear") {
return symbolImage(for: "gear") return symbolImageForPreference
} }
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -192,8 +192,8 @@ extension Themer {
} }
func pinImage() -> NSImage { func pinImage() -> NSImage {
if #available(macOS 10.16, *) { if let pinImage = symbolImage(for: "macwindow.on.rectangle") {
return symbolImage(for: "macwindow.on.rectangle") return pinImage
} }
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -316,8 +316,8 @@ extension Themer {
} }
func sharingImage() -> NSImage { func sharingImage() -> NSImage {
if #available(macOS 10.16, *) { if let sharingImage = symbolImage(for: "square.and.arrow.up.on.square.fill") {
return symbolImage(for: "square.and.arrow.up.on.square.fill") return sharingImage
} }
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
@ -445,15 +445,14 @@ extension Themer {
NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.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 symbolImage(for name: String) -> NSImage { func symbolImage(for name: String) -> NSImage? {
assert(name.count > 0) assert(name.count > 0)
if #available(OSX 10.16, *) { if #available(OSX 10.16, *) {
return NSImage(systemSymbolName: name, // return NSImage(systemSymbolName: name,
accessibilityDescription: name)! // accessibilityDescription: name)!
} else {
// Dummy image for older xcodes
return NSImage(named: NSImage.Name("Calendar Tab Icon"))!
} }
return nil
} }
} }

Loading…
Cancel
Save