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
allowsDefaultTighteningForTruncation = true
if #available(OSX 10.12.2, *) {
isAutomaticTextCompletionEnabled = false
allowsCharacterPickerTouchBarItem = false
}
isAutomaticTextCompletionEnabled = false
allowsCharacterPickerTouchBarItem = false
}
func disableWrapping() {

7
Clocker/Overall App/Foundation + Additions.swift

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

167
Clocker/Overall App/Themer.swift

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

46
Clocker/Panel/PanelController.swift

@ -40,9 +40,7 @@ class PanelController: ParentPanelController {
private func enablePerformanceLoggingIfNeccessary() {
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() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Open")
}
PerfLogger.startMarker("Open")
guard isWindowLoaded == true else {
return
@ -77,7 +73,7 @@ class PanelController: ParentPanelController {
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
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
@ -127,17 +123,13 @@ class PanelController: ParentPanelController {
log()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Open")
}
PerfLogger.endMarker("Open")
}
// New way to set the panel's frame.
// This takes into account the screen's dimensions.
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 {
return
@ -167,21 +159,17 @@ class PanelController: ParentPanelController {
let screenMaxX = (statusItemScreen?.frame)!.maxX
let minY = statusItemFrame.origin.y < (statusItemScreen?.frame)!.maxY ?
statusItemFrame.origin.y :
(statusItemScreen?.frame)!.maxY
statusItemFrame.origin.y :
(statusItemScreen?.frame)!.maxY
statusItemFrame.origin.y = minY
setFrameTheNewWay(statusItemFrame, screenMaxX)
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Set Panel Frame")
}
PerfLogger.endMarker("Set Panel Frame")
}
}
private func log() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Logging")
}
PerfLogger.startMarker("Logging")
let preferences = DataStore.shared().timezones()
@ -226,33 +214,25 @@ class PanelController: ParentPanelController {
Logger.log(object: panelEvent, for: "openedPanel")
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Logging")
}
PerfLogger.endMarker("Logging")
}
private func startWindowTimer() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Start Window Timer")
}
PerfLogger.startMarker("Start Window Timer")
stopMenubarTimerIfNeccesary()
if let timer = parentTimer, timer.state == .paused {
parentTimer?.start()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Start Window Timer")
}
PerfLogger.endMarker("Start Window Timer")
return
}
startTimer()
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Start Window Timer")
}
PerfLogger.endMarker("Start Window Timer")
}
private func startTimer() {

40
Clocker/Panel/ParentPanelController.swift

@ -169,13 +169,13 @@ class ParentPanelController: NSWindowController {
updateReviewViewFontColor()
// Set the background color of the bottom buttons view to something different to indicate we're not in a release candidate
#if DEBUG
stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0,
green: 150.0 / 255.0,
blue: 122.0 / 255.0,
alpha: 0.5).cgColor
stackView.arrangedSubviews.last?.toolTip = "Debug Mode"
#endif
#if DEBUG
stackView.arrangedSubviews.last?.layer?.backgroundColor = NSColor(deviceRed: 255.0 / 255.0,
green: 150.0 / 255.0,
blue: 122.0 / 255.0,
alpha: 0.5).cgColor
stackView.arrangedSubviews.last?.toolTip = "Debug Mode"
#endif
// Setup layers
futureSliderView.wantsLayer = true
@ -209,8 +209,8 @@ class ParentPanelController: NSWindowController {
// Setup colors based on the curren theme
themeChanged()
//TODO: Always hide the legacy slider view. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true
//TODO: Always hide the legacy slider view. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true
// UI adjustments based on user preferences
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
@ -501,9 +501,7 @@ class ParentPanelController: NSWindowController {
}
func updateDefaultPreferences() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Update Default Preferences")
}
PerfLogger.startMarker("Update Default Preferences")
updatePanelColor()
@ -520,9 +518,7 @@ class ParentPanelController: NSWindowController {
updateDatasource(with: convertedTimezones)
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Update Default Preferences")
}
PerfLogger.endMarker("Update Default Preferences")
}
func updateDatasource(with timezones: [TimezoneData]) {
@ -639,9 +635,7 @@ class ParentPanelController: NSWindowController {
cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone
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 {
cellView.noteLabel.stringValue = note
} else if let value = TimezoneDataOperations(with: model, store: DataStore.shared()).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
@ -758,9 +752,7 @@ class ParentPanelController: NSWindowController {
}
func retrieveCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Retrieve Calendar Events")
}
let eventCenter = EventCenter.sharedCenter()
@ -772,9 +764,7 @@ class ParentPanelController: NSWindowController {
removeUpcomingEventView()
}
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Retrieve Calendar Events")
}
}
@IBAction func shareAction(_ sender: NSButton) {
@ -826,9 +816,7 @@ class ParentPanelController: NSWindowController {
}
private func fetchCalendarEvents() {
if #available(OSX 10.14, *) {
PerfLogger.startMarker("Fetch Calendar Events")
}
let eventCenter = EventCenter.sharedCenter()
let now = Date()
@ -843,9 +831,7 @@ class ParentPanelController: NSWindowController {
return
}
if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events")
}
}
} else {
if upcomingEventCollectionView != nil {
@ -853,9 +839,7 @@ class ParentPanelController: NSWindowController {
upcomingEventCollectionView.reloadData()
return
}
if #available(OSX 10.14, *) {
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
return lastVersion != (Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String)
// limit all types of prompts to at least 1mo intervals
&& lastPrompt.timeIntervalSinceNow < minInterval
// limit all types of prompts to at least 1mo intervals
&& lastPrompt.timeIntervalSinceNow < minInterval
}
class func prompt() {
if #available(OSX 10.14, *) {
SKStoreReviewController.requestReview()
} else {
guard let ratingsURL = URL(string: AboutUsConstants.AppStoreLink) else {
return
}
NSWorkspace.shared.open(ratingsURL)
}
SKStoreReviewController.requestReview()
prompted()
}
}

30
Clocker/Panel/UI/TimezoneDataSource.swift

@ -58,9 +58,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.sunriseSetTime.stringValue = operation.formattedSunriseTime(with: sliderValue)
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.rowNumber = row
cellView.customName.stringValue = currentModel.formattedTimezoneLabel()
@ -137,23 +135,23 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
title: "Delete",
handler: { _, row in
if self.timezones[row].isSystemTimezone {
self.showAlertForDeletingAHomeRow(row, tableView)
return
}
if self.timezones[row].isSystemTimezone {
self.showAlertForDeletingAHomeRow(row, tableView)
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) {
windowController.deleteTimezone(at: row)
} else {
guard let panelController = PanelController.panel() else { return }
panelController.deleteTimezone(at: row)
}
if self.dataStore.shouldDisplay(ViewType.showAppInForeground) {
windowController.deleteTimezone(at: row)
} else {
guard let panelController = PanelController.panel() else { return }
panelController.deleteTimezone(at: row)
}
})
})
if #available(OSX 11.0, *) {
swipeToDelete.image = Themer.shared().filledTrashImage()

4
Clocker/Preferences/Appearance/AppearanceViewController.swift

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

4
Clocker/Preferences/Calendar/CalendarViewController.swift

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

106
Clocker/Preferences/General/PreferencesViewController.swift

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

14
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -91,11 +91,7 @@ class StatusItemHandler: NSObject {
currentState = menubarState
func setSelector() {
if #available(macOS 10.14, *) {
statusItem.button?.action = #selector(menubarIconClicked(_:))
} else {
statusItem.action = #selector(menubarIconClicked(_:))
}
statusItem.button?.action = #selector(menubarIconClicked(_:))
}
statusItem.button?.target = self
@ -201,10 +197,10 @@ class StatusItemHandler: NSObject {
repeats: false,
block: { [weak self] _ in
if let strongSelf = self {
strongSelf.refresh()
}
})
if let strongSelf = self {
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
menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20

19
Clocker/Preferences/Menu Bar/StatusItemView.swift

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

Loading…
Cancel
Save