Commit 3e422773 by Daniel Dahan

second round reworking the MotionController

parent fcf3d822
...@@ -91,7 +91,7 @@ extension MotionDebugPlugin:MotionDebugViewDelegate { ...@@ -91,7 +91,7 @@ extension MotionDebugPlugin:MotionDebugViewDelegate {
public func onProcessSliderChanged(progress: Float) { public func onProcessSliderChanged(progress: Float) {
let seekValue = Motion.shared.isPresenting ? progress : 1.0 - progress let seekValue = Motion.shared.isPresenting ? progress : 1.0 - progress
Motion.shared.update(progress: Double(seekValue)) Motion.shared.update(elapsedTime: Double(seekValue))
} }
func onPerspectiveChanged(translation: CGPoint, rotation: CGFloat, scale: CGFloat) { func onPerspectiveChanged(translation: CGPoint, rotation: CGFloat, scale: CGFloat) {
......
...@@ -166,12 +166,12 @@ fileprivate extension Motion { ...@@ -166,12 +166,12 @@ fileprivate extension Motion {
prepareViewControllers() prepareViewControllers()
prepareSnapshotView() prepareSnapshotView()
prepareForTransition() prepareTransition()
prepareContext() prepareContext()
prepareToView() prepareToView()
prepareViewHierarchy() prepareViewHierarchy()
processContext() processContext()
prepareForAnimation() prepareTransitionPairs()
processForAnimation() processForAnimation()
} }
} }
...@@ -188,7 +188,7 @@ internal extension Motion { ...@@ -188,7 +188,7 @@ internal extension Motion {
fullScreenSnapshot?.removeFromSuperview() fullScreenSnapshot?.removeFromSuperview()
} }
override func complete(finished: Bool) { override func complete(isFinished finished: Bool) {
guard isTransitioning else { guard isTransitioning else {
return return
} }
...@@ -220,13 +220,13 @@ internal extension Motion { ...@@ -220,13 +220,13 @@ internal extension Motion {
} }
// move fromView & toView back from our container back to the one supplied by UIKit // move fromView & toView back from our container back to the one supplied by UIKit
if (toOverFullScreen && finished) || (fromOverFullScreen && !finished) { if (toOverFullScreen && isFinished) || (fromOverFullScreen && !finished) {
transitionContainer.addSubview(finished ? fromView : toView) transitionContainer.addSubview(isFinished ? fromView : toView)
} }
transitionContainer.addSubview(finished ? toView : fromView) transitionContainer.addSubview(isFinished ? toView : fromView)
if isPresenting != finished, !isContainerController { if isPresenting != isFinished, !isContainerController {
// only happens when present a .overFullScreen VC // only happens when present a .overFullScreen VC
// bug: http://openradar.appspot.com/radar?id=5320103646199808 // bug: http://openradar.appspot.com/radar?id=5320103646199808
UIApplication.shared.keyWindow!.addSubview(isPresenting ? fromView : toView) UIApplication.shared.keyWindow!.addSubview(isPresenting ? fromView : toView)
...@@ -249,7 +249,7 @@ internal extension Motion { ...@@ -249,7 +249,7 @@ internal extension Motion {
insertToViewFirst = false insertToViewFirst = false
defaultAnimation = .auto defaultAnimation = .auto
super.complete(finished: finished) super.complete(isFinished: isFinished)
if finished { if finished {
if let fvc = fvc, let tvc = tvc { if let fvc = fvc, let tvc = tvc {
...@@ -342,13 +342,13 @@ fileprivate extension Motion { ...@@ -342,13 +342,13 @@ fileprivate extension Motion {
} }
internal extension Motion { internal extension Motion {
override func prepareForTransition() { override func prepareTransition() {
super.prepareForTransition() super.prepareTransition()
insert(preprocessor: DefaultAnimationPreprocessor(motion: self), before: DurationPreprocessor.self) insert(preprocessor: DefaultAnimationPreprocessor(motion: self), before: DurationPreprocessor.self)
} }
override func prepareForAnimation() { override func prepareTransitionPairs() {
super.prepareForAnimation() super.prepareTransitionPairs()
context.hide(view: toView) context.hide(view: toView)
} }
} }
......
...@@ -37,11 +37,11 @@ public class MotionIndependentController: MotionController { ...@@ -37,11 +37,11 @@ public class MotionIndependentController: MotionController {
transitionContainer = rootView transitionContainer = rootView
completionCallback = completion completionCallback = completion
prepareForTransition() prepareTransition()
context.defaultCoordinateSpace = .sameParent context.defaultCoordinateSpace = .sameParent
context.set(fromViews: fromViews, toViews: toViews) context.set(fromViews: fromViews, toViews: toViews)
processContext() processContext()
prepareForAnimation() prepareTransitionPairs()
animate() animate()
} }
} }
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