diff --git a/Clocker/Panel/PanelController.swift b/Clocker/Panel/PanelController.swift index 6fd352b..6e3fac3 100644 --- a/Clocker/Panel/PanelController.swift +++ b/Clocker/Panel/PanelController.swift @@ -74,6 +74,8 @@ class PanelController: ParentPanelController { super.dismissRowActions() updateDefaultPreferences() + + setupUpcomingEventViewCollectionViewIfNeccesary() if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { futureSliderView.isHidden = true @@ -303,6 +305,9 @@ class PanelController: ParentPanelController { window?.orderOut(nil) datasource = nil + upcomingEventsDataSource = nil + parentTimer?.pause() + parentTimer = nil } func setActivePanel(newValue: Bool) { diff --git a/Clocker/Preferences/Calendar/CalendarViewController.swift b/Clocker/Preferences/Calendar/CalendarViewController.swift index db4a7b2..109c105 100644 --- a/Clocker/Preferences/Calendar/CalendarViewController.swift +++ b/Clocker/Preferences/Calendar/CalendarViewController.swift @@ -5,29 +5,26 @@ import CoreLoggerKit import EventKit class ClockerTextBackgroundView: NSView { - private var themeDidChangeNotification: NSObjectProtocol? override func awakeFromNib() { wantsLayer = true layer?.cornerRadius = 8.0 layer?.masksToBounds = false - layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor - - themeDidChangeNotification = NotificationCenter.default.addObserver(forName: .themeDidChangeNotification, object: nil, queue: OperationQueue.main) { _ in - self.layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor - } - } - deinit { - if let themeDidChangeNotif = themeDidChangeNotification { - NotificationCenter.default.removeObserver(themeDidChangeNotif) - } + NotificationCenter.default.addObserver(self, + selector: #selector(updateBackgroundColor), + name: .themeDidChangeNotification, + object: nil) } - + override func updateLayer() { super.updateLayer() layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor } + + @objc func updateBackgroundColor() { + layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor + } } class CalendarViewController: ParentViewController { diff --git a/Clocker/Preferences/Menu Bar/StatusContainerView.swift b/Clocker/Preferences/Menu Bar/StatusContainerView.swift index bf55dea..b4fee8b 100644 --- a/Clocker/Preferences/Menu Bar/StatusContainerView.swift +++ b/Clocker/Preferences/Menu Bar/StatusContainerView.swift @@ -239,6 +239,7 @@ class StatusContainerView: NSView { // NSView move animation NSAnimationContext.runAnimationGroup({ context in context.duration = 0.2 + context.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) let newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: newWidth, height: frame.size.height) // The view will animate to the new origin self.animator().frame = newFrame diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index 743a0ed..f3055bb 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -247,9 +247,8 @@ class StatusItemHandler: NSObject { if upcomingEventView == nil { constructCompactView(with: true) } - } else { - let upcomingEventView = retrieveUpcomingEventStatusView() - upcomingEventView?.removeFromSuperview() + } else if let upcomingEventView = retrieveUpcomingEventStatusView() { + upcomingEventView.removeFromSuperview() constructCompactView() // So that Status Container View reclaims the space } // This will internally call `statusItemViewSetNeedsDisplay` on all subviews ensuring all text in the menubar is up-to-date.