Skip to content

Commit

Permalink
Formatting!
Browse files Browse the repository at this point in the history
  • Loading branch information
n0shake committed Jul 5, 2021
1 parent 13eba45 commit bd09d5d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 33 deletions.
14 changes: 9 additions & 5 deletions Clocker/Panel/Notes Popover/NotesPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class NotesPopover: NSViewController {
guard let initialStart = calendar?.nextDate(after: currentDate,
matching: NSCalendar.Unit.hour,
value: hour,
options: NSCalendar.Options.matchPreviousTimePreservingSmallerUnits) else {
options: NSCalendar.Options.matchPreviousTimePreservingSmallerUnits)
else {
assertionFailure("Initial Date object was unexepectedly nil")
return
}
Expand All @@ -196,7 +197,8 @@ class NotesPopover: NSViewController {
guard let newDate = currentCalendar?.date(byAdding: NSCalendar.Unit.minute,
value: 0,
to: Date(),
options: NSCalendar.Options.matchLast) else {
options: NSCalendar.Options.matchLast)
else {
assertionFailure("Initial Date object was unexepectedly nil")
completionHandler(nil)
return
Expand All @@ -222,7 +224,7 @@ class NotesPopover: NSViewController {
}
completionHandler(completedDate)

})
})
} catch {
assertionFailure("Failed to successfully initialize DataDetector")
completionHandler(nil)
Expand Down Expand Up @@ -320,7 +322,8 @@ class NotesPopover: NSViewController {
}

private func updateTimezoneInDefaultPreferences(with override: Int,
_: OverrideType) {
_: OverrideType)
{
let timezones = DataStore.shared().timezones()

var timezoneObjects: [TimezoneData] = []
Expand Down Expand Up @@ -389,7 +392,8 @@ class NotesPopover: NSViewController {
timezone: model.timezone(),
alertIndex: alertIndex,
reminderDate: reminderPicker.dateValue,
additionalNotes: model.note) {
additionalNotes: model.note)
{
showSuccessMessage()
}
}
Expand Down
26 changes: 14 additions & 12 deletions Clocker/Panel/PanelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ class PanelController: ParentPanelController {
}

if let statusWindow = statusBackgroundWindow,
let statusButton = statusView {
let statusButton = statusView
{
var statusItemFrame = statusWindow.convertToScreen(statusButton.frame)
var statusItemScreen = NSScreen.main
var testPoint = statusItemFrame.origin
Expand Down Expand Up @@ -184,16 +185,17 @@ class PanelController: ParentPanelController {
let preferences = DataStore.shared().timezones()

guard let theme = 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 relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber,
let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber,
let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode else {
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber,
let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber,
let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber,
let showDateInMenu = DataStore.shared().retrieve(key: CLShowDateInMenu) as? NSNumber,
let showPlaceInMenu = DataStore.shared().retrieve(key: CLShowPlaceInMenu) as? NSNumber,
let showUpcomingEventView = DataStore.shared().retrieve(key: CLShowUpcomingEventView) as? String,
let country = Locale.autoupdatingCurrent.regionCode
else {
return
}

Expand Down Expand Up @@ -313,7 +315,7 @@ class PanelController: ParentPanelController {
}

class func panel() -> PanelController? {
let panel = NSApplication.shared.windows.compactMap { (window) -> PanelController? in
let panel = NSApplication.shared.windows.compactMap { window -> PanelController? in

guard let parent = window.windowController as? PanelController else {
return nil
Expand Down
1 change: 1 addition & 0 deletions Clocker/Panel/ParentPanelController+ModernSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension ParentPanelController {
if modernSlider != nil {
modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
modernSlider.enclosingScrollView?.backgroundColor = NSColor.clear
modernSlider.setAccessibility("ModernSlider")
modernSlider.postsBoundsChangedNotifications = true
NotificationCenter.default.addObserver(self,
selector: #selector(collectionViewDidScroll(_:)),
Expand Down
31 changes: 18 additions & 13 deletions Clocker/Panel/ParentPanelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ParentPanelController: NSWindowController {

var datasource: TimezoneDataSource?

private lazy var feedbackWindow: AppFeedbackWindowController = AppFeedbackWindowController.shared()
private lazy var feedbackWindow = AppFeedbackWindowController.shared()

private var notePopover: NotesPopover?

Expand Down Expand Up @@ -395,7 +395,7 @@ class ParentPanelController: NSWindowController {

var current = main.frame.height

let activeScreens = NSScreen.screens.filter { (current) -> Bool in
let activeScreens = NSScreen.screens.filter { current -> Bool in
NSMouseInRect(mouseLocation, current.frame, false)
}

Expand Down Expand Up @@ -425,8 +425,9 @@ class ParentPanelController: NSWindowController {
if let note = object?.note, note.isEmpty == false {
newHeight += 20
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil {
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil
{
newHeight += 20
}
}
Expand Down Expand Up @@ -496,7 +497,7 @@ class ParentPanelController: NSWindowController {
updatePanelColor()

let defaults = DataStore.shared().timezones()
let convertedTimezones = defaults.map { (data) -> TimezoneData in
let convertedTimezones = defaults.map { data -> TimezoneData in
TimezoneData.customObject(from: data)!
}

Expand Down Expand Up @@ -533,7 +534,8 @@ class ParentPanelController: NSWindowController {
let currentCalendar = Calendar(identifier: .gregorian)
guard let newDate = currentCalendar.date(byAdding: .minute,
value: Int(futureSlider.doubleValue),
to: Date()) else {
to: Date())
else {
assertionFailure("Data was unexpectedly nil")
return
}
Expand Down Expand Up @@ -599,8 +601,9 @@ class ParentPanelController: NSWindowController {
let current = preferences[$0]

if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current) {
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current)
{
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return
}
Expand All @@ -620,7 +623,8 @@ class ParentPanelController: NSWindowController {
if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note
} 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
} else {
cellView.noteLabel.stringValue = CLEmptyString
Expand Down Expand Up @@ -719,7 +723,8 @@ class ParentPanelController: NSWindowController {

@IBAction func calendarButtonAction(_: NSButton) {
if calendarButton.title == NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access") {
comment: "Button Title for no Calendar access")
{
showPermissionsWindow()
} else {
retrieveCalendarEvents()
Expand Down Expand Up @@ -840,7 +845,7 @@ class ParentPanelController: NSWindowController {
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)

self.setCalendarButtonTitle(buttonTitle: "in \(withoutAgo.lowercased())")

if upcomingEvent.meetingURL != nil {
self.whiteRemoveButton.image = Themer.shared().videoCallImage()
}
Expand Down Expand Up @@ -1033,7 +1038,7 @@ class ParentPanelController: NSWindowController {

@objc func openCrowdin() {
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)

Expand Down Expand Up @@ -1112,7 +1117,7 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
let filteredServices = proposed.filter { service in
allowedServices.contains(service.title)
}

var newProposedServices: [NSSharingService] = [copySharingService]
newProposedServices.append(contentsOf: filteredServices)
return newProposedServices
Expand Down
4 changes: 2 additions & 2 deletions Clocker/Panel/Rate Controller/ReviewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ final class ReviewController {

// Check if the app has been installed for atleast 7 days
guard let install = storage.object(forKey: Keys.install) as? Date,
install.timeIntervalSinceNow < minInstall
install.timeIntervalSinceNow < minInstall
else { return false }

// If we have never been prompted before, go ahead and prompt
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 }

// Minimum interval between two versions should be 45
Expand Down
2 changes: 1 addition & 1 deletion Clocker/Panel/Rate Controller/UpcomingEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ThinScroller: NSScroller {
class DraggableClipView: NSClipView {
private var clickPoint: NSPoint!
private var trackingArea: NSTrackingArea?

override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
clickPoint = event.locationInWindow
Expand Down

0 comments on commit bd09d5d

Please sign in to comment.