From 33623d4bbc5f74fa9a1fa132dc77723be4bf666f Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 16 Apr 2022 13:16:22 -0400 Subject: [PATCH] Make things more readable. --- .../Dependencies/Date Additions/Date+Comparators.swift | 2 +- Clocker/Onboarding/OnboardingSearchController.swift | 5 ++++- Clocker/Panel/UI/TimezoneDataSource.swift | 5 ++++- .../Panel/Upcoming Events/UpcomingEventsDataSource.swift | 1 + .../App Feedback/AppFeedbackWindowController.swift | 9 ++++++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Clocker/Dependencies/Date Additions/Date+Comparators.swift b/Clocker/Dependencies/Date Additions/Date+Comparators.swift index 85770cf..b364293 100755 --- a/Clocker/Dependencies/Date Additions/Date+Comparators.swift +++ b/Clocker/Dependencies/Date Additions/Date+Comparators.swift @@ -43,7 +43,7 @@ public extension Date { * - returns: A TimeChunk representing the time between the dates, in natural form */ func chunkBetween(date: Date) -> TimeChunk { - let components : Set = [.year, .month, .day, .hour, .minute, .second] + let components: Set = [.year, .month, .day, .hour, .minute, .second] let compenentsBetween = Calendar.autoupdatingCurrent.dateComponents(components, from: self, to: date) return TimeChunk(seconds: compenentsBetween.second!, minutes: compenentsBetween.minute!, diff --git a/Clocker/Onboarding/OnboardingSearchController.swift b/Clocker/Onboarding/OnboardingSearchController.swift index 84fc1bf..d87dbac 100644 --- a/Clocker/Onboarding/OnboardingSearchController.swift +++ b/Clocker/Onboarding/OnboardingSearchController.swift @@ -445,7 +445,10 @@ extension OnboardingSearchController: NSTableViewDataSource { } func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? { - if let result = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "resultCellView"), owner: self) as? ResultTableViewCell, row >= 0, row < searchResultsDataSource.resultsCount() { + if let result = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "resultCellView"), owner: self) as? ResultTableViewCell, + row >= 0, + row < searchResultsDataSource.resultsCount() + { let currentSelection = searchResultsDataSource.retrieveResult(row) if let timezone = currentSelection as? TimezoneMetadata { result.result.stringValue = " \(timezone.formattedName)" diff --git a/Clocker/Panel/UI/TimezoneDataSource.swift b/Clocker/Panel/UI/TimezoneDataSource.swift index 26f36bd..be15e45 100644 --- a/Clocker/Panel/UI/TimezoneDataSource.swift +++ b/Clocker/Panel/UI/TimezoneDataSource.swift @@ -85,7 +85,10 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate { return 100 } - if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, timezones.count > row, let relativeDisplay = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber { + if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, + timezones.count > row, + let relativeDisplay = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber + { let model = timezones[row] let shouldShowSunrise = DataStore.shared().shouldDisplay(.sunrise) diff --git a/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift b/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift index 316b1a9..b0df0fe 100644 --- a/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift +++ b/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift @@ -1,5 +1,6 @@ // Copyright © 2015 Abhishek Banthia +import AppKit import Foundation class UpcomingEventsDataSource: NSObject, NSCollectionViewDataSource, NSCollectionViewDelegateFlowLayout { diff --git a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift index 16f8781..a351edc 100644 --- a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift +++ b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift @@ -158,7 +158,14 @@ class AppFeedbackWindowController: NSWindowController { guard let timezoneObject = TimezoneData.customObject(from: data) else { return nil } - return "Timezone: \(timezoneObject.timezone()) Name: \(timezoneObject.formattedAddress ?? "No") Favourited: \((timezoneObject.isFavourite == 1) ? "Yes" : "No") Note: \(timezoneObject.note ?? "No Note") System: \(timezoneObject.isSystemTimezone ? "Yes" : "No")" + let customString = """ + Timezone: \(timezoneObject.timezone()) + Name: \(timezoneObject.formattedAddress ?? "No") + Favourited: \((timezoneObject.isFavourite == 1) ? "Yes" : "No") + Note: \(timezoneObject.note ?? "No Note") + System: \(timezoneObject.isSystemTimezone ? "Yes" : "No")" + """ + return customString } var relativeDate = "Relative"