diff --git a/Clocker/AppDelegate.swift b/Clocker/AppDelegate.swift index b72014b..54fbf10 100644 --- a/Clocker/AppDelegate.swift +++ b/Clocker/AppDelegate.swift @@ -7,8 +7,8 @@ import FirebaseCore import FirebaseCrashlytics open class AppDelegate: NSObject, NSApplicationDelegate { - private lazy var floatingWindow: FloatingWindowController = FloatingWindowController.shared() - private lazy var panelController: PanelController = PanelController.shared() + private lazy var floatingWindow = FloatingWindowController.shared() + private lazy var panelController = PanelController.shared() private var statusBarHandler: StatusItemHandler! private var panelObserver: NSKeyValueObservation? @@ -16,7 +16,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate { 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 { let hotKeyCenter = PTHotKeyCenter.shared() @@ -30,10 +30,10 @@ open class AppDelegate: NSObject, NSApplicationDelegate { } // Register new key - let newHotKey: PTHotKey = PTHotKey(identifier: keyPath, - keyCombo: newShortcut, - target: self, - action: #selector(ping(_:))) + let newHotKey = PTHotKey(identifier: keyPath, + keyCombo: newShortcut, + target: self, + action: #selector(ping(_:))) hotKeyCenter?.register(newHotKey) } diff --git a/Clocker/Clocker.xcodeproj/project.pbxproj b/Clocker/Clocker.xcodeproj/project.pbxproj index 8bbf603..e6cfe45 100755 --- a/Clocker/Clocker.xcodeproj/project.pbxproj +++ b/Clocker/Clocker.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ 3531F7F126936DE900DF0111 /* upload-symbols in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7EC26936DE900DF0111 /* upload-symbols */; }; 3531F7F226936DE900DF0111 /* upload-symbols in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7EC26936DE900DF0111 /* upload-symbols */; }; 3531F7F52693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; }; - 3531F7F62693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; }; 3531F7F72693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; }; 3531F80626938D7700DF0111 /* GoogleUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3531F7FC26938D7600DF0111 /* GoogleUtilities.framework */; }; 3531F80726938D7700DF0111 /* GoogleUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3531F7FC26938D7600DF0111 /* GoogleUtilities.framework */; }; @@ -216,13 +215,6 @@ remoteGlobalIDString = E273122E1349EC9000A84433; remoteInfo = PTHotKey.framework; }; - 9A86E2BF1CE04F1600547EE7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 9A86E2B51CE04F1600547EE7 /* ShortcutRecorder.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 0D6B2468180304DE00CE1142; - remoteInfo = Demo; - }; C20839CC21515C1F00C86589 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DD4F7BFB13C30F9F00825C6E /* Project object */; @@ -769,7 +761,6 @@ children = ( 9A86E2BC1CE04F1600547EE7 /* ShortcutRecorder.framework */, 9A86E2BE1CE04F1600547EE7 /* PTHotKey.framework */, - 9A86E2C01CE04F1600547EE7 /* Demo.app */, ); name = Products; sourceTree = ""; @@ -842,6 +833,14 @@ path = Frameworks; sourceTree = ""; }; + 9AEF66812693A6270036142F /* Recovered References */ = { + isa = PBXGroup; + children = ( + 3531F7F42693882300DF0111 /* Keys.plist */, + ); + name = "Recovered References"; + sourceTree = ""; + }; C2021B89219F30960036C247 /* Onboarding */ = { isa = PBXGroup; children = ( @@ -916,6 +915,7 @@ 3531F7EC26936DE900DF0111 /* upload-symbols */, 3531F7C026936C6E00DF0111 /* GoogleService-Info.plist */, DD4F7C0513C30F9F00825C6E /* Products */, + 9AEF66812693A6270036142F /* Recovered References */, ); sourceTree = ""; }; @@ -1032,7 +1032,6 @@ DD4F7C0213C30F9F00825C6E /* Resources */, 9A20A0711C4E808500FB45AB /* Login Item Helper */, 9A5E75EC204CC39700119939 /* Embed Frameworks */, - C2A632A020EAC5EE00EB6BEA /* SwiftFormat */, 3531F7F326936F5000DF0111 /* ShellScript */, ); buildRules = ( @@ -1156,13 +1155,6 @@ remoteRef = 9A86E2BD1CE04F1600547EE7 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 9A86E2C01CE04F1600547EE7 /* Demo.app */ = { - isa = PBXReferenceProxy; - fileType = wrapper.application; - path = Demo.app; - remoteRef = 9A86E2BF1CE04F1600547EE7 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -1559,7 +1551,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; @@ -1592,7 +1584,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 21.07.01; + MARKETING_VERSION = 21.07.02; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.abhishek.Clocker; @@ -2128,7 +2120,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -2162,7 +2154,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 21.07.01; + MARKETING_VERSION = 21.07.02; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; "OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG"; @@ -2210,7 +2202,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; @@ -2243,7 +2235,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 21.07.01; + MARKETING_VERSION = 21.07.02; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; "OTHER_SWIFT_FLAGS[arch=*]" = "-D RELEASE"; diff --git a/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index ae6fe6b..51bc80e 100644 --- a/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -27,8 +27,8 @@ endingColumnNumber = "9223372036854775807" startingLineNumber = "47" endingLineNumber = "47" - landmarkName = "geocodingKey" - landmarkType = "24"> + landmarkName = "unknown" + landmarkType = "0"> diff --git a/Clocker/ClockerUITests/AboutUsTests.swift b/Clocker/ClockerUITests/AboutUsTests.swift index ae1e172..e736976 100644 --- a/Clocker/ClockerUITests/AboutUsTests.swift +++ b/Clocker/ClockerUITests/AboutUsTests.swift @@ -33,7 +33,7 @@ class AboutUsTests: XCTestCase { tapAboutTab() let appDisplayName = "CFBundleDisplayName".localizedString() - let expectedVersion = "\(appDisplayName) 21.07.01 (93)" + let expectedVersion = "\(appDisplayName) 21.07.02 (95)" guard let presentVersion = app.windows["Clocker"].staticTexts["ClockerVersion"].value as? String else { XCTFail("Present version not present") diff --git a/Clocker/ClockerUITests/CopyToClipboardTests.swift b/Clocker/ClockerUITests/CopyToClipboardTests.swift index 4b6e6ad..62f3cbd 100644 --- a/Clocker/ClockerUITests/CopyToClipboardTests.swift +++ b/Clocker/ClockerUITests/CopyToClipboardTests.swift @@ -4,16 +4,16 @@ import XCTest class CopyToClipboardTests: XCTestCase { var app: XCUIApplication! - + override func setUp() { continueAfterFailure = false app = XCUIApplication() app.launch() - if app.tables["FloatingTableView"].exists == false { - app.tapMenubarIcon() - app.buttons["Pin"].click() - } +// if app.tables["FloatingTableView"].exists == false { +// app.tapMenubarIcon() +// app.buttons["Pin"].click() +// } } override func tearDownWithError() throws { @@ -23,20 +23,20 @@ class CopyToClipboardTests: XCTestCase { func testFullCopy() throws { let cellCount = app.tables["FloatingTableView"].cells.count var clipboardValue = String() - for cellIndex in 0.. Bool in + addUIInterruptionMonitor(withDescription: "Reminders Access") { alert -> Bool in let alertButton = alert.buttons["OK"] if alertButton.exists { alertButton.tap() diff --git a/Clocker/ClockerUITests/PreferencesTest.swift b/Clocker/ClockerUITests/PreferencesTest.swift index 177d78a..5c0f1f0 100644 --- a/Clocker/ClockerUITests/PreferencesTest.swift +++ b/Clocker/ClockerUITests/PreferencesTest.swift @@ -31,7 +31,7 @@ class PreferencesTest: XCTestCase { return } - app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.click() + app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).click() XCTAssertTrue(app.checkBoxes["DeleteTimezone"].isEnabled) } @@ -334,7 +334,7 @@ class PreferencesTest: XCTestCase { if rowQueryCount > 0 { // Table Rows aren't hittable in Xcode 12.0 (10/7/20) and so we need to find a closer co-ordinate and perform click() - let currentElement = clockerWindow.tables["TimezoneTableView"].tableRows.firstMatch + let currentElement = clockerWindow.tables["TimezoneTableView"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)) currentElement.click() for _ in 0 ..< rowQueryCount { @@ -416,7 +416,7 @@ extension XCTestCase { return } - let currentElement = app.windows["Clocker"].tableRows.firstMatch + let currentElement = app.windows["Clocker"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)) currentElement.click() while rowQueryCount > 0 { @@ -442,7 +442,7 @@ extension XCTestCase { } private func deleteAtRow(_ rowToDelete: XCUIElement, for _: XCUIApplication, shouldSleep: Bool) { - rowToDelete.click() + rowToDelete.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).click() rowToDelete.typeKey(XCUIKeyboardKey.delete, modifierFlags: XCUIElement.KeyModifierFlags()) if shouldSleep { sleep(2) diff --git a/Clocker/ClockerUnitTests/ClockerUnitTests.swift b/Clocker/ClockerUnitTests/ClockerUnitTests.swift index 09e0533..1e88a88 100644 --- a/Clocker/ClockerUnitTests/ClockerUnitTests.swift +++ b/Clocker/ClockerUnitTests/ClockerUnitTests.swift @@ -120,16 +120,16 @@ class ClockerUnitTests: XCTestCase { let timezone = TimezoneData.customObject(from: $0) return timezone?.placeID == "TestIdentifier" } - + // California is absent. Add it! if filteredCount.count == 0 { let timezoneData = TimezoneData(with: california) let operationsObject = TimezoneDataOperations(with: timezoneData) operationsObject.saveObject() } - + let oldCount = (defaults.object(forKey: CLDefaultPreferenceKey) as? [Data])?.count ?? 0 - + currentFavourites = currentFavourites.filter { let timezone = TimezoneData.customObject(from: $0) return timezone?.placeID != "TestIdentifier" @@ -288,7 +288,8 @@ class ClockerUnitTests: XCTestCase { guard let newDate = cal?.date(byAdding: .minute, value: 0, to: Date(), - options: .matchFirst) else { + options: .matchFirst) + else { XCTFail("Unable to add dates!") return } diff --git a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift index ae92fef..d4ef137 100644 --- a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift +++ b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift @@ -11,7 +11,7 @@ struct ModelConstants { static let emptyString = "" } -public struct DateFormat { +public enum DateFormat { public static let twelveHour = "h:mm a" public static let twelveHourWithSeconds = "h:mm:ss a" public static let twentyFourHour = "HH:mm" @@ -82,7 +82,7 @@ public class TimezoneData: NSObject, NSCoding { public var isSystemTimezone = false public var overrideFormat: TimezoneOverride = .globalFormat - public override init() { + override public init() { selectionType = .timezone isFavourite = 0 note = ModelConstants.emptyString @@ -303,7 +303,7 @@ public class TimezoneData: NSObject, NSCoding { public func timezoneFormat(_ currentFormat: NSNumber) -> String { let chosenDefault = currentFormat let timeFormat = TimezoneData.values[chosenDefault] ?? DateFormat.twelveHour - + switch overrideFormat { case .globalFormat: return timeFormat @@ -338,7 +338,7 @@ public class TimezoneData: NSObject, NSCoding { return formatInString.contains("ss") } - public override var hash: Int { + override public var hash: Int { guard let placeIdentifier = placeID, let timezone = timezoneID else { return -1 } @@ -350,14 +350,14 @@ public class TimezoneData: NSObject, NSCoding { return lhs.placeID == rhs.placeID } - public override func isEqual(to object: Any?) -> Bool { + override public func isEqual(to object: Any?) -> Bool { if let other = object as? TimezoneData { return placeID == other.placeID } return false } - public override func isEqual(_ object: Any?) -> Bool { + override public func isEqual(_ object: Any?) -> Bool { guard let compared = object as? TimezoneData else { return false } @@ -367,12 +367,12 @@ public class TimezoneData: NSObject, NSCoding { } } -extension TimezoneData { - public override var description: String { +public extension TimezoneData { + override var description: String { return objectDescription() } - public override var debugDescription: String { + override var debugDescription: String { return objectDescription() } diff --git a/Clocker/Dependencies/Date Additions/TimePeriodChain.swift b/Clocker/Dependencies/Date Additions/TimePeriodChain.swift index f0c691c..52a8be8 100755 --- a/Clocker/Dependencies/Date Additions/TimePeriodChain.swift +++ b/Clocker/Dependencies/Date Additions/TimePeriodChain.swift @@ -138,15 +138,15 @@ open class TimePeriodChain: TimePeriodGroup { _end = _end?.addingTimeInterval(duration) } - public override func map(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] { + override public func map(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] { 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) } - internal override func reduce(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result { + override internal func reduce(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result { return try periods.reduce(initialResult, nextPartialResult) } diff --git a/Clocker/Dependencies/Solar.swift b/Clocker/Dependencies/Solar.swift index 23b9b93..c31203c 100644 --- a/Clocker/Dependencies/Solar.swift +++ b/Clocker/Dependencies/Solar.swift @@ -176,10 +176,10 @@ public struct Solar { } } -extension Solar { +public extension Solar { /// Whether the location specified by the `latitude` and `longitude` is in daytime on `date` /// - Complexity: O(1) - public var isDaytime: Bool { + var isDaytime: Bool { guard let sunrise = sunrise, let sunset = sunset @@ -199,7 +199,7 @@ extension Solar { /// Whether the location specified by the `latitude` and `longitude` is in nighttime on `date` /// - Complexity: O(1) - public var isNighttime: Bool { + var isNighttime: Bool { return !isDaytime } } diff --git a/Clocker/Events and Reminders/CalendarHandler.swift b/Clocker/Events and Reminders/CalendarHandler.swift index 40e11b1..80a4028 100644 --- a/Clocker/Events and Reminders/CalendarHandler.swift +++ b/Clocker/Events and Reminders/CalendarHandler.swift @@ -21,7 +21,7 @@ extension EventCenter { var sourcesAndCalendars: [Any] = [] // Fetch array of user's calendars sorted first by source title and then by calendar title - let calendars = eventStore.calendars(for: .event).sorted { (cal1, cal2) -> Bool in + let calendars = eventStore.calendars(for: .event).sorted { cal1, cal2 -> Bool in if cal1.source.sourceIdentifier == cal2.source.sourceIdentifier { return cal1.title < cal2.title @@ -232,7 +232,7 @@ extension EventCenter { } func retrieveAllCalendarIdentifiers() -> [String] { - return eventStore.calendars(for: .event).map { (calendar) -> String in + return eventStore.calendars(for: .event).map { calendar -> String in calendar.calendarIdentifier } } @@ -242,7 +242,8 @@ extension EventCenter { dateComps.day = day guard let convertedDate = calendar?.date(byAdding: dateComps, to: Date(), - options: NSCalendar.Options.matchFirst) else { + options: NSCalendar.Options.matchFirst) + else { return Date() } return convertedDate @@ -313,7 +314,7 @@ extension EventCenter { // We now sort the array so that AllDay Events are first, then sort by startTime for date in eventsForDateMapper.keys { - let sortedEvents = eventsForDateMapper[date]?.sorted(by: { (event1, event2) -> Bool in + let sortedEvents = eventsForDateMapper[date]?.sorted(by: { event1, event2 -> Bool in if event1.isAllDay { return true } else if event2.isAllDay { return false } else { return event1.event.startDate < event2.event.startDate } }) eventsForDateMapper[date] = sortedEvents @@ -378,7 +379,8 @@ extension EventCenter { || actualLink.contains("indigo.collocall.de") || actualLink.contains("public.senfcall.de") || actualLink.contains("youcanbook.me/zoom/") - || actualLink.contains("workplace.com/groupcall") { + || actualLink.contains("workplace.com/groupcall") + { if let zoomLink = result.url { return zoomLink } diff --git a/Clocker/Events and Reminders/EventCenter.swift b/Clocker/Events and Reminders/EventCenter.swift index 5bc40c7..5d6e5ee 100644 --- a/Clocker/Events and Reminders/EventCenter.swift +++ b/Clocker/Events and Reminders/EventCenter.swift @@ -16,7 +16,7 @@ class EventCenter: NSObject { var eventsForDate: [Date: [EventInfo]] = [:] var filteredEvents: [Date: [EventInfo]] = [:] - + private let fetchQueue = DispatchQueue(label: "com.abhishek.fetch") @discardableResult class func sharedCenter() -> EventCenter { @@ -43,7 +43,7 @@ class EventCenter: NSObject { private func refetchAll() { Logger.info("\nRefetching events from the store") - + eventsForDate = [:] filteredEvents = [:] autoreleasepool { @@ -53,6 +53,5 @@ class EventCenter: NSObject { self.fetchEvents(-40, 80) } } - } } diff --git a/Clocker/Events and Reminders/RemindersHandler.swift b/Clocker/Events and Reminders/RemindersHandler.swift index 7546c81..9b93518 100644 --- a/Clocker/Events and Reminders/RemindersHandler.swift +++ b/Clocker/Events and Reminders/RemindersHandler.swift @@ -51,7 +51,8 @@ extension EventCenter { timezone: String, alertIndex: Int, reminderDate: Date, - additionalNotes: String?) -> Bool { + additionalNotes: String?) -> Bool + { initializeStoreIfNeccesary() if reminderAccessNotDetermined() || reminderAccessDenied() { diff --git a/Clocker/Menu Bar/MenubarHandler.swift b/Clocker/Menu Bar/MenubarHandler.swift index eddee16..14cc331 100644 --- a/Clocker/Menu Bar/MenubarHandler.swift +++ b/Clocker/Menu Bar/MenubarHandler.swift @@ -19,7 +19,7 @@ class MenubarHandler: NSObject { } if menubarTitles.isEmpty == false { - let titles = menubarTitles.map { (data) -> String? in + let titles = menubarTitles.map { data -> String? in let timezone = TimezoneData.customObject(from: data) let operationsObject = TimezoneDataOperations(with: timezone!) return "\(operationsObject.menuTitle().trimmingCharacters(in: NSCharacterSet.whitespacesAndNewlines))" diff --git a/Clocker/Menu Bar/StatusContainerView.swift b/Clocker/Menu Bar/StatusContainerView.swift index 8890b50..c266f5f 100644 --- a/Clocker/Menu Bar/StatusContainerView.swift +++ b/Clocker/Menu Bar/StatusContainerView.swift @@ -31,10 +31,12 @@ func compactWidth(for timezone: TimezoneData) -> Int { if timeFormat == DateFormat.twelveHour || timeFormat == DateFormat.twelveHourWithSeconds || timeFormat == DateFormat.twelveHourWithZero - || timeFormat == DateFormat.twelveHourWithSeconds { + || timeFormat == DateFormat.twelveHourWithSeconds + { totalWidth += 20 } else if timeFormat == DateFormat.twentyFourHour - || timeFormat == DateFormat.twentyFourHourWithSeconds { + || timeFormat == DateFormat.twentyFourHourWithSeconds + { totalWidth += 0 } @@ -79,7 +81,7 @@ class StatusContainerView: NSView { ] func containerWidth(for timezones: [Data]) -> CGFloat { - let compressedWidth = timezones.reduce(0.0) { (result, timezone) -> CGFloat in + let compressedWidth = timezones.reduce(0.0) { result, timezone -> CGFloat in if let timezoneObject = TimezoneData.customObject(from: timezone) { let precalculatedWidth = Double(compactWidth(for: timezoneObject)) @@ -106,6 +108,7 @@ class StatusContainerView: NSView { addSubviews() } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/Clocker/Menu Bar/StatusItemHandler.swift b/Clocker/Menu Bar/StatusItemHandler.swift index 8f1be21..cc941d7 100644 --- a/Clocker/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Menu Bar/StatusItemHandler.swift @@ -141,7 +141,7 @@ class StatusItemHandler: NSObject { private func retrieveSyncedMenubarTimezones() -> [Data] { let defaultPreferences = DataStore.shared().retrieve(key: CLDefaultPreferenceKey) as? [Data] ?? [] - let menubarTimezones = defaultPreferences.filter { (data) -> Bool in + let menubarTimezones = defaultPreferences.filter { data -> Bool in if let timezoneObj = TimezoneData.customObject(from: data) { return timezoneObj.isFavourite == 1 } @@ -185,7 +185,7 @@ class StatusItemHandler: NSObject { if let strongSelf = self { 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 menubarTimer?.tolerance = shouldDisplaySeconds ? 0.5 : 20 diff --git a/Clocker/Menu Bar/StatusItemView.swift b/Clocker/Menu Bar/StatusItemView.swift index 0b3f5bb..fff2da2 100644 --- a/Clocker/Menu Bar/StatusItemView.swift +++ b/Clocker/Menu Bar/StatusItemView.swift @@ -36,8 +36,8 @@ extension NSView { class StatusItemView: NSView { // MARK: Private variables - private let locationView: NSTextField = NSTextField(labelWithString: "Hello") - private let timeView: NSTextField = NSTextField(labelWithString: "Mon 19:14 PM") + private let locationView = NSTextField(labelWithString: "Hello") + private let timeView = NSTextField(labelWithString: "Mon 19:14 PM") private var operationsObject: TimezoneDataOperations { return TimezoneDataOperations(with: dataObject) } @@ -117,6 +117,7 @@ class StatusItemView: NSView { timeView.attributedStringValue = NSAttributedString(string: operationsObject.compactMenuSubtitle(), attributes: timeAttributes) } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/Clocker/Onboarding/FinalOnboardingViewController.swift b/Clocker/Onboarding/FinalOnboardingViewController.swift index 42ef30a..11be709 100644 --- a/Clocker/Onboarding/FinalOnboardingViewController.swift +++ b/Clocker/Onboarding/FinalOnboardingViewController.swift @@ -71,7 +71,7 @@ class FinalOnboardingViewController: NSViewController { @IBAction func localizationAction(_: Any) { guard let localizationURL = URL(string: AboutUsConstants.TwitterLink), - let languageCode = Locale.preferredLanguages.first else { return } + let languageCode = Locale.preferredLanguages.first else { return } NSWorkspace.shared.open(localizationURL) @@ -103,7 +103,8 @@ class FinalOnboardingViewController: NSViewController { } guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String, - let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else { + let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String + else { return nil } let operatingSystem = ProcessInfo.processInfo.operatingSystemVersion @@ -134,7 +135,8 @@ class EmailTextFieldValidator { range: range) if allMatches.count == 1, - allMatches.first?.url?.absoluteString.contains("mailto:") == true { + allMatches.first?.url?.absoluteString.contains("mailto:") == true + { return trimmedText } return nil diff --git a/Clocker/Onboarding/OnboardingSearchController.swift b/Clocker/Onboarding/OnboardingSearchController.swift index eeda040..9c30da4 100644 --- a/Clocker/Onboarding/OnboardingSearchController.swift +++ b/Clocker/Onboarding/OnboardingSearchController.swift @@ -27,8 +27,9 @@ class OnboardingSearchController: NSViewController { private var geocodingKey: String = { guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"), - let dictionary = NSDictionary(contentsOfFile: path), - let apiKey = dictionary["GeocodingKey"] as? String else { + let dictionary = NSDictionary(contentsOfFile: path), + let apiKey = dictionary["GeocodingKey"] as? String + else { assertionFailure("Unable to find the API key") return "" } @@ -373,7 +374,7 @@ class OnboardingSearchController: NSViewController { self.findLocalSearchResultsForTimezones() self.prepareUIForPresentingResults() } - }) + }) } private func presentErrorMessage(_ errorMessage: String) { @@ -398,7 +399,7 @@ class OnboardingSearchController: NSViewController { } private func appendResultsToFilteredArray(_ results: [SearchResult.Result]) { - let finalTimezones: [TimezoneData] = results.map { (result) -> TimezoneData in + let finalTimezones: [TimezoneData] = results.map { result -> TimezoneData in let location = result.geometry.location let latitude = location.lat let longitude = location.lng diff --git a/Clocker/Overall App/DateFormatterManager.swift b/Clocker/Overall App/DateFormatterManager.swift index d1df9ae..db70d94 100644 --- a/Clocker/Overall App/DateFormatterManager.swift +++ b/Clocker/Overall App/DateFormatterManager.swift @@ -5,9 +5,9 @@ import Cocoa class DateFormatterManager: NSObject { public static let sharedInstance = DateFormatterManager() - private static var dateFormatter: DateFormatter = DateFormatter() - private static var calendarDateFormatter: DateFormatter = DateFormatter() - private static var simpleFormatter: DateFormatter = DateFormatter() + private static var dateFormatter = DateFormatter() + private static var calendarDateFormatter = DateFormatter() + private static var simpleFormatter = DateFormatter() private static var specializedFormatter = DateFormatter() private static var localizedForamtter = DateFormatter() private static var localizedSimpleFormatter = DateFormatter()