Skip to content

Commit

Permalink
passed in current view when attaching view
Browse files Browse the repository at this point in the history
  • Loading branch information
charliescheer committed Jul 22, 2024
1 parent 25a0336 commit 80335d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Simplenote/SPNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SPNavigationController: NSViewController {
currentView.removeConstraints(currentView.constraints)
}

guard let (leadingAnchor, trailingAnchor) = attachView(subview: viewController.view) else {
guard let (leadingAnchor, trailingAnchor) = attachView(subview: viewController.view, currentView: currentView) else {
return
}

Expand All @@ -107,9 +107,8 @@ class SPNavigationController: NSViewController {
}

@discardableResult
private func attachView(subview: NSView, behindCurrent: Bool = false) -> (leading: NSLayoutConstraint, trailing: NSLayoutConstraint)? {
if let currentView = topViewController?.view,
behindCurrent {
private func attachView(subview: NSView, currentView: NSView?, behindCurrent: Bool = false) -> (leading: NSLayoutConstraint, trailing: NSLayoutConstraint)? {
if behindCurrent {
view.addSubview(subview, positioned: .below, relativeTo: currentView)
} else {
view.addSubview(subview)
Expand Down Expand Up @@ -141,7 +140,7 @@ class SPNavigationController: NSViewController {
return
}

self.attachView(subview: nextViewController.view, behindCurrent: true)
attachView(subview: nextViewController.view, currentView: currentViewController.view, behindCurrent: true)

animateTransition(slidingView: currentViewController.view, fadingView: nextViewController.view, direction: .leadingToTrailing) {
self.dettach(child: currentViewController)
Expand Down

0 comments on commit 80335d1

Please sign in to comment.