Browse Source

Formatting!

pull/101/head
Abhishek Banthia 4 years ago
parent
commit
bd09d5d80e
  1. 12
      Clocker/Panel/Notes Popover/NotesPopover.swift
  2. 8
      Clocker/Panel/PanelController.swift
  3. 1
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  4. 21
      Clocker/Panel/ParentPanelController.swift

12
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -175,7 +175,8 @@ class NotesPopover: NSViewController {
guard let initialStart = calendar?.nextDate(after: currentDate, guard let initialStart = calendar?.nextDate(after: currentDate,
matching: NSCalendar.Unit.hour, matching: NSCalendar.Unit.hour,
value: hour, value: hour,
options: NSCalendar.Options.matchPreviousTimePreservingSmallerUnits) else { options: NSCalendar.Options.matchPreviousTimePreservingSmallerUnits)
else {
assertionFailure("Initial Date object was unexepectedly nil") assertionFailure("Initial Date object was unexepectedly nil")
return return
} }
@ -196,7 +197,8 @@ class NotesPopover: NSViewController {
guard let newDate = currentCalendar?.date(byAdding: NSCalendar.Unit.minute, guard let newDate = currentCalendar?.date(byAdding: NSCalendar.Unit.minute,
value: 0, value: 0,
to: Date(), to: Date(),
options: NSCalendar.Options.matchLast) else { options: NSCalendar.Options.matchLast)
else {
assertionFailure("Initial Date object was unexepectedly nil") assertionFailure("Initial Date object was unexepectedly nil")
completionHandler(nil) completionHandler(nil)
return return
@ -320,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] = []
@ -389,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()
} }
} }

8
Clocker/Panel/PanelController.swift

@ -152,7 +152,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
@ -193,7 +194,8 @@ class PanelController: ParentPanelController {
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 else { let country = Locale.autoupdatingCurrent.regionCode
else {
return return
} }
@ -313,7 +315,7 @@ class PanelController: ParentPanelController {
} }
class func panel() -> PanelController? { 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 { guard let parent = window.windowController as? PanelController else {
return nil return nil

1
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -20,6 +20,7 @@ extension ParentPanelController {
if modernSlider != nil { if modernSlider != nil {
modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
modernSlider.enclosingScrollView?.backgroundColor = NSColor.clear modernSlider.enclosingScrollView?.backgroundColor = NSColor.clear
modernSlider.setAccessibility("ModernSlider")
modernSlider.postsBoundsChangedNotifications = true modernSlider.postsBoundsChangedNotifications = true
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector: #selector(collectionViewDidScroll(_:)), selector: #selector(collectionViewDidScroll(_:)),

21
Clocker/Panel/ParentPanelController.swift

@ -37,7 +37,7 @@ class ParentPanelController: NSWindowController {
var datasource: TimezoneDataSource? var datasource: TimezoneDataSource?
private lazy var feedbackWindow: AppFeedbackWindowController = AppFeedbackWindowController.shared() private lazy var feedbackWindow = AppFeedbackWindowController.shared()
private var notePopover: NotesPopover? private var notePopover: NotesPopover?
@ -395,7 +395,7 @@ class ParentPanelController: NSWindowController {
var current = main.frame.height 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) NSMouseInRect(mouseLocation, current.frame, false)
} }
@ -426,7 +426,8 @@ class ParentPanelController: NSWindowController {
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
} }
} }
@ -496,7 +497,7 @@ class ParentPanelController: NSWindowController {
updatePanelColor() updatePanelColor()
let defaults = DataStore.shared().timezones() let defaults = DataStore.shared().timezones()
let convertedTimezones = defaults.map { (data) -> TimezoneData in let convertedTimezones = defaults.map { data -> TimezoneData in
TimezoneData.customObject(from: data)! TimezoneData.customObject(from: data)!
} }
@ -533,7 +534,8 @@ class ParentPanelController: NSWindowController {
let currentCalendar = Calendar(identifier: .gregorian) let currentCalendar = Calendar(identifier: .gregorian)
guard let newDate = currentCalendar.date(byAdding: .minute, guard let newDate = currentCalendar.date(byAdding: .minute,
value: Int(futureSlider.doubleValue), value: Int(futureSlider.doubleValue),
to: Date()) else { to: Date())
else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return return
} }
@ -600,7 +602,8 @@ class ParentPanelController: NSWindowController {
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
} }
@ -620,7 +623,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
@ -719,7 +723,8 @@ class ParentPanelController: NSWindowController {
@IBAction func calendarButtonAction(_: NSButton) { @IBAction func calendarButtonAction(_: NSButton) {
if calendarButton.title == NSLocalizedString("Click here to start.", if calendarButton.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()

Loading…
Cancel
Save