Browse Source

Formatting..

pull/113/head
Abhishek 3 years ago
parent
commit
d9d6b8beeb
  1. 2
      Clocker/AppDelegate.swift
  2. 40
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  3. 44
      Clocker/ClockerUnitTests/ThemerTests.swift
  4. 10
      Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift
  5. 6
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift
  6. 6
      Clocker/Dependencies/Date Additions/TimePeriodChain.swift
  7. 6
      Clocker/Events and Reminders/CalendarHandler.swift
  8. 3
      Clocker/Events and Reminders/RemindersHandler.swift
  9. 6
      Clocker/Menu Bar/StatusContainerView.swift
  10. 5
      Clocker/Menu Bar/StatusItemHandler.swift
  11. 2
      Clocker/Onboarding/FinalOnboardingViewController.swift
  12. 9
      Clocker/Onboarding/OnboardingSearchController.swift
  13. 10
      Clocker/Overall App/DataStore.swift
  14. 2
      Clocker/Overall App/NetworkManager.swift
  15. 54
      Clocker/Overall App/Themer.swift
  16. 2
      Clocker/Overall App/Timer.swift
  17. 2
      Clocker/Overall App/VersionUpdateHandler.swift
  18. 2
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  19. 8
      Clocker/Panel/Notes Popover/NotesPopover.swift
  20. 23
      Clocker/Panel/PanelController.swift
  21. 2
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  22. 45
      Clocker/Panel/ParentPanelController.swift
  23. 4
      Clocker/Panel/Rate Controller/ReviewController.swift
  24. 6
      Clocker/Panel/UI/TimezoneCellView.swift
  25. 2
      Clocker/Panel/UI/TimezoneDataSource.swift
  26. 3
      Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift
  27. 6
      Clocker/Preferences/About/AboutViewController.swift
  28. 15
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift
  29. 3
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  30. 6
      Clocker/Preferences/Calendar/CalendarViewController.swift
  31. 7
      Clocker/Preferences/General/PreferencesDataSource.swift
  32. 37
      Clocker/Preferences/General/PreferencesViewController.swift
  33. 6
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  34. 13
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  35. 1
      Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift
  36. 8
      Clocker/Preferences/OneWindowController.swift

2
Clocker/AppDelegate.swift

@ -16,7 +16,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
panelObserver?.invalidate() panelObserver?.invalidate()
} }
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) { override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
if let path = keyPath, path == PreferencesConstants.hotKeyPathIdentifier { if let path = keyPath, path == PreferencesConstants.hotKeyPathIdentifier {
let hotKeyCenter = PTHotKeyCenter.shared() let hotKeyCenter = PTHotKeyCenter.shared()

40
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -105,31 +105,31 @@ class ClockerUnitTests: XCTestCase {
XCTAssert(newDefaults.isEmpty == false) XCTAssert(newDefaults.isEmpty == false)
XCTAssert(newDefaults.count == oldCount + 1) XCTAssert(newDefaults.count == oldCount + 1)
} }
func testDecoding() { func testDecoding() {
let timezone1 = TimezoneData.customObject(from: nil) let timezone1 = TimezoneData.customObject(from: nil)
XCTAssertNotNil(timezone1) XCTAssertNotNil(timezone1)
let data = Data() let data = Data()
let timezone2 = TimezoneData.customObject(from: data) let timezone2 = TimezoneData.customObject(from: data)
XCTAssertNil(timezone2) XCTAssertNil(timezone2)
} }
func testDescription() { func testDescription() {
let timezoneData = TimezoneData(with: california) let timezoneData = TimezoneData(with: california)
XCTAssertFalse(timezoneData.description.isEmpty) XCTAssertFalse(timezoneData.description.isEmpty)
XCTAssertFalse(timezoneData.debugDescription.isEmpty) XCTAssertFalse(timezoneData.debugDescription.isEmpty)
} }
func testHashing() { func testHashing() {
let timezoneData = TimezoneData(with: california) let timezoneData = TimezoneData(with: california)
XCTAssert(timezoneData.hash != -1) XCTAssert(timezoneData.hash != -1)
timezoneData.placeID = nil timezoneData.placeID = nil
timezoneData.timezoneID = nil timezoneData.timezoneID = nil
XCTAssert(timezoneData.hash == -1) XCTAssert(timezoneData.hash == -1)
} }
func testBadInputDictionaryForInitialization() { func testBadInputDictionaryForInitialization() {
let badInput: [String: Any] = ["customLabel": "", let badInput: [String: Any] = ["customLabel": "",
"latitude": "41.2565369", "latitude": "41.2565369",
@ -234,7 +234,7 @@ class ClockerUnitTests: XCTestCase {
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss") XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss")
// Wrong input // Wrong input
dataObject.setShouldOverrideGlobalTimeFormat(0) // 12-hour with preceding zero and seconds dataObject.setShouldOverrideGlobalTimeFormat(0) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat(88) == "h:mm a") XCTAssertTrue(dataObject.timezoneFormat(88) == "h:mm a")
@ -274,47 +274,47 @@ class ClockerUnitTests: XCTestCase {
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss") XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss")
dataObject.setShouldOverrideGlobalTimeFormat(12) // 12-hour with preceding zero and seconds dataObject.setShouldOverrideGlobalTimeFormat(12) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "epoch") XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "epoch")
} }
func testSecondsDisplayForOverridenTimezone() { func testSecondsDisplayForOverridenTimezone() {
let dataObject = TimezoneData(with: california) let dataObject = TimezoneData(with: california)
UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format
// Test default behaviour // Test default behaviour
let timezoneWithSecondsKeys = [4,5,8,11] let timezoneWithSecondsKeys = [4, 5, 8, 11]
for timezoneKey in timezoneWithSecondsKeys { for timezoneKey in timezoneWithSecondsKeys {
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey) dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey)
XCTAssertTrue(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) XCTAssertTrue(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat()))
} }
let timezoneWithoutSecondsKeys = [1,2,7,10] let timezoneWithoutSecondsKeys = [1, 2, 7, 10]
for timezoneKey in timezoneWithoutSecondsKeys { for timezoneKey in timezoneWithoutSecondsKeys {
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey) dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey)
XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat()))
} }
// Test wrong override timezone key // Test wrong override timezone key
let wrongTimezoneKey = 88 let wrongTimezoneKey = 88
dataObject.setShouldOverrideGlobalTimeFormat(wrongTimezoneKey) dataObject.setShouldOverrideGlobalTimeFormat(wrongTimezoneKey)
XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat()))
// Test wrong global preference key // Test wrong global preference key
dataObject.setShouldOverrideGlobalTimeFormat(0) dataObject.setShouldOverrideGlobalTimeFormat(0)
XCTAssertFalse(dataObject.shouldShowSeconds(88)) XCTAssertFalse(dataObject.shouldShowSeconds(88))
} }
func testTimezoneRetrieval() { func testTimezoneRetrieval() {
let dataObject = TimezoneData(with: mumbai) let dataObject = TimezoneData(with: mumbai)
let autoupdatingTimezone = TimeZone.autoupdatingCurrent.identifier let autoupdatingTimezone = TimeZone.autoupdatingCurrent.identifier
XCTAssertEqual(dataObject.timezone(), "Asia/Calcutta") XCTAssertEqual(dataObject.timezone(), "Asia/Calcutta")
// Unlikely // Unlikely
dataObject.timezoneID = nil dataObject.timezoneID = nil
XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone) XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone)
dataObject.isSystemTimezone = true dataObject.isSystemTimezone = true
XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone) XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone)
} }
@ -328,15 +328,15 @@ class ClockerUnitTests: XCTestCase {
dataObject.formattedAddress = nil dataObject.formattedAddress = nil
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Asia", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())") XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Asia", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())")
dataObject.setLabel("Jogeshwari") dataObject.setLabel("Jogeshwari")
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Jogeshwari", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())") XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Jogeshwari", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())")
// Unlikely scenario // Unlikely scenario
dataObject.setLabel("") dataObject.setLabel("")
dataObject.timezoneID = "GMT" dataObject.timezoneID = "GMT"
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "GMT", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())") XCTAssertTrue(dataObject.formattedTimezoneLabel() == "GMT", "Incorrect custom label returned by model \(dataObject.formattedTimezoneLabel())")
// Another unlikely scenario // Another unlikely scenario
dataObject.setLabel("") dataObject.setLabel("")
dataObject.timezoneID = nil dataObject.timezoneID = nil

44
Clocker/ClockerUnitTests/ThemerTests.swift

@ -5,16 +5,15 @@ import XCTest
@testable import Clocker @testable import Clocker
class ThemerTests: XCTestCase { class ThemerTests: XCTestCase {
@available(macOS 10.14, *) @available(macOS 10.14, *)
func testSettingTheme() { func testSettingTheme() {
// Set to some random number should set to 0 // Set to some random number should set to 0
let subject = Themer(index: 124) let subject = Themer(index: 124)
XCTAssertEqual(NSAppearance(named: .aqua), NSAppearance(named: .aqua)) XCTAssertEqual(NSAppearance(named: .aqua), NSAppearance(named: .aqua))
// Set the same theme; this should return early // Set the same theme; this should return early
subject.set(theme: 0) subject.set(theme: 0)
// Set the theme to dark theme // Set the theme to dark theme
subject.set(theme: 1) subject.set(theme: 1)
let expectedApperance = NSAppearance(named: .darkAqua) let expectedApperance = NSAppearance(named: .darkAqua)
@ -28,8 +27,7 @@ class ThemerTests: XCTestCase {
let expectedBackgroundColor = NSColor.white let expectedBackgroundColor = NSColor.white
let expectedTextColor = NSColor.black let expectedTextColor = NSColor.black
let expectedTextBackgroundColor = NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) let expectedTextBackgroundColor = NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle" let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus" let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle" let expectedPinImageName = "macwindow.on.rectangle"
@ -54,14 +52,13 @@ class ThemerTests: XCTestCase {
let expectedBackwardsImage = "gobackward.15" let expectedBackwardsImage = "gobackward.15"
let expectedForwardsImage = "goforward.15" let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill" let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor) XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor) XCTAssertEqual(subject.mainTextColor(), expectedTextColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor) XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName) XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName) XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName) XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
@ -74,7 +71,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage) XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage) XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance) XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage) XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted) XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage) XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
@ -88,7 +85,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage) XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
} }
func testDarkTheme() throws { func testDarkTheme() throws {
let subject = Themer(index: 1) // 1 is for dark theme let subject = Themer(index: 1) // 1 is for dark theme
let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
@ -96,8 +93,7 @@ class ThemerTests: XCTestCase {
let expectedBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) let expectedBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0)
let expectedTextColor = NSColor.white let expectedTextColor = NSColor.white
let expectedTextBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) let expectedTextBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle" let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus" let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle" let expectedPinImageName = "macwindow.on.rectangle"
@ -122,7 +118,6 @@ class ThemerTests: XCTestCase {
let expectedBackwardsImage = "gobackward.15" let expectedBackwardsImage = "gobackward.15"
let expectedForwardsImage = "goforward.15" let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill" let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
@ -155,18 +150,17 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
XCTAssertEqual(subject.description, "Current Theme is \(Themer.Theme.dark)") XCTAssertEqual(subject.description, "Current Theme is \(Themer.Theme.dark)")
} }
func testSystemTheme() throws { func testSystemTheme() throws {
let currentSystemTheme = let currentSystemTheme =
UserDefaults.standard.string(forKey: "AppleUserInterfaceStyle")?.lowercased().contains("dark") ?? false ? Themer.Theme.dark : Themer.Theme.light UserDefaults.standard.string(forKey: "AppleUserInterfaceStyle")?.lowercased().contains("dark") ?? false ? Themer.Theme.dark : Themer.Theme.light
let subject = Themer(index: 2) // 2 is for system theme let subject = Themer(index: 2) // 2 is for system theme
let expectedSliderKnobColor = currentSystemTheme == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedSliderKnobColor = currentSystemTheme == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
let expectedSliderRightColor = currentSystemTheme == .dark ? NSColor.white : NSColor.gray let expectedSliderRightColor = currentSystemTheme == .dark ? NSColor.white : NSColor.gray
let expectedBackgroundColor = currentSystemTheme == .dark ? NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) : NSColor.white let expectedBackgroundColor = currentSystemTheme == .dark ? NSColor(deviceRed: 42.0 / 255.0, green: 42.0 / 255.0, blue: 42.0 / 255.0, alpha: 1.0) : NSColor.white
let expectedTextColor = NSColor.textColor let expectedTextColor = NSColor.textColor
let expectedTextBackgroundColor = currentSystemTheme == .dark ? NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) : NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0) let expectedTextBackgroundColor = currentSystemTheme == .dark ? NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) : NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle" let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus" let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle" let expectedPinImageName = "macwindow.on.rectangle"
@ -191,7 +185,6 @@ class ThemerTests: XCTestCase {
let expectedBackwardsImage = "gobackward.15" let expectedBackwardsImage = "gobackward.15"
let expectedForwardsImage = "goforward.15" let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill" let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
@ -224,7 +217,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
XCTAssertEqual(subject.description, "System Theme is \(currentSystemTheme == .dark ? Themer.Theme.dark : Themer.Theme.light)") XCTAssertEqual(subject.description, "System Theme is \(currentSystemTheme == .dark ? Themer.Theme.dark : Themer.Theme.light)")
} }
func testSolarizedLightTheme() throws { func testSolarizedLightTheme() throws {
let subject = Themer(index: 3) // 3 is for solarized light theme let subject = Themer(index: 3) // 3 is for solarized light theme
let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
@ -232,8 +225,7 @@ class ThemerTests: XCTestCase {
let expectedBackgroundColor = NSColor(deviceRed: 253.0 / 255.0, green: 246.0 / 255.0, blue: 227.0 / 255.0, alpha: 1.0) let expectedBackgroundColor = NSColor(deviceRed: 253.0 / 255.0, green: 246.0 / 255.0, blue: 227.0 / 255.0, alpha: 1.0)
let expectedTextColor = NSColor.black let expectedTextColor = NSColor.black
let expectedTextBackgroundColor = NSColor(deviceRed: 238.0 / 255.0, green: 232.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0) let expectedTextBackgroundColor = NSColor(deviceRed: 238.0 / 255.0, green: 232.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle" let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus" let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle" let expectedPinImageName = "macwindow.on.rectangle"
@ -258,14 +250,13 @@ class ThemerTests: XCTestCase {
let expectedBackwardsImage = "gobackward.15" let expectedBackwardsImage = "gobackward.15"
let expectedForwardsImage = "goforward.15" let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill" let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor) XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
XCTAssertEqual(subject.mainTextColor(), expectedTextColor) XCTAssertEqual(subject.mainTextColor(), expectedTextColor)
XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor) XCTAssertEqual(subject.textBackgroundColor(), expectedTextBackgroundColor)
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName) XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName) XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName) XCTAssertEqual(subject.pinImage().accessibilityDescription, expectedPinImageName)
@ -278,7 +269,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage) XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage) XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectedCurrentLocationImage)
XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance) XCTAssertEqual(subject.popoverAppearance(), expectedPopoverApperarance)
XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage) XCTAssertEqual(subject.addImage().accessibilityDescription, expectedAddImage)
XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted) XCTAssertEqual(subject.addImageHighlighted().name(), expectedAddImageHighlighted)
XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage) XCTAssertEqual(subject.privacyTabImage().accessibilityDescription, expectedPrivacyTabImage)
@ -292,7 +283,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage) XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
} }
func testSolarizedDarkTheme() throws { func testSolarizedDarkTheme() throws {
let subject = Themer(index: 4) // 4 is for solarized dark theme let subject = Themer(index: 4) // 4 is for solarized dark theme
let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) let expectedSliderKnobColor = NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
@ -300,8 +291,7 @@ class ThemerTests: XCTestCase {
let expectedBackgroundColor = NSColor(deviceRed: 7.0 / 255.0, green: 54.0 / 255.0, blue: 66.0 / 255.0, alpha: 1.0) let expectedBackgroundColor = NSColor(deviceRed: 7.0 / 255.0, green: 54.0 / 255.0, blue: 66.0 / 255.0, alpha: 1.0)
let expectedTextColor = NSColor.white let expectedTextColor = NSColor.white
let expectedTextBackgroundColor = NSColor(deviceRed: 88.0 / 255.0, green: 110.0 / 255.0, blue: 117.0 / 255.0, alpha: 1.0) let expectedTextBackgroundColor = NSColor(deviceRed: 88.0 / 255.0, green: 110.0 / 255.0, blue: 117.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle" let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus" let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle" let expectedPinImageName = "macwindow.on.rectangle"
@ -326,7 +316,6 @@ class ThemerTests: XCTestCase {
let expectedBackwardsImage = "gobackward.15" let expectedBackwardsImage = "gobackward.15"
let expectedForwardsImage = "goforward.15" let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill" let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor) XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor) XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
@ -358,5 +347,4 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage) XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage) XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
} }
} }

10
Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift

@ -2,7 +2,7 @@
import Cocoa import Cocoa
public struct ResultStatus { public enum ResultStatus {
public static let okay = "OK" public static let okay = "OK"
public static let zeroResults = "ZERO_RESULTS" public static let zeroResults = "ZERO_RESULTS"
public static let requestDenied = "REQUEST_DENIED" public static let requestDenied = "REQUEST_DENIED"
@ -12,7 +12,7 @@ public struct SearchResult: Codable {
public let results: [Result] public let results: [Result]
public let status: String public let status: String
public let errorMessage: String? public let errorMessage: String?
public struct Result: Codable { public struct Result: Codable {
public let addressComponents: [AddressComponent] public let addressComponents: [AddressComponent]
public let formattedAddress: String public let formattedAddress: String
@ -55,10 +55,10 @@ public struct SearchResult: Codable {
case types case types
} }
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case results = "results" case results
case status = "status" case status
case errorMessage = "error_message" case errorMessage = "error_message"
} }
} }

6
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -85,7 +85,7 @@ public class TimezoneData: NSObject, NSCoding {
public var isSystemTimezone = false public var isSystemTimezone = false
public var overrideFormat: TimezoneOverride = .globalFormat public var overrideFormat: TimezoneOverride = .globalFormat
public override init() { override public init() {
selectionType = .timezone selectionType = .timezone
isFavourite = 0 isFavourite = 0
note = ModelConstants.emptyString note = ModelConstants.emptyString
@ -268,7 +268,7 @@ public class TimezoneData: NSObject, NSCoding {
return formatInString.contains("ss") return formatInString.contains("ss")
} }
public override var hash: Int { override public var hash: Int {
guard let placeIdentifier = placeID, let timezone = timezoneID else { guard let placeIdentifier = placeID, let timezone = timezoneID else {
return -1 return -1
} }
@ -276,7 +276,7 @@ public class TimezoneData: NSObject, NSCoding {
return placeIdentifier.hashValue ^ timezone.hashValue return placeIdentifier.hashValue ^ timezone.hashValue
} }
public override func isEqual(_ object: Any?) -> Bool { override public func isEqual(_ object: Any?) -> Bool {
guard let compared = object as? TimezoneData else { guard let compared = object as? TimezoneData else {
return false return false
} }

6
Clocker/Dependencies/Date Additions/TimePeriodChain.swift

@ -138,15 +138,15 @@ open class TimePeriodChain: TimePeriodGroup {
_end = _end?.addingTimeInterval(duration) _end = _end?.addingTimeInterval(duration)
} }
public override func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] { override public func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
return try periods.map(transform) return try periods.map(transform)
} }
public override func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] { override public func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
return try periods.filter(isIncluded) return try periods.filter(isIncluded)
} }
internal override func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result { override internal func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
return try periods.reduce(initialResult, nextPartialResult) return try periods.reduce(initialResult, nextPartialResult)
} }

6
Clocker/Events and Reminders/CalendarHandler.swift

@ -391,7 +391,8 @@ extension EventCenter {
// Check for Zoom links // Check for Zoom links
if actualLink.contains("zoom.us/j/") if actualLink.contains("zoom.us/j/")
|| actualLink.contains("zoom.us/s/") || actualLink.contains("zoom.us/s/")
|| actualLink.contains("zoom.us/w/") { || actualLink.contains("zoom.us/w/")
{
// Create a Zoom App link // Create a Zoom App link
let workspace = NSWorkspace.shared let workspace = NSWorkspace.shared
if workspace.urlForApplication(toOpen: URL(string: "zoommtg://")!) != nil { if workspace.urlForApplication(toOpen: URL(string: "zoommtg://")!) != nil {
@ -417,7 +418,8 @@ extension EventCenter {
|| actualLink.contains("public.senfcall.de") || actualLink.contains("public.senfcall.de")
|| actualLink.contains("youcanbook.me/zoom/") || actualLink.contains("youcanbook.me/zoom/")
|| actualLink.contains("workplace.com/groupcall") || actualLink.contains("workplace.com/groupcall")
|| actualLink.contains("bluejeans.com/") { || actualLink.contains("bluejeans.com/")
{
if let meetingLink = result.url { if let meetingLink = result.url {
return meetingLink return meetingLink
} }

3
Clocker/Events and Reminders/RemindersHandler.swift

@ -51,7 +51,8 @@ extension EventCenter {
timezone: String, timezone: String,
alertIndex: Int, alertIndex: Int,
reminderDate: Date, reminderDate: Date,
additionalNotes: String?) -> Bool { additionalNotes: String?) -> Bool
{
initializeStoreIfNeccesary() initializeStoreIfNeccesary()
if reminderAccessNotDetermined() || reminderAccessDenied() { if reminderAccessNotDetermined() || reminderAccessDenied() {

6
Clocker/Menu Bar/StatusContainerView.swift

@ -31,10 +31,12 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds || timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero || timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds { || timeFormat == DateFormat.twelveHourWithSeconds
{
totalWidth += 20 totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour } else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds { || timeFormat == DateFormat.twentyFourHourWithSeconds
{
totalWidth += 0 totalWidth += 0
} }

5
Clocker/Menu Bar/StatusItemHandler.swift

@ -112,7 +112,8 @@ class StatusItemHandler: NSObject {
userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification, userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification,
object: self, object: self,
queue: mainQueue) { _ in queue: mainQueue)
{ _ in
self.setupStatusItem() self.setupStatusItem()
} }
} }
@ -185,7 +186,7 @@ class StatusItemHandler: NSObject {
if let strongSelf = self { if let strongSelf = self {
strongSelf.performTimerWork() strongSelf.performTimerWork()
} }
}) })
// 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

2
Clocker/Onboarding/FinalOnboardingViewController.swift

@ -53,7 +53,7 @@ class FinalOnboardingViewController: NSViewController {
@IBAction func localizationAction(_: Any) { @IBAction func localizationAction(_: Any) {
guard let localizationURL = URL(string: AboutUsConstants.TwitterFollowIntentLink), guard let localizationURL = URL(string: AboutUsConstants.TwitterFollowIntentLink),
let languageCode = Locale.preferredLanguages.first else { return } let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL) NSWorkspace.shared.open(localizationURL)

9
Clocker/Onboarding/OnboardingSearchController.swift

@ -27,8 +27,8 @@ class OnboardingSearchController: NSViewController {
private var geocodingKey: String = { private var geocodingKey: String = {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"), guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
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 ""
@ -135,7 +135,8 @@ class OnboardingSearchController: NSViewController {
private func setupLabelHidingTimer() { private func setupLabelHidingTimer() {
Timer.scheduledTimer(withTimeInterval: 5, Timer.scheduledTimer(withTimeInterval: 5,
repeats: false) { _ in repeats: false)
{ _ in
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
self.setInfoLabel(CLEmptyString) self.setInfoLabel(CLEmptyString)
} }
@ -375,7 +376,7 @@ class OnboardingSearchController: NSViewController {
self.findLocalSearchResultsForTimezones() self.findLocalSearchResultsForTimezones()
self.prepareUIForPresentingResults() self.prepareUIForPresentingResults()
} }
}) })
} }
private func presentErrorMessage(_ errorMessage: String) { private func presentErrorMessage(_ errorMessage: String) {

10
Clocker/Overall App/DataStore.swift

@ -50,14 +50,14 @@ class DataStore: NSObject {
if let cloudPreferences = ubiquitousStore.object(forKey: CLDefaultPreferenceKey) as? [Data] { if let cloudPreferences = ubiquitousStore.object(forKey: CLDefaultPreferenceKey) as? [Data] {
return cloudPreferences return cloudPreferences
} }
guard let preferences = userDefaults.object(forKey: CLDefaultPreferenceKey) as? [Data] else { guard let preferences = userDefaults.object(forKey: CLDefaultPreferenceKey) as? [Data] else {
return [] return []
} }
return preferences return preferences
} }
func setTimezones(_ timezones: [Data]?) { func setTimezones(_ timezones: [Data]?) {
userDefaults.set(timezones, forKey: CLDefaultPreferenceKey) userDefaults.set(timezones, forKey: CLDefaultPreferenceKey)
// iCloud sync // iCloud sync
@ -164,9 +164,9 @@ class DataStore: NSObject {
return value == 0 return value == 0
} }
} }
//MARK: Private // MARK: Private
private func shouldDisplayHelper(_ key: String) -> Bool { private func shouldDisplayHelper(_ key: String) -> Bool {
guard let value = retrieve(key: key) as? NSNumber else { guard let value = retrieve(key: key) as? NSNumber else {
return false return false

2
Clocker/Overall App/NetworkManager.swift

@ -41,7 +41,7 @@ extension NetworkManager {
let session = URLSession(configuration: configuration) let session = URLSession(configuration: configuration)
guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: encodedPath) let url = URL(string: encodedPath)
else { else {
completionHandler(nil, unableToGenerateURL) completionHandler(nil, unableToGenerateURL)
return nil return nil

54
Clocker/Overall App/Themer.swift

@ -15,6 +15,7 @@ class Themer: NSObject {
case solarizedLight case solarizedLight
case solarizedDark case solarizedDark
} }
private static var sharedInstance = Themer(index: UserDefaults.standard.integer(forKey: CLThemeKey)) private static var sharedInstance = Themer(index: UserDefaults.standard.integer(forKey: CLThemeKey))
private var effectiveApperanceObserver: NSKeyValueObservation? private var effectiveApperanceObserver: NSKeyValueObservation?
private var themeIndex: Theme { private var themeIndex: Theme {
@ -47,9 +48,9 @@ class Themer: NSObject {
selector: #selector(respondToInterfaceStyle), selector: #selector(respondToInterfaceStyle),
name: .interfaceStyleDidChange, name: .interfaceStyleDidChange,
object: nil) object: nil)
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { [weak self] (app, _) in effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { [weak self] _, _ in
if let sSelf = self { if let sSelf = self {
sSelf.setAppAppearance() sSelf.setAppAppearance()
NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil) NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil)
@ -92,12 +93,13 @@ extension Themer {
self.setAppAppearance() self.setAppAppearance()
} }
} }
//MARK: Color // MARK: Color
func sliderKnobColor() -> NSColor { func sliderKnobColor() -> NSColor {
switch themeIndex { switch themeIndex {
case .light: case .light:
return NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) return NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9)
case .system: case .system:
return retrieveCurrentSystem() == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9) return retrieveCurrentSystem() == .light ? NSColor(deviceRed: 255.0, green: 255.0, blue: 255, alpha: 0.9) : NSColor(deviceRed: 0.0, green: 0.0, blue: 0, alpha: 0.9)
default: default:
@ -108,7 +110,7 @@ extension Themer {
func sliderRightColor() -> NSColor { func sliderRightColor() -> NSColor {
switch themeIndex { switch themeIndex {
case .dark: case .dark:
return NSColor.white return NSColor.white
default: default:
return NSColor.gray return NSColor.gray
} }
@ -132,7 +134,7 @@ extension Themer {
return themeIndex == .light ? NSColor.white : NSColor(deviceRed: 55.0 / 255.0, green: 71.0 / 255.0, blue: 79.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, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
@ -172,8 +174,9 @@ extension Themer {
return themeIndex == .light ? NSColor.black : NSColor.white return themeIndex == .light ? NSColor.black : NSColor.white
} }
//MARK: Images // MARK: Images
func shutdownImage() -> NSImage { func shutdownImage() -> NSImage {
if let symbolImageForShutdown = symbolImage(for: "ellipsis.circle") { if let symbolImageForShutdown = symbolImage(for: "ellipsis.circle") {
return symbolImageForShutdown return symbolImageForShutdown
@ -190,7 +193,7 @@ extension Themer {
if let symbolImageForPreference = symbolImage(for: "plus") { if let symbolImageForPreference = symbolImage(for: "plus") {
return symbolImageForPreference return symbolImageForPreference
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Settings"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("Settings"))!,
NSImage(named: NSImage.Name("Settings-White"))!, NSImage(named: NSImage.Name("Settings-White"))!,
NSImage(named: NSImage.actionTemplateName)!, NSImage(named: NSImage.actionTemplateName)!,
@ -202,7 +205,7 @@ extension Themer {
if let pinImage = symbolImage(for: "macwindow.on.rectangle") { if let pinImage = symbolImage(for: "macwindow.on.rectangle") {
return pinImage return pinImage
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Float"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("Float"))!,
NSImage(named: NSImage.Name("Float-White"))!, NSImage(named: NSImage.Name("Float-White"))!,
NSImage(named: NSImage.Name("Pin"))!, NSImage(named: NSImage.Name("Pin"))!,
@ -225,7 +228,7 @@ extension Themer {
if let symbolImage = symbolImage(for: "sunset.fill") { if let symbolImage = symbolImage(for: "sunset.fill") {
return symbolImage return symbolImage
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Sunset"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("Sunset"))!,
NSImage(named: NSImage.Name("WhiteSunset"))!, NSImage(named: NSImage.Name("WhiteSunset"))!,
NSImage(named: NSImage.Name("Sunset Dynamic"))!, NSImage(named: NSImage.Name("Sunset Dynamic"))!,
@ -237,7 +240,7 @@ extension Themer {
if let symbolImage = symbolImage(for: "xmark") { if let symbolImage = symbolImage(for: "xmark") {
return symbolImage return symbolImage
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Remove"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("Remove"))!,
NSImage(named: NSImage.Name("WhiteRemove"))!, NSImage(named: NSImage.Name("WhiteRemove"))!,
NSImage(named: NSImage.Name("Remove Dynamic"))!, NSImage(named: NSImage.Name("Remove Dynamic"))!,
@ -317,7 +320,7 @@ extension Themer {
if let symbolImageForPreference = symbolImage(for: "plus") { if let symbolImageForPreference = symbolImage(for: "plus") {
return symbolImageForPreference return symbolImageForPreference
} }
return fallbackImageProvider(NSImage(named: NSImage.Name("Add Icon"))!, return fallbackImageProvider(NSImage(named: NSImage.Name("Add Icon"))!,
NSImage(named: NSImage.Name("Add White"))!, NSImage(named: NSImage.Name("Add White"))!,
NSImage(named: .addDynamicIcon)!, NSImage(named: .addDynamicIcon)!,
@ -402,21 +405,21 @@ extension Themer {
return removeImage() return removeImage()
} }
//MARK: Debug Description // MARK: Debug Description
override var debugDescription: String { override var debugDescription: String {
if themeIndex == .system { if themeIndex == .system {
return "System Theme is \(retrieveCurrentSystem())" return "System Theme is \(retrieveCurrentSystem())"
} }
return "Current Theme is \(themeIndex)" return "Current Theme is \(themeIndex)"
} }
override var description: String { override var description: String {
return debugDescription return debugDescription
} }
//MARK: Private // MARK: Private
private func symbolImage(for name: String) -> NSImage? { private func symbolImage(for name: String) -> NSImage? {
assert(name.isEmpty == false) assert(name.isEmpty == false)
@ -428,7 +431,7 @@ extension Themer {
return nil return nil
} }
private func retrieveCurrentSystem() -> Theme { private func retrieveCurrentSystem() -> Theme {
if #available(OSX 10.14, *) { if #available(OSX 10.14, *) {
if let appleInterfaceStyle = UserDefaults.standard.object(forKey: "AppleInterfaceStyle") as? String { if let appleInterfaceStyle = UserDefaults.standard.object(forKey: "AppleInterfaceStyle") as? String {
@ -439,7 +442,7 @@ extension Themer {
} }
return .light return .light
} }
private func setAppAppearance() { private func setAppAppearance() {
if #available(OSX 10.14, *) { if #available(OSX 10.14, *) {
var appAppearance = NSAppearance(named: .aqua) var appAppearance = NSAppearance(named: .aqua)
@ -452,12 +455,13 @@ extension Themer {
NSApp.appearance = appAppearance NSApp.appearance = appAppearance
} }
} }
private func fallbackImageProvider(_ lightImage: NSImage, private func fallbackImageProvider(_ lightImage: NSImage,
_ darkImage: NSImage, _ darkImage: NSImage,
_ systemImage: NSImage, _ systemImage: NSImage,
_ solarizedLightImage: NSImage, _ solarizedLightImage: NSImage,
_ solarizedDarkImage: NSImage) -> NSImage { _ solarizedDarkImage: NSImage) -> NSImage
{
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
switch themeIndex { switch themeIndex {
case .light: case .light:
@ -474,7 +478,5 @@ extension Themer {
} }
return themeIndex == .light ? lightImage : darkImage return themeIndex == .light ? lightImage : darkImage
} }
} }

2
Clocker/Overall App/Timer.swift

@ -118,7 +118,7 @@ open class Repeater: Equatable {
} }
/// Handler typealias /// Handler typealias
public typealias Observer = ((Repeater) -> Void) public typealias Observer = (Repeater) -> Void
/// Token assigned to the observer /// Token assigned to the observer
public typealias ObserverToken = UInt64 public typealias ObserverToken = UInt64

2
Clocker/Overall App/VersionUpdateHandler.swift

@ -172,7 +172,7 @@ class VersionUpdateHandler: NSObject {
lastVersionCopy = "0" lastVersionCopy = "0"
} }
var newVersionFound = false var newVersionFound = false
var details: String = "" var details = ""
let versions = dict.keys.sorted() let versions = dict.keys.sorted()

2
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -368,7 +368,7 @@ extension TimezoneDataOperations {
to: Date()) to: Date())
guard let lat = dataObject.latitude, guard let lat = dataObject.latitude,
let long = dataObject.longitude let long = dataObject.longitude
else { else {
assertionFailure("Data was unexpectedly nil.") assertionFailure("Data was unexpectedly nil.")
return return

8
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -224,7 +224,7 @@ class NotesPopover: NSViewController {
} }
completionHandler(completedDate) completionHandler(completedDate)
}) })
} catch { } catch {
assertionFailure("Failed to successfully initialize DataDetector") assertionFailure("Failed to successfully initialize DataDetector")
completionHandler(nil) completionHandler(nil)
@ -322,7 +322,8 @@ class NotesPopover: NSViewController {
} }
private func updateTimezoneInDefaultPreferences(with override: Int, private func updateTimezoneInDefaultPreferences(with override: Int,
_: OverrideType) { _: OverrideType)
{
let timezones = DataStore.shared().timezones() let timezones = DataStore.shared().timezones()
var timezoneObjects: [TimezoneData] = [] var timezoneObjects: [TimezoneData] = []
@ -391,7 +392,8 @@ class NotesPopover: NSViewController {
timezone: model.timezone(), timezone: model.timezone(),
alertIndex: alertIndex, alertIndex: alertIndex,
reminderDate: reminderPicker.dateValue, reminderDate: reminderPicker.dateValue,
additionalNotes: model.note) { additionalNotes: model.note)
{
showSuccessMessage() showSuccessMessage()
} }
} }

23
Clocker/Panel/PanelController.swift

@ -154,7 +154,8 @@ class PanelController: ParentPanelController {
} }
if let statusWindow = statusBackgroundWindow, if let statusWindow = statusBackgroundWindow,
let statusButton = statusView { let statusButton = statusView
{
var statusItemFrame = statusWindow.convertToScreen(statusButton.frame) var statusItemFrame = statusWindow.convertToScreen(statusButton.frame)
var statusItemScreen = NSScreen.main var statusItemScreen = NSScreen.main
var testPoint = statusItemFrame.origin var testPoint = statusItemFrame.origin
@ -186,16 +187,16 @@ class PanelController: ParentPanelController {
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber, let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber,
let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber, let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber,
let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber, let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber, let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber, let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String, let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode let country = Locale.autoupdatingCurrent.regionCode
else { else {
return return
} }

2
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -127,7 +127,7 @@ extension ParentPanelController {
} }
public func setDefaultDateLabel(_ index: Int) -> Int { public func setDefaultDateLabel(_ index: Int) -> Int {
let futureSliderDayPreference = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber ?? 5 let futureSliderDayPreference = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber ?? 5
let futureSliderDayRange = (futureSliderDayPreference.intValue + 1) let futureSliderDayRange = (futureSliderDayPreference.intValue + 1)
let totalCount = (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1 let totalCount = (PanelConstants.modernSliderPointsInADay * futureSliderDayRange * 2) + 1
let centerPoint = Int(ceil(Double(totalCount / 2))) let centerPoint = Int(ceil(Double(totalCount / 2)))

45
Clocker/Panel/ParentPanelController.swift

@ -188,7 +188,8 @@ class ParentPanelController: NSWindowController {
object: nil) object: nil)
NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification, NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
object: self, object: self,
queue: OperationQueue.main) { [weak self] _ in queue: OperationQueue.main)
{ [weak self] _ in
if let sSelf = self { if let sSelf = self {
sSelf.mainTableView.reloadData() sSelf.mainTableView.reloadData()
sSelf.setScrollViewConstraint() sSelf.setScrollViewConstraint()
@ -250,7 +251,7 @@ class ParentPanelController: NSWindowController {
coordinates: nil) coordinates: nil)
} }
} }
private func updateHomeObject(with customLabel: String, coordinates: CLLocationCoordinate2D?) { private func updateHomeObject(with customLabel: String, coordinates: CLLocationCoordinate2D?) {
let timezones = DataStore.shared().timezones() let timezones = DataStore.shared().timezones()
@ -415,8 +416,9 @@ class ParentPanelController: NSWindowController {
if let note = object?.note, note.isEmpty == false { if let note = object?.note, note.isEmpty == false {
newHeight += 20 newHeight += 20
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo), } else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object, let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil { TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil
{
newHeight += 20 newHeight += 20
} }
} }
@ -603,8 +605,9 @@ class ParentPanelController: NSWindowController {
let current = preferences[$0] let current = preferences[$0]
if $0 < mainTableView.numberOfRows, if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView, let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current) { let model = TimezoneData.customObject(from: current)
{
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true { if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return return
} }
@ -624,7 +627,8 @@ class ParentPanelController: NSWindowController {
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo), } else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) { let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue)
{
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = CLEmptyString
@ -724,7 +728,8 @@ class ParentPanelController: NSWindowController {
@IBAction func calendarButtonAction(_ sender: NSButton) { @IBAction func calendarButtonAction(_ sender: NSButton) {
if sender.title == NSLocalizedString("Click here to start.", if sender.title == NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access") { comment: "Button Title for no Calendar access")
{
showPermissionsWindow() showPermissionsWindow()
} else { } else {
retrieveCalendarEvents() retrieveCalendarEvents()
@ -815,7 +820,8 @@ class ParentPanelController: NSWindowController {
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false { if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
if self.upcomingEventCollectionView != nil, if self.upcomingEventCollectionView != nil,
let upcomingEvents = eventCenter.upcomingEventsForDay(events) { let upcomingEvents = eventCenter.upcomingEventsForDay(events)
{
self.upcomingEventsDataSource.updateEventsDataSource(upcomingEvents) self.upcomingEventsDataSource.updateEventsDataSource(upcomingEvents)
self.upcomingEventCollectionView.reloadData() self.upcomingEventCollectionView.reloadData()
return return
@ -982,7 +988,7 @@ class ParentPanelController: NSWindowController {
@objc func openCrowdin() { @objc func openCrowdin() {
guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink), guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink),
let languageCode = Locale.preferredLanguages.first else { return } let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL) NSWorkspace.shared.open(localizationURL)
@ -996,7 +1002,7 @@ class ParentPanelController: NSWindowController {
NSWorkspace.shared.open(sourceURL) NSWorkspace.shared.open(sourceURL)
} }
@objc func openFAQs() { @objc func openFAQs() {
guard let sourceURL = URL(string: AboutUsConstants.FAQsLink) else { return } guard let sourceURL = URL(string: AboutUsConstants.FAQsLink) else { return }
@ -1077,19 +1083,19 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
/// London - 01:17:01 /// London - 01:17:01
private func retrieveAllTimes() -> String { private func retrieveAllTimes() -> String {
var clipboardCopy = String() var clipboardCopy = String()
// Get all timezones // Get all timezones
let timezones = DataStore.shared().timezones() let timezones = DataStore.shared().timezones()
if timezones.isEmpty { if timezones.isEmpty {
return clipboardCopy return clipboardCopy
} }
// Sort them in ascending order // Sort them in ascending order
let sortedByTime = timezones.sorted { obj1, obj2 -> Bool in let sortedByTime = timezones.sorted { obj1, obj2 -> Bool in
let system = NSTimeZone.system let system = NSTimeZone.system
guard let object1 = TimezoneData.customObject(from: obj1), guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2) let object2 = TimezoneData.customObject(from: obj2)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return false return false
@ -1103,19 +1109,20 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
return difference1 > difference2 return difference1 > difference2
} }
// Grab date in first place and store it as local variable // Grab date in first place and store it as local variable
guard let earliestTimezone = TimezoneData.customObject(from: sortedByTime.first) else { guard let earliestTimezone = TimezoneData.customObject(from: sortedByTime.first) else {
return clipboardCopy return clipboardCopy
} }
let timezoneOperations = TimezoneDataOperations(with: earliestTimezone) let timezoneOperations = TimezoneDataOperations(with: earliestTimezone)
var sectionTitle = timezoneOperations.todaysDate(with: 0) // TODO: Take slider value into consideration var sectionTitle = timezoneOperations.todaysDate(with: 0) // TODO: Take slider value into consideration
clipboardCopy.append("\(sectionTitle)\n") clipboardCopy.append("\(sectionTitle)\n")
stride(from: 0, to: sortedByTime.count, by: 1).forEach { stride(from: 0, to: sortedByTime.count, by: 1).forEach {
if $0 < sortedByTime.count, if $0 < sortedByTime.count,
let dataModel = TimezoneData.customObject(from: sortedByTime[$0]) { let dataModel = TimezoneData.customObject(from: sortedByTime[$0])
{
let dataOperations = TimezoneDataOperations(with: dataModel) let dataOperations = TimezoneDataOperations(with: dataModel)
let date = dataOperations.todaysDate(with: 0) let date = dataOperations.todaysDate(with: 0)
let time = dataOperations.time(with: 0) let time = dataOperations.time(with: 0)

4
Clocker/Panel/Rate Controller/ReviewController.swift

@ -42,12 +42,12 @@ final class ReviewController {
// Check if the app has been installed for atleast 7 days // Check if the app has been installed for atleast 7 days
guard let install = storage.object(forKey: Keys.install) as? Date, guard let install = storage.object(forKey: Keys.install) as? Date,
install.timeIntervalSinceNow < minInstall install.timeIntervalSinceNow < minInstall
else { return false } else { return false }
// If we have never been prompted before, go ahead and prompt // If we have never been prompted before, go ahead and prompt
guard let lastPrompt = storage.object(forKey: Keys.lastPrompt) as? Date, guard let lastPrompt = storage.object(forKey: Keys.lastPrompt) as? Date,
let lastVersion = storage.object(forKey: Keys.lastVersion) as? String let lastVersion = storage.object(forKey: Keys.lastVersion) as? String
else { return true } else { return true }
// Minimum interval between two versions should be 3 months // Minimum interval between two versions should be 3 months

6
Clocker/Panel/UI/TimezoneCellView.swift

@ -39,7 +39,7 @@ class TimezoneCellView: NSTableCellView {
func setupLayout() { func setupLayout() {
guard let relativeFont = relativeDate.font, guard let relativeFont = relativeDate.font,
let sunriseFont = sunriseSetTime.font let sunriseFont = sunriseSetTime.font
else { else {
assertionFailure("Unable to convert to NSString") assertionFailure("Unable to convert to NSString")
return return
@ -128,7 +128,7 @@ class TimezoneCellView: NSTableCellView {
} }
guard let customFont = customName.font, guard let customFont = customName.font,
let timeFont = time.font let timeFont = time.font
else { else {
assertionFailure("User Font Size is in unexpectedly nil") assertionFailure("User Font Size is in unexpectedly nil")
return return
@ -165,7 +165,7 @@ class TimezoneCellView: NSTableCellView {
} }
guard let panelTableView = searchView as? PanelTableView, guard let panelTableView = searchView as? PanelTableView,
let enclosingScroller = panelTableView.enclosingScrollView let enclosingScroller = panelTableView.enclosingScrollView
else { else {
// We might be coming from the preview tableview! // We might be coming from the preview tableview!
return return

2
Clocker/Panel/UI/TimezoneDataSource.swift

@ -144,7 +144,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
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()

3
Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift

@ -40,7 +40,8 @@ class UpcomingEventViewItem: NSCollectionViewItem {
_ color: NSColor, _ color: NSColor,
_ link: URL?, _ link: URL?,
_ delegate: UpcomingEventPanelDelegate?, _ delegate: UpcomingEventPanelDelegate?,
_ isCancelled: Bool) { _ isCancelled: Bool)
{
if leadingConstraint.constant != UpcomingEventViewItem.EventLeadingConstraint / 2 { if leadingConstraint.constant != UpcomingEventViewItem.EventLeadingConstraint / 2 {
leadingConstraint.animator().constant = UpcomingEventViewItem.EventLeadingConstraint / 2 leadingConstraint.animator().constant = UpcomingEventViewItem.EventLeadingConstraint / 2
} }

6
Clocker/Preferences/About/AboutViewController.swift

@ -99,7 +99,7 @@ class AboutViewController: ParentViewController {
@IBAction func openMyTwitter(_: Any) { @IBAction func openMyTwitter(_: Any) {
guard let twitterURL = URL(string: AboutUsConstants.TwitterLink), guard let twitterURL = URL(string: AboutUsConstants.TwitterLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return } let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(twitterURL) NSWorkspace.shared.open(twitterURL)
@ -110,7 +110,7 @@ class AboutViewController: ParentViewController {
@IBAction func viewSource(_: Any) { @IBAction func viewSource(_: Any) {
guard let sourceURL = URL(string: AboutUsConstants.AppStoreLink), guard let sourceURL = URL(string: AboutUsConstants.AppStoreLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return } let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(sourceURL) NSWorkspace.shared.open(sourceURL)
@ -132,7 +132,7 @@ class AboutViewController: ParentViewController {
@IBAction func openGitHub(_: Any) { @IBAction func openGitHub(_: Any) {
guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink), guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink),
let languageCode = Locale.preferredLanguages.first else { return } let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL) NSWorkspace.shared.open(localizationURL)

15
Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

@ -80,7 +80,8 @@ class AppFeedbackWindowController: NSWindowController {
themeDidChangeNotification = NotificationCenter.default.addObserver(forName: .themeDidChangeNotification, themeDidChangeNotification = NotificationCenter.default.addObserver(forName: .themeDidChangeNotification,
object: nil, object: nil,
queue: OperationQueue.main) { _ in queue: OperationQueue.main)
{ _ in
self.window?.backgroundColor = Themer.shared().mainBackgroundColor() self.window?.backgroundColor = Themer.shared().mainBackgroundColor()
self.setup() self.setup()
} }
@ -139,9 +140,9 @@ class AppFeedbackWindowController: NSWindowController {
let preferences = DataStore.shared().timezones() let preferences = DataStore.shared().timezones()
guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let country = Locale.autoupdatingCurrent.regionCode let country = Locale.autoupdatingCurrent.regionCode
else { else {
return "Error" return "Error"
} }
@ -182,7 +183,7 @@ class AppFeedbackWindowController: NSWindowController {
private func retrieveDataForSending() -> [String: String] { private func retrieveDataForSending() -> [String: String] {
guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String, guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
else { else {
return [:] return [:]
} }
@ -285,7 +286,7 @@ class AppFeedbackWindowController: NSWindowController {
@IBAction func navigateToSupportTwitter(_: Any) { @IBAction func navigateToSupportTwitter(_: Any) {
guard let twitterURL = URL(string: AboutUsConstants.TwitterLink), guard let twitterURL = URL(string: AboutUsConstants.TwitterLink),
let countryCode = Locale.autoupdatingCurrent.regionCode else { return } let countryCode = Locale.autoupdatingCurrent.regionCode else { return }
NSWorkspace.shared.open(twitterURL) NSWorkspace.shared.open(twitterURL)
@ -311,7 +312,7 @@ extension AppFeedbackWindowController: NSWindowDelegate {
func bringPreferencesWindowToFront() { func bringPreferencesWindowToFront() {
let windows = NSApplication.shared.windows let windows = NSApplication.shared.windows
let prefWindow = windows.first(where: { window in let prefWindow = windows.first(where: { window in
return window.identifier == NSUserInterfaceItemIdentifier("Preferences") window.identifier == NSUserInterfaceItemIdentifier("Preferences")
}) })
if let prefW = prefWindow { if let prefW = prefWindow {
prefW.makeKeyAndOrderFront(self) prefW.makeKeyAndOrderFront(self)

3
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -188,7 +188,8 @@ class AppearanceViewController: ParentViewController {
refresh(panel: true, floating: true) refresh(panel: true, floating: true)
if let selectedFormat = sender.selectedItem?.title, if let selectedFormat = sender.selectedItem?.title,
selectedFormat.contains("ss") { selectedFormat.contains("ss")
{
Logger.info("Selected format contains timezone format") Logger.info("Selected format contains timezone format")
guard let panelController = PanelController.panel() else { return } guard let panelController = PanelController.panel() else { return }
panelController.pauseTimer() panelController.pauseTimer()

6
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -243,13 +243,15 @@ extension CalendarViewController: NSTableViewDelegate {
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? { func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
if let currentSource = calendars[row] as? String, if let currentSource = calendars[row] as? String,
let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell { let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell
{
message.sourceName.stringValue = currentSource message.sourceName.stringValue = currentSource
return message return message
} }
if let currentSource = calendars[row] as? CalendarInfo, if let currentSource = calendars[row] as? CalendarInfo,
let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell { let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell
{
calendarCell.calendarName.stringValue = currentSource.calendar.title calendarCell.calendarName.stringValue = currentSource.calendar.title
calendarCell.calendarSelected.state = currentSource.selected ? NSControl.StateValue.on : NSControl.StateValue.off calendarCell.calendarSelected.state = currentSource.selected ? NSControl.StateValue.on : NSControl.StateValue.off
calendarCell.calendarSelected.target = self calendarCell.calendarSelected.target = self

7
Clocker/Preferences/General/PreferencesDataSource.swift

@ -104,7 +104,8 @@ extension PreferencesDataSource: NSTableViewDataSource {
var selectedDataSource: TimezoneData? var selectedDataSource: TimezoneData?
if selectedTimezones.count > row, if selectedTimezones.count > row,
let model = TimezoneData.customObject(from: selectedTimezones[row]) { let model = TimezoneData.customObject(from: selectedTimezones[row])
{
selectedDataSource = model selectedDataSource = model
} }
@ -163,7 +164,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
"Old Label": dataObject.customLabel ?? "Error", "Old Label": dataObject.customLabel ?? "Error",
"New Label": formattedValue, "New Label": formattedValue,
], ],
for: "Custom Label Changed") for: "Custom Label Changed")
dataObject.setLabel(formattedValue) dataObject.setLabel(formattedValue)
@ -176,7 +177,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
"Selected Timezone Count": selectedTimezones.count, "Selected Timezone Count": selectedTimezones.count,
"Current Row": row, "Current Row": row,
], ],
for: "Error in selected row count") for: "Error in selected row count")
} }
} }

37
Clocker/Preferences/General/PreferencesViewController.swift

@ -19,7 +19,6 @@ struct PreferencesConstants {
} }
class PreferencesViewController: ParentViewController { class PreferencesViewController: ParentViewController {
@IBOutlet private var placeholderLabel: NSTextField! @IBOutlet private var placeholderLabel: NSTextField!
@IBOutlet private var timezoneTableView: NSTableView! @IBOutlet private var timezoneTableView: NSTableView!
@IBOutlet private var availableTimezoneTableView: NSTableView! @IBOutlet private var availableTimezoneTableView: NSTableView!
@ -43,14 +42,14 @@ class PreferencesViewController: ParentViewController {
@IBOutlet var startAtLoginLabel: NSTextField! @IBOutlet var startAtLoginLabel: NSTextField!
@IBOutlet var startupCheckbox: NSButton! @IBOutlet var startupCheckbox: NSButton!
// Sorting // Sorting
private var arePlacesSortedInAscendingOrder = false private var arePlacesSortedInAscendingOrder = false
private var arePlacesSortedInAscendingTimezoneOrder = false private var arePlacesSortedInAscendingTimezoneOrder = false
private var isTimezoneSortOptionSelected = false private var isTimezoneSortOptionSelected = false
private var isTimezoneNameSortOptionSelected = false private var isTimezoneNameSortOptionSelected = false
private var isLabelOptionSelected = false private var isLabelOptionSelected = false
private var isActivityInProgress = false { private var isActivityInProgress = false {
didSet { didSet {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
@ -73,14 +72,12 @@ class PreferencesViewController: ParentViewController {
private lazy var startupManager = StartupManager() private lazy var startupManager = StartupManager()
private var dataTask: URLSessionDataTask? = .none private var dataTask: URLSessionDataTask? = .none
private lazy var notimezoneView: NoTimezoneView? = { private lazy var notimezoneView: NoTimezoneView? = NoTimezoneView(frame: tableview.frame)
NoTimezoneView(frame: tableview.frame)
}()
private var geocodingKey: String = { private var geocodingKey: String = {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"), guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
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 ""
@ -88,8 +85,6 @@ class PreferencesViewController: ParentViewController {
return apiKey return apiKey
}() }()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -97,10 +92,11 @@ class PreferencesViewController: ParentViewController {
selector: #selector(refreshTimezoneTableView), selector: #selector(refreshTimezoneTableView),
name: NSNotification.Name.customLabelChanged, name: NSNotification.Name.customLabelChanged,
object: nil) object: nil)
NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification, NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
object: self, object: self,
queue: OperationQueue.main) { [weak self] _ in queue: OperationQueue.main)
{ [weak self] _ in
if let sSelf = self { if let sSelf = self {
sSelf.refreshTimezoneTableView() sSelf.refreshTimezoneTableView()
} }
@ -347,9 +343,10 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
for: "favouriteRemoved") for: "favouriteRemoved")
if let appDelegate = NSApplication.shared.delegate as? AppDelegate, if let appDelegate = NSApplication.shared.delegate as? AppDelegate,
let menubarFavourites = DataStore.shared().menubarTimezones(), let menubarFavourites = DataStore.shared().menubarTimezones(),
menubarFavourites.isEmpty, menubarFavourites.isEmpty,
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false { DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false
{
appDelegate.invalidateMenubarTimer(true) appDelegate.invalidateMenubarTimer(true)
} }
@ -475,7 +472,7 @@ extension PreferencesViewController {
self.prepareUIForPresentingResults() self.prepareUIForPresentingResults()
} }
}) })
} }
} }
@ -893,7 +890,7 @@ extension PreferencesViewController {
let system = NSTimeZone.system let system = NSTimeZone.system
guard let object1 = TimezoneData.customObject(from: obj1), guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2) let object2 = TimezoneData.customObject(from: obj2)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return false return false
@ -921,7 +918,7 @@ extension PreferencesViewController {
let sortedLabels = selectedTimeZones.sorted { obj1, obj2 -> Bool in let sortedLabels = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1), guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2) let object2 = TimezoneData.customObject(from: obj2)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return false return false
@ -945,7 +942,7 @@ extension PreferencesViewController {
let sortedByAddress = selectedTimeZones.sorted { obj1, obj2 -> Bool in let sortedByAddress = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1), guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2) let object2 = TimezoneData.customObject(from: obj2)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return false return false
@ -1012,7 +1009,7 @@ extension PreferencesViewController: PreferenceSelectionUpdates {
let sortedTimezones = selectedTimeZones.sorted { obj1, obj2 -> Bool in let sortedTimezones = selectedTimeZones.sorted { obj1, obj2 -> Bool in
guard let object1 = TimezoneData.customObject(from: obj1), guard let object1 = TimezoneData.customObject(from: obj1),
let object2 = TimezoneData.customObject(from: obj2) let object2 = TimezoneData.customObject(from: obj2)
else { else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return false return false

6
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -33,10 +33,12 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds || timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero || timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds { || timeFormat == DateFormat.twelveHourWithSeconds
{
totalWidth += 20 totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour } else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds { || timeFormat == DateFormat.twentyFourHourWithSeconds
{
totalWidth += 0 totalWidth += 0
} }

13
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -115,15 +115,16 @@ class StatusItemHandler: NSObject {
userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification, userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification,
object: self, object: self,
queue: mainQueue) { _ in queue: mainQueue)
{ _ in
self.setupStatusItem() self.setupStatusItem()
} }
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: OperationQueue.main) { notification in NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: OperationQueue.main) { _ in
self.menubarTimer?.invalidate() self.menubarTimer?.invalidate()
} }
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { notification in NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { _ in
self.setupStatusItem() self.setupStatusItem()
} }
} }
@ -183,7 +184,7 @@ class StatusItemHandler: NSObject {
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

1
Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

@ -65,6 +65,7 @@ class UpcomingEventStatusItemView: NSView {
]) ])
} }
@available(*, unavailable)
required init?(coder _: NSCoder) { required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }

8
Clocker/Preferences/OneWindowController.swift

@ -50,7 +50,7 @@ class OneWindowController: NSWindowController {
window?.backgroundColor = Themer.shared().mainBackgroundColor() window?.backgroundColor = Themer.shared().mainBackgroundColor()
window?.identifier = NSUserInterfaceItemIdentifier("Preferences") window?.identifier = NSUserInterfaceItemIdentifier("Preferences")
} }
private func setupToolbarImages() { private func setupToolbarImages() {
guard let tabViewController = contentViewController as? CenteredTabViewController else { guard let tabViewController = contentViewController as? CenteredTabViewController else {
return return
@ -78,18 +78,18 @@ class OneWindowController: NSWindowController {
} }
// MARK: Public // MARK: Public
func openPermissionsPane() { func openPermissionsPane() {
openPreferenceTab(at: 3) openPreferenceTab(at: 3)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
} }
// Action mapped to the + button in the PanelController. We should always open the General Pane when the + button is clicked. // Action mapped to the + button in the PanelController. We should always open the General Pane when the + button is clicked.
func openGeneralPane() { func openGeneralPane() {
openPreferenceTab(at: 0) openPreferenceTab(at: 0)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
} }
private func openPreferenceTab(at index: Int) { private func openPreferenceTab(at index: Int) {
guard let window = window else { guard let window = window else {
return return

Loading…
Cancel
Save