Skip to content

Commit

Permalink
Removed isAnimated property and animation options
Browse files Browse the repository at this point in the history
  • Loading branch information
SamusAranX committed Sep 23, 2019
1 parent ba9c27f commit 90e400f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 50 deletions.
50 changes: 10 additions & 40 deletions Sources/Preferences/PreferencesTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ final class PreferencesTabViewController: NSViewController, PreferencesStyleCont
return view.window
}

var isAnimated: Bool = true

override func loadView() {
self.view = NSView()
self.view.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -124,17 +122,17 @@ final class PreferencesTabViewController: NSViewController, PreferencesStyleCont

let fromViewController = children[activeTab]
let toViewController = children[index]
let options: NSViewController.TransitionOptions = animated && isAnimated
? [.crossfade]
: []

view.removeConstraints(activeChildViewConstraints)

fromViewController.view.layer?.opacity = 0
toViewController.view.layer?.opacity = 0
transition(
from: fromViewController,
to: toViewController,
options: options
options: []
) {
toViewController.view.layer?.opacity = 1
self.activeChildViewConstraints = toViewController.view.constrainToSuperviewBounds()
}
}
Expand All @@ -145,40 +143,12 @@ final class PreferencesTabViewController: NSViewController, PreferencesStyleCont
options: NSViewController.TransitionOptions = [],
completionHandler completion: (() -> Void)? = nil
) {
let isAnimated = options
.intersection([
.crossfade,
.slideUp,
.slideDown,
.slideForward,
.slideBackward,
.slideLeft,
.slideRight
])
.isEmpty == false

if isAnimated {
NSAnimationContext.runAnimationGroup({ context in
context.allowsImplicitAnimation = true
context.duration = 0.25
context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
setWindowFrame(for: toViewController, animated: true)

super.transition(
from: fromViewController,
to: toViewController,
options: options,
completionHandler: completion
)
}, completionHandler: nil)
} else {
super.transition(
from: fromViewController,
to: toViewController,
options: options,
completionHandler: completion
)
}
super.transition(
from: fromViewController,
to: toViewController,
options: [],
completionHandler: completion
)
}

private func setWindowFrame(for viewController: NSViewController, animated: Bool = false) {
Expand Down
10 changes: 0 additions & 10 deletions Sources/Preferences/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ import Cocoa
public final class PreferencesWindowController: NSWindowController {
private let tabViewController = PreferencesTabViewController()

public var isAnimated: Bool {
get {
return tabViewController.isAnimated
}
set {
tabViewController.isAnimated = newValue
}
}

public var hidesToolbarForSingleItem: Bool {
didSet {
updateToolbarVisibility()
Expand Down Expand Up @@ -52,7 +43,6 @@ public final class PreferencesWindowController: NSWindowController {
return (preferencePanes.count <= 1) ? .visible : .hidden
}
}()
tabViewController.isAnimated = animated
tabViewController.configure(preferencePanes: preferencePanes, style: style)
updateToolbarVisibility()
}
Expand Down

0 comments on commit 90e400f

Please sign in to comment.