Commit 25b99d44 by Daniel Dahan

removed the ability for plugins, transitionPairs, animators, and preprocessors to ever be nil

parent 54fc5fe5
...@@ -107,16 +107,16 @@ public class MotionController: NSObject { ...@@ -107,16 +107,16 @@ public class MotionController: NSObject {
internal var isFinished = true internal var isFinished = true
/// An Array of MotionPreprocessors used during a transition. /// An Array of MotionPreprocessors used during a transition.
internal var preprocessors: [MotionPreprocessor]! internal fileprivate(set) lazy var preprocessors = [MotionPreprocessor]()
/// An Array of MotionAnimators used during a transition. /// An Array of MotionAnimators used during a transition.
internal var animators: [MotionAnimator]! internal fileprivate(set) lazy var animators = [MotionAnimator]()
/// An Array of MotionPlugins used during a transition. /// An Array of MotionPlugins used during a transition.
internal var plugins: [MotionPlugin]! internal fileprivate(set) lazy var plugins = [MotionPlugin]()
/// The matching fromViews to toViews based on the motionIdentifier value. /// The matching fromViews to toViews based on the motionIdentifier value.
internal var transitionPairs: [(fromViews: [UIView], toViews: [UIView])]! internal fileprivate(set) lazy var transitionPairs = [(fromViews: [UIView], toViews: [UIView])]()
/// Plugins that are enabled during the transition. /// Plugins that are enabled during the transition.
internal static var enabledPlugins = [MotionPlugin.Type]() internal static var enabledPlugins = [MotionPlugin.Type]()
...@@ -328,8 +328,6 @@ internal extension MotionController { ...@@ -328,8 +328,6 @@ internal extension MotionController {
return return
} }
transitionPairs = [([UIView], [UIView])]()
for a in animators { for a in animators {
let fv = context.fromViews.filter { (view: UIView) -> Bool in let fv = context.fromViews.filter { (view: UIView) -> Bool in
return a.canAnimate(view: view, isAppearing: false) return a.canAnimate(view: view, isAppearing: false)
...@@ -351,8 +349,8 @@ internal extension MotionController { ...@@ -351,8 +349,8 @@ internal extension MotionController {
return return
} }
for v in preprocessors { for x in preprocessors {
v.process(fromViews: context.fromViews, toViews: context.toViews) x.process(fromViews: context.fromViews, toViews: context.toViews)
} }
} }
...@@ -439,18 +437,18 @@ internal extension MotionController { ...@@ -439,18 +437,18 @@ internal extension MotionController {
let completion = completionCallback let completion = completionCallback
transitionPairs = nil
transitionObservers = nil transitionObservers = nil
transitionContainer = nil transitionContainer = nil
completionCallback = nil completionCallback = nil
container = nil container = nil
preprocessors = nil
animators = nil
plugins = nil
context = nil context = nil
beginTime = nil beginTime = nil
elapsedTime = 0 elapsedTime = 0
totalDuration = 0 totalDuration = 0
preprocessors.removeAll()
animators.removeAll()
plugins.removeAll()
transitionPairs.removeAll()
completion?(isFinished) completion?(isFinished)
} }
...@@ -481,24 +479,23 @@ fileprivate extension MotionController { ...@@ -481,24 +479,23 @@ fileprivate extension MotionController {
/// Prepares the preprocessors. /// Prepares the preprocessors.
func preparePreprocessors() { func preparePreprocessors() {
preprocessors = [ for x in [
IgnoreSubviewTransitionsPreprocessor(), IgnoreSubviewTransitionsPreprocessor(),
MatchPreprocessor(), MatchPreprocessor(),
SourcePreprocessor(), SourcePreprocessor(),
CascadePreprocessor(), CascadePreprocessor(),
DurationPreprocessor() DurationPreprocessor()] as [MotionPreprocessor] {
] preprocessors.append(x)
}
for v in preprocessors { for x in preprocessors {
v.context = context x.context = context
} }
} }
/// Prepares the animators. /// Prepares the animators.
func prepareAnimators() { func prepareAnimators() {
animators = [ animators.append(MotionDefaultAnimator<MotionCoreAnimationViewContext>())
MotionDefaultAnimator<MotionCoreAnimationViewContext>()
]
if #available(iOS 10, tvOS 10, *) { if #available(iOS 10, tvOS 10, *) {
animators.append(MotionDefaultAnimator<MotionViewPropertyViewContext>()) animators.append(MotionDefaultAnimator<MotionViewPropertyViewContext>())
...@@ -511,9 +508,11 @@ fileprivate extension MotionController { ...@@ -511,9 +508,11 @@ fileprivate extension MotionController {
/// Prepares the plugins. /// Prepares the plugins.
func preparePlugins() { func preparePlugins() {
plugins = Motion.enabledPlugins.map({ for x in Motion.enabledPlugins.map({
return $0.init() return $0.init()
}) }) {
plugins.append(x)
}
for plugin in plugins { for plugin in plugins {
preprocessors.append(plugin) preprocessors.append(plugin)
......
...@@ -232,7 +232,7 @@ class TransitionPreprocessor: MotionPreprocessor { ...@@ -232,7 +232,7 @@ class TransitionPreprocessor: MotionPreprocessor {
} }
if case .auto = defaultAnimation { if case .auto = defaultAnimation {
if animators!.contains(where: { $0.canAnimate(view: tv, isAppearing: true) || $0.canAnimate(view: fv, isAppearing: false) }) { if animators.contains(where: { $0.canAnimate(view: tv, isAppearing: true) || $0.canAnimate(view: fv, isAppearing: false) }) {
defaultAnimation = .none defaultAnimation = .none
} else if isNavigationController { } else if isNavigationController {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment