Browse Source

Remove 10.14 checks.

master
Abhishek Banthia 9 months ago
parent
commit
511dd23c4a
  1. 6
      Clocker/Overall App/AppKit + Additions.swift
  2. 7
      Clocker/Overall App/Foundation + Additions.swift
  3. 167
      Clocker/Overall App/Themer.swift
  4. 46
      Clocker/Panel/PanelController.swift
  5. 40
      Clocker/Panel/ParentPanelController.swift
  6. 14
      Clocker/Panel/Rate Controller/ReviewController.swift
  7. 30
      Clocker/Panel/UI/TimezoneDataSource.swift
  8. 4
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  9. 4
      Clocker/Preferences/Calendar/CalendarViewController.swift
  10. 106
      Clocker/Preferences/General/PreferencesViewController.swift
  11. 14
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  12. 19
      Clocker/Preferences/Menu Bar/StatusItemView.swift

6
Clocker/Overall App/AppKit + Additions.swift

@ -7,10 +7,8 @@ extension NSTextField {
isBordered = false isBordered = false
allowsDefaultTighteningForTruncation = true allowsDefaultTighteningForTruncation = true
if #available(OSX 10.12.2, *) { isAutomaticTextCompletionEnabled = false
isAutomaticTextCompletionEnabled = false allowsCharacterPickerTouchBarItem = false
allowsCharacterPickerTouchBarItem = false
}
} }
func disableWrapping() { func disableWrapping() {

7
Clocker/Overall App/Foundation + Additions.swift

@ -59,11 +59,6 @@ public extension Data {
extension NSKeyedArchiver { extension NSKeyedArchiver {
static func clocker_archive(with object: Any) -> Data? { static func clocker_archive(with object: Any) -> Data? {
return try? NSKeyedArchiver.archivedData(withRootObject: object, requiringSecureCoding: true)
if #available(macOS 10.14, *) {
return try? NSKeyedArchiver.archivedData(withRootObject: object, requiringSecureCoding: true)
}
return nil
} }
} }

167
Clocker/Overall App/Themer.swift

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

46
Clocker/Panel/PanelController.swift

@ -40,9 +40,7 @@ class PanelController: ParentPanelController {
private func enablePerformanceLoggingIfNeccessary() { private func enablePerformanceLoggingIfNeccessary() {
if !ProcessInfo.processInfo.environment.keys.contains("ENABLE_PERF_LOGGING") { if !ProcessInfo.processInfo.environment.keys.contains("ENABLE_PERF_LOGGING") {
if #available(OSX 10.14, *) { PerfLogger.disable()
PerfLogger.disable()
}
} }
} }
@ -63,9 +61,7 @@ class PanelController: ParentPanelController {
} }
func open() { func open() {
if #available(OSX 10.14, *) { PerfLogger.startMarker("Open")
PerfLogger.startMarker("Open")
}
guard isWindowLoaded == true else { guard isWindowLoaded == true else {
return return
@ -77,7 +73,7 @@ class PanelController: ParentPanelController {
setupUpcomingEventViewCollectionViewIfNeccesary() setupUpcomingEventViewCollectionViewIfNeccesary()
//TODO: Always hide the legacy slider. Delete this once v24.01 stabilizes. //TODO: Always hide the legacy slider. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true futureSliderView.isHidden = true
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
@ -127,17 +123,13 @@ class PanelController: ParentPanelController {
log() log()
if #available(OSX 10.14, *) { PerfLogger.endMarker("Open")
PerfLogger.endMarker("Open")
}
} }
// New way to set the panel's frame. // New way to set the panel's frame.
// This takes into account the screen's dimensions. // This takes into account the screen's dimensions.
private func setPanelFrame() { private func setPanelFrame() {
if #available(OSX 10.14, *) { PerfLogger.startMarker("Set Panel Frame")
PerfLogger.startMarker("Set Panel Frame")
}
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else { guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
return return
@ -167,21 +159,17 @@ class PanelController: ParentPanelController {
let screenMaxX = (statusItemScreen?.frame)!.maxX let screenMaxX = (statusItemScreen?.frame)!.maxX
let minY = statusItemFrame.origin.y < (statusItemScreen?.frame)!.maxY ? let minY = statusItemFrame.origin.y < (statusItemScreen?.frame)!.maxY ?
statusItemFrame.origin.y : statusItemFrame.origin.y :
(statusItemScreen?.frame)!.maxY (statusItemScreen?.frame)!.maxY
statusItemFrame.origin.y = minY statusItemFrame.origin.y = minY
setFrameTheNewWay(statusItemFrame, screenMaxX) setFrameTheNewWay(statusItemFrame, screenMaxX)
if #available(OSX 10.14, *) { PerfLogger.endMarker("Set Panel Frame")
PerfLogger.endMarker("Set Panel Frame")
}
} }
} }
private func log() { private func log() {
if #available(OSX 10.14, *) { PerfLogger.startMarker("Logging")
PerfLogger.startMarker("Logging")
}
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
@ -226,33 +214,25 @@ class PanelController: ParentPanelController {
Logger.log(object: panelEvent, for: "openedPanel") Logger.log(object: panelEvent, for: "openedPanel")
if #available(OSX 10.14, *) { PerfLogger.endMarker("Logging")
PerfLogger.endMarker("Logging")
}
} }
private func startWindowTimer() { private func startWindowTimer() {
if #available(OSX 10.14, *) { PerfLogger.startMarker("Start Window Timer")
PerfLogger.startMarker("Start Window Timer")
}
stopMenubarTimerIfNeccesary() stopMenubarTimerIfNeccesary()
if let timer = parentTimer, timer.state == .paused { if let timer = parentTimer, timer.state == .paused {
parentTimer?.start() parentTimer?.start()
if #available(OSX 10.14, *) { PerfLogger.endMarker("Start Window Timer")
PerfLogger.endMarker("Start Window Timer")
}
return return
} }
startTimer() startTimer()
if #available(OSX 10.14, *) { PerfLogger.endMarker("Start Window Timer")
PerfLogger.endMarker("Start Window Timer")
}
} }
private func startTimer() { private func startTimer() {

40
Clocker/Panel/ParentPanelController.swift

@ -169,13 +169,13 @@ class ParentPanelController: NSWindowController {
updateReviewViewFontColor() updateReviewViewFontColor()
// Set the background color of the bottom buttons view to something different to indicate we're not in a release candidate // Set the background color of the bottom buttons view to something different to indicate we're not in a release candidate
#if DEBUG #if DEBUG
stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0, stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0,
green: 150.0 / 255.0, green: 150.0 / 255.0,
blue: 122.0 / 255.0, blue: 122.0 / 255.0,
alpha: 0.5).cgColor alpha: 0.5).cgColor
stackView.arrangedSubviews.last?.toolTip = "Debug Mode" stackView.arrangedSubviews.last?.toolTip = "Debug Mode"
#endif #endif
// Setup layers // Setup layers
futureSliderView.wantsLayer = true futureSliderView.wantsLayer = true
@ -209,8 +209,8 @@ class ParentPanelController: NSWindowController {
// Setup colors based on the curren theme // Setup colors based on the curren theme
themeChanged() themeChanged()
//TODO: Always hide the legacy slider view. Delete this once v24.01 stabilizes. //TODO: Always hide the legacy slider view. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true futureSliderView.isHidden = true
// UI adjustments based on user preferences // UI adjustments based on user preferences
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
@ -501,9 +501,7 @@ class ParentPanelController: NSWindowController {
} }
func updateDefaultPreferences() { func updateDefaultPreferences() {
if #available(OSX 10.14, *) { PerfLogger.startMarker("Update Default Preferences")
PerfLogger.startMarker("Update Default Preferences")
}
updatePanelColor() updatePanelColor()
@ -520,9 +518,7 @@ class ParentPanelController: NSWindowController {
updateDatasource(with: convertedTimezones) updateDatasource(with: convertedTimezones)
if #available(OSX 10.14, *) { PerfLogger.endMarker("Update Default Preferences")
PerfLogger.endMarker("Update Default Preferences")
}
} }
func updateDatasource(with timezones: [TimezoneData]) { func updateDatasource(with timezones: [TimezoneData]) {
@ -639,9 +635,7 @@ class ParentPanelController: NSWindowController {
cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone
cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if #available(macOS 10.14, *) { cellView.sunriseImage.contentTintColor = model.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
cellView.sunriseImage.contentTintColor = model.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
}
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
} else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) { } else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
@ -758,9 +752,7 @@ class ParentPanelController: NSWindowController {
} }
func retrieveCalendarEvents() { func retrieveCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Retrieve Calendar Events") PerfLogger.startMarker("Retrieve Calendar Events")
}
let eventCenter = EventCenter.sharedCenter() let eventCenter = EventCenter.sharedCenter()
@ -772,9 +764,7 @@ class ParentPanelController: NSWindowController {
removeUpcomingEventView() removeUpcomingEventView()
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Retrieve Calendar Events") PerfLogger.endMarker("Retrieve Calendar Events")
}
} }
@IBAction func shareAction(_ sender: NSButton) { @IBAction func shareAction(_ sender: NSButton) {
@ -826,9 +816,7 @@ class ParentPanelController: NSWindowController {
} }
private func fetchCalendarEvents() { private func fetchCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Fetch Calendar Events") PerfLogger.startMarker("Fetch Calendar Events")
}
let eventCenter = EventCenter.sharedCenter() let eventCenter = EventCenter.sharedCenter()
let now = Date() let now = Date()
@ -843,9 +831,7 @@ class ParentPanelController: NSWindowController {
return return
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events") PerfLogger.endMarker("Fetch Calendar Events")
}
} }
} else { } else {
if upcomingEventCollectionView != nil { if upcomingEventCollectionView != nil {
@ -853,9 +839,7 @@ class ParentPanelController: NSWindowController {
upcomingEventCollectionView.reloadData() upcomingEventCollectionView.reloadData()
return return
} }
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events") PerfLogger.endMarker("Fetch Calendar Events")
}
} }
} }

14
Clocker/Panel/Rate Controller/ReviewController.swift

@ -57,20 +57,12 @@ final class ReviewController {
// never prompt w/in the same version // never prompt w/in the same version
return lastVersion != (Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String) return lastVersion != (Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String)
// limit all types of prompts to at least 1mo intervals // limit all types of prompts to at least 1mo intervals
&& lastPrompt.timeIntervalSinceNow < minInterval && lastPrompt.timeIntervalSinceNow < minInterval
} }
class func prompt() { class func prompt() {
if #available(OSX 10.14, *) { SKStoreReviewController.requestReview()
SKStoreReviewController.requestReview()
} else {
guard let ratingsURL = URL(string: AboutUsConstants.AppStoreLink) else {
return
}
NSWorkspace.shared.open(ratingsURL)
}
prompted() prompted()
} }
} }

30
Clocker/Panel/UI/TimezoneDataSource.swift

@ -58,9 +58,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue) cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue)
cellView.sunriseImage.image = currentModel.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = currentModel.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if #available(macOS 10.14, *) { cellView.sunriseImage.contentTintColor = currentModel.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
cellView.sunriseImage.contentTintColor = currentModel.isSunriseOrSunset ? NSColor.systemYellow : NSColor.systemOrange
}
cellView.relativeDate.stringValue = operation.date(with: sliderValue, displayType: .panel) cellView.relativeDate.stringValue = operation.date(with: sliderValue, displayType: .panel)
cellView.rowNumber = row cellView.rowNumber = row
cellView.customName.stringValue = currentModel.formattedTimezoneLabel() cellView.customName.stringValue = currentModel.formattedTimezoneLabel()
@ -137,23 +135,23 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
title: "Delete", title: "Delete",
handler: { _, row in handler: { _, row in
if self.timezones[row].isSystemTimezone { if self.timezones[row].isSystemTimezone {
self.showAlertForDeletingAHomeRow(row, tableView) self.showAlertForDeletingAHomeRow(row, tableView)
return return
} }
let indexSet = IndexSet(integer: row) let indexSet = IndexSet(integer: row)
tableView.removeRows(at: indexSet, withAnimation: NSTableView.AnimationOptions()) tableView.removeRows(at: indexSet, withAnimation: NSTableView.AnimationOptions())
if self.dataStore.shouldDisplay(ViewType.showAppInForeground) { if self.dataStore.shouldDisplay(ViewType.showAppInForeground) {
windowController.deleteTimezone(at: row) windowController.deleteTimezone(at: row)
} else { } else {
guard let panelController = PanelController.panel() else { return } guard let panelController = PanelController.panel() else { return }
panelController.deleteTimezone(at: row) panelController.deleteTimezone(at: row)
} }
}) })
if #available(OSX 11.0, *) { if #available(OSX 11.0, *) {
swipeToDelete.image = Themer.shared().filledTrashImage() swipeToDelete.image = Themer.shared().filledTrashImage()

4
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -126,10 +126,6 @@ class AppearanceViewController: ParentViewController {
sliderDayRangePopup.selectItem(at: selectedIndex.intValue) sliderDayRangePopup.selectItem(at: selectedIndex.intValue)
} }
if #available(macOS 10.14, *) {} else {
theme.removeItem(at: 2)
}
let shouldDisplayCompact = DataStore.shared().shouldDisplay(.menubarCompactMode) let shouldDisplayCompact = DataStore.shared().shouldDisplay(.menubarCompactMode)
menubarMode.setSelected(true, forSegment: shouldDisplayCompact ? 0 : 1) menubarMode.setSelected(true, forSegment: shouldDisplayCompact ? 0 : 1)

4
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -56,9 +56,7 @@ class CalendarViewController: ParentViewController {
self.setup() self.setup()
} }
if #available(macOS 10.14, *) { noAccessView.material = .contentBackground
noAccessView.material = .contentBackground
}
upcomingEventView.setAccessibility("UpcomingEventView") upcomingEventView.setAccessibility("UpcomingEventView")
} }

106
Clocker/Preferences/General/PreferencesViewController.swift

@ -133,10 +133,8 @@ class PreferencesViewController: ParentViewController {
} }
private func darkModeChanges() { private func darkModeChanges() {
if #available(macOS 10.14, *) { addTimezoneButton.image = Themer.shared().addImage()
addTimezoneButton.image = Themer.shared().addImage() deleteButton.image = Themer.shared().removeImage()
deleteButton.image = Themer.shared().removeImage()
}
} }
private func setupLocalizedText() { private func setupLocalizedText() {
@ -435,48 +433,48 @@ extension PreferencesViewController {
self.dataTask = NetworkManager.task(with: self.generateSearchURL(), self.dataTask = NetworkManager.task(with: self.generateSearchURL(),
completionHandler: { [weak self] response, error in completionHandler: { [weak self] response, error in
guard let self = self else { return } guard let self = self else { return }
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
if let errorPresent = error { if let errorPresent = error {
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
if self.searchResultsDataSource.timezoneFilteredArray.isEmpty { if self.searchResultsDataSource.timezoneFilteredArray.isEmpty {
self.presentError(errorPresent.localizedDescription) self.presentError(errorPresent.localizedDescription)
return return
} }
self.prepareUIForPresentingResults() self.prepareUIForPresentingResults()
return return
} }
guard let data = response, let searchResults = data.decode() else { guard let data = response, let searchResults = data.decode() else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return return
} }
// let searchResults = data.decode() // let searchResults = data.decode()
if searchResults.status == ResultStatus.zeroResults { if searchResults.status == ResultStatus.zeroResults {
Logger.info("Zero Results returned") Logger.info("Zero Results returned")
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "No results! 😔 Try entering the exact name." : UserDefaultKeys.emptyString self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "No results! 😔 Try entering the exact name." : UserDefaultKeys.emptyString
self.reloadSearchResults() self.reloadSearchResults()
self.isActivityInProgress = false self.isActivityInProgress = false
return return
} else if searchResults.status == ResultStatus.requestDenied && searchResults.results.isEmpty { } else if searchResults.status == ResultStatus.requestDenied && searchResults.results.isEmpty {
Logger.info("Request denied!") Logger.info("Request denied!")
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "Update Clocker to get a faster experience 😃" : UserDefaultKeys.emptyString self.placeholderLabel.placeholderString = self.searchResultsDataSource.timezoneFilteredArray.isEmpty ? "Update Clocker to get a faster experience 😃" : UserDefaultKeys.emptyString
self.reloadSearchResults() self.reloadSearchResults()
self.isActivityInProgress = false self.isActivityInProgress = false
return return
} }
self.appendResultsToFilteredArray(searchResults.results) self.appendResultsToFilteredArray(searchResults.results)
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.prepareUIForPresentingResults() self.prepareUIForPresentingResults()
} }
}) })
} }
} }
@ -932,8 +930,8 @@ extension PreferencesViewController {
} }
sender.image = isLabelOptionSelected ? sender.image = isLabelOptionSelected ?
NSImage(named: NSImage.Name("NSDescendingSortIndicator"))! : NSImage(named: NSImage.Name("NSDescendingSortIndicator"))! :
NSImage(named: NSImage.Name("NSAscendingSortIndicator"))! NSImage(named: NSImage.Name("NSAscendingSortIndicator"))!
isLabelOptionSelected.toggle() isLabelOptionSelected.toggle()
@ -1023,18 +1021,18 @@ extension PreferencesViewController: PreferenceSelectionUpdates {
if tableColumn.identifier.rawValue == "formattedAddress" { if tableColumn.identifier.rawValue == "formattedAddress" {
return arePlacesSortedInAscendingOrder ? return arePlacesSortedInAscendingOrder ?
object1.formattedAddress! > object2.formattedAddress! : object1.formattedAddress! > object2.formattedAddress! :
object1.formattedAddress! < object2.formattedAddress! object1.formattedAddress! < object2.formattedAddress!
} else { } else {
return arePlacesSortedInAscendingOrder ? return arePlacesSortedInAscendingOrder ?
object1.customLabel! > object2.customLabel! : object1.customLabel! > object2.customLabel! :
object1.customLabel! < object2.customLabel! object1.customLabel! < object2.customLabel!
} }
} }
let indicatorImage = arePlacesSortedInAscendingOrder ? let indicatorImage = arePlacesSortedInAscendingOrder ?
NSImage(named: NSImage.Name("NSDescendingSortIndicator"))! : NSImage(named: NSImage.Name("NSDescendingSortIndicator"))! :
NSImage(named: NSImage.Name("NSAscendingSortIndicator"))! NSImage(named: NSImage.Name("NSAscendingSortIndicator"))!
timezoneTableView.setIndicatorImage(indicatorImage, in: tableColumn) timezoneTableView.setIndicatorImage(indicatorImage, in: tableColumn)

14
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -91,11 +91,7 @@ class StatusItemHandler: NSObject {
currentState = menubarState currentState = menubarState
func setSelector() { func setSelector() {
if #available(macOS 10.14, *) { statusItem.button?.action = #selector(menubarIconClicked(_:))
statusItem.button?.action = #selector(menubarIconClicked(_:))
} else {
statusItem.action = #selector(menubarIconClicked(_:))
}
} }
statusItem.button?.target = self statusItem.button?.target = self
@ -201,10 +197,10 @@ class StatusItemHandler: NSObject {
repeats: false, repeats: false,
block: { [weak self] _ in block: { [weak self] _ in
if let strongSelf = self { if let strongSelf = self {
strongSelf.refresh() strongSelf.refresh()
} }
}) })
// Tolerance, even a small amount, has a positive imapct on the power usage. As a rule, we set it to 10% of the interval // Tolerance, even a small amount, has a positive imapct on the power usage. As a rule, we set it to 10% of the interval
menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20 menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20

19
Clocker/Preferences/Menu Bar/StatusItemView.swift

@ -27,20 +27,11 @@ var compactModeTimeFont: NSFont {
extension NSView { extension NSView {
var hasDarkAppearance: Bool { var hasDarkAppearance: Bool {
if #available(OSX 10.14, *) { switch effectiveAppearance.name {
switch effectiveAppearance.name { case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark:
case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark: return true
return true default:
default: return false
return false
}
} else {
switch effectiveAppearance.name {
case .vibrantDark:
return true
default:
return false
}
} }
} }
} }

Loading…
Cancel
Save