Browse Source

Fix status item handler smashing against the view.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
689835c393
  1. 5
      Clocker/Panel/PanelController.swift
  2. 19
      Clocker/Preferences/Calendar/CalendarViewController.swift
  3. 1
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  4. 5
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

5
Clocker/Panel/PanelController.swift

@ -75,6 +75,8 @@ class PanelController: ParentPanelController {
updateDefaultPreferences()
setupUpcomingEventViewCollectionViewIfNeccesary()
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
futureSliderView.isHidden = true
modernContainerView.isHidden = true
@ -303,6 +305,9 @@ class PanelController: ParentPanelController {
window?.orderOut(nil)
datasource = nil
upcomingEventsDataSource = nil
parentTimer?.pause()
parentTimer = nil
}
func setActivePanel(newValue: Bool) {

19
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 {

1
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

5
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.

Loading…
Cancel
Save