Skip to content

Commit

Permalink
NavigationController: Fixes resizing animation
Browse files Browse the repository at this point in the history
  • Loading branch information
jleandroperez committed Jul 24, 2024
1 parent 1aaa3ac commit 4422b7b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Simplenote/SPNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ class SPNavigationController: NSViewController {
let currentView = topViewController?.view

attach(child: viewController)
if let currentView {
currentView.removeConstraints(currentView.constraints)

/// Disable Bottom Constraint
/// This allows for the enclosing NSWindow to resize, just enough to fit the `nextViewController.view`
///
if let currentView, let bottomConstraint = view.firstContraint(firstView: currentView, firstAttribute: .bottom) {
bottomConstraint.isActive = false
}

guard let (leadingAnchor, trailingAnchor) = attachView(subview: viewController.view, below: currentView) else {
Expand Down Expand Up @@ -139,6 +143,13 @@ class SPNavigationController: NSViewController {
guard viewStack.count > 1, let currentViewController = viewStack.popLast(), let nextViewController = viewStack.last else {
return
}

/// Disable Bottom Constraint
/// This allows for the enclosing NSWindow to resize, just enough to fit the `nextViewController.view`
///
if let currentBottomConstraint = view.firstContraint(firstView: currentViewController.view, firstAttribute: .bottom) {
currentBottomConstraint.isActive = false
}

attachView(subview: nextViewController.view, below: currentViewController.view)

Expand Down

0 comments on commit 4422b7b

Please sign in to comment.