diff --git a/Simplenote/NSView+Simplenote.swift b/Simplenote/NSView+Simplenote.swift index b7cebdcb6..7d27fe74c 100644 --- a/Simplenote/NSView+Simplenote.swift +++ b/Simplenote/NSView+Simplenote.swift @@ -19,4 +19,10 @@ extension NSView { let effectiveResponder = fieldEditor?.delegate as? NSControl return effectiveResponder == self } + + /// Returns first layout constraint found for attribute type + /// + func firstContraint(firstView: NSView, firstAttribute: NSLayoutConstraint.Attribute) -> NSLayoutConstraint? { + constraints.first(where: { $0.firstItem as? NSView == firstView && $0.firstAttribute == firstAttribute }) + } } diff --git a/Simplenote/SPNavigationController.swift b/Simplenote/SPNavigationController.swift index fdb8667bc..221ee3001 100644 --- a/Simplenote/SPNavigationController.swift +++ b/Simplenote/SPNavigationController.swift @@ -160,8 +160,8 @@ class SPNavigationController: NSViewController { } private func animateTransition(slidingView: NSView, fadingView: NSView?, direction: AnimationDirection, onCompletion: @escaping () -> Void) { - guard let leadingConstraint = view.constraints.first(where: { $0.firstItem as? NSView == slidingView && $0.firstAttribute == .leading }), - let trailingConstraint = view.constraints.first(where: { $0.firstItem as? NSView == slidingView && $0.firstAttribute == .trailing }) else { + guard let leadingConstraint = view.firstContraint(firstView: slidingView, firstAttribute: .leading), + let trailingConstraint = view.firstContraint(firstView: slidingView, firstAttribute: .trailing) else { return }