Commit 20239fec by Daniel Dahan

finished rework for Motion

parent 601c787a
...@@ -53,14 +53,6 @@ extension MotionTransition { ...@@ -53,14 +53,6 @@ extension MotionTransition {
prepareContainer() prepareContainer()
prepareContext() prepareContext()
for v in preprocessors {
v.motion = self
}
for v in animators {
v.motion = self
}
prepareViewHierarchy() prepareViewHierarchy()
prepareAnimatingViews() prepareAnimatingViews()
prepareToView() prepareToView()
...@@ -100,8 +92,8 @@ fileprivate extension MotionTransition { ...@@ -100,8 +92,8 @@ fileprivate extension MotionTransition {
func prepareSnapshotView() { func prepareSnapshotView() {
fullScreenSnapshot = transitionContainer?.window?.snapshotView(afterScreenUpdates: false) ?? fromView?.snapshotView(afterScreenUpdates: false) fullScreenSnapshot = transitionContainer?.window?.snapshotView(afterScreenUpdates: false) ?? fromView?.snapshotView(afterScreenUpdates: false)
if let snapshot = fullScreenSnapshot { if let v = fullScreenSnapshot {
(transitionContainer?.window ?? transitionContainer)?.addSubview(snapshot) (transitionContainer?.window ?? transitionContainer)?.addSubview(v)
} }
if let v = fromViewController?.motionStoredSnapshot { if let v = fromViewController?.motionStoredSnapshot {
...@@ -143,7 +135,7 @@ fileprivate extension MotionTransition { ...@@ -143,7 +135,7 @@ fileprivate extension MotionTransition {
/// Prepares the transition container. /// Prepares the transition container.
func prepareTransitionContainer() { func prepareTransitionContainer() {
transitionContainer?.isUserInteractionEnabled = false transitionContainer?.isUserInteractionEnabled = isUserInteractionEnabled
} }
/// Prepares the view that holds all the animating views. /// Prepares the view that holds all the animating views.
...@@ -161,14 +153,22 @@ fileprivate extension MotionTransition { ...@@ -161,14 +153,22 @@ fileprivate extension MotionTransition {
func prepareContext() { func prepareContext() {
context = MotionContext(container: container) context = MotionContext(container: container)
guard let fv = fromView else { for v in preprocessors {
return v.motion = self
}
for v in animators {
v.motion = self
} }
guard let tv = toView else { guard let tv = toView else {
return return
} }
guard let fv = fromView else {
return
}
context.loadViewAlpha(rootView: tv) context.loadViewAlpha(rootView: tv)
container.addSubview(tv) container.addSubview(tv)
...@@ -185,12 +185,14 @@ fileprivate extension MotionTransition { ...@@ -185,12 +185,14 @@ fileprivate extension MotionTransition {
/// Prepares the view hierarchy. /// Prepares the view hierarchy.
func prepareViewHierarchy() { func prepareViewHierarchy() {
if (.auto == viewOrderStrategy && if (.auto == viewOrderStrategy && !isPresenting && !isTabBarController) ||
!isPresenting &&
!isTabBarController) ||
.sourceViewOnTop == viewOrderStrategy { .sourceViewOnTop == viewOrderStrategy {
context.insertToViewFirst = true context.insertToViewFirst = true
} }
for v in preprocessors {
v.process(fromViews: context.fromViews, toViews: context.toViews)
}
} }
/// Prepares the transition fromView & toView pairs. /// Prepares the transition fromView & toView pairs.
...@@ -204,8 +206,6 @@ fileprivate extension MotionTransition { ...@@ -204,8 +206,6 @@ fileprivate extension MotionTransition {
return false return false
} }
print("FROM PREPARED", animatingFromViews)
animatingToViews = context.toViews.filter { (view) -> Bool in animatingToViews = context.toViews.filter { (view) -> Bool in
for animator in animators { for animator in animators {
if animator.canAnimate(view: view, isAppearing: true) { if animator.canAnimate(view: view, isAppearing: true) {
...@@ -214,8 +214,6 @@ fileprivate extension MotionTransition { ...@@ -214,8 +214,6 @@ fileprivate extension MotionTransition {
} }
return false return false
} }
print("TO PREPARED", animatingFromViews)
} }
/// Prepares the to view. /// Prepares the to view.
......
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