Skip to content

Commit

Permalink
Fix layout collapsing when showing event details
Browse files Browse the repository at this point in the history
Seems to only affect specific calendar scaling sizes
  • Loading branch information
pakerwreah committed Apr 13, 2024
1 parent aa8a0fc commit c79c4c6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Calendr/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,17 @@ class MainViewController: NSViewController, NSPopoverDelegate {
NSEvent.removeMonitor(mouseMovedEventMonitor!)
}

override func viewDidLayout() {
super.viewDidLayout()

guard let window = view.window, window.isVisible else { return }

window.setContentSize(contentSize)
}

private var contentSize: CGSize {
var size = view.frame.size
size.height = mainStackView.frame.height + 2 * Constants.MainStackView.margin
size.height = ceil(mainStackView.frame.height + 2 * Constants.MainStackView.margin)
return size
}

Expand Down Expand Up @@ -534,16 +542,9 @@ class MainViewController: NSViewController, NSPopoverDelegate {
statusBarButton.setUpClickHandler(clickHandler)

mainStackView.rx.observe(\.frame)
.map(\.height)
.distinctUntilChanged()
.bind { [weak self] _ in
guard let self, let window = self.view.window, window.isVisible else { return }

NSAnimationContext.runAnimationGroup { context in
context.duration = 0.1
context.allowsImplicitAnimation = true
window.setContentSize(self.contentSize)
}
guard let self, let window = view.window, window.isVisible else { return }
view.frame.size = contentSize
}
.disposed(by: disposeBag)

Expand Down

0 comments on commit c79c4c6

Please sign in to comment.