Commit d54c304b by Daniel Dahan

updated SourcePreprocessor with latest statement settings

parent 104aead0
...@@ -88,24 +88,27 @@ class CascadePreprocessor: MotionCorePreprocessor { ...@@ -88,24 +88,27 @@ class CascadePreprocessor: MotionCorePreprocessor {
- Parameter views: An Array of UIViews. - Parameter views: An Array of UIViews.
*/ */
func process(views: [UIView]) { func process(views: [UIView]) {
for view in views { for v in views {
guard let (deltaTime, direction, delayMatchedViews) = context[view]?.cascade else { continue } guard let (deltaTime, direction, delayMatchedViews) = context[v]?.cascade else {
continue
}
var parentView = v
var parentView = view if v is UITableView, let wrapperView = v.subviews.get(0) {
if view is UITableView, let wrapperView = view.subviews.get(0) {
parentView = wrapperView parentView = wrapperView
} }
let sortedSubviews = parentView.subviews.sorted(by: direction.comparator) let sortedSubviews = parentView.subviews.sorted(by: direction.comparator)
let initialDelay = context[view]!.delay let initialDelay = context[v]!.delay
let finalDelay = TimeInterval(sortedSubviews.count) * deltaTime + initialDelay let finalDelay = TimeInterval(sortedSubviews.count) * deltaTime + initialDelay
for (i, subview) in sortedSubviews.enumerated() { for (i, subview) in sortedSubviews.enumerated() {
let delay = TimeInterval(i) * deltaTime + initialDelay let delay = TimeInterval(i) * deltaTime + initialDelay
func applyDelay(view: UIView) { func applyDelay(view: UIView) {
if context.pairedView(for: view) == nil { if nil == context.pairedView(for: view) {
context[view]?.delay = delay context[view]?.delay = delay
} else if delayMatchedViews, let paired = context.pairedView(for: view) { } else if delayMatchedViews, let paired = context.pairedView(for: view) {
......
...@@ -35,8 +35,8 @@ class IgnoreSubviewTransitionsPreprocessor: MotionCorePreprocessor { ...@@ -35,8 +35,8 @@ class IgnoreSubviewTransitionsPreprocessor: MotionCorePreprocessor {
- Parameter toViews: An Array of UIViews. - Parameter toViews: An Array of UIViews.
*/ */
override func process(fromViews: [UIView], toViews: [UIView]) { override func process(fromViews: [UIView], toViews: [UIView]) {
process(views:fromViews) process(views: fromViews)
process(views:toViews) process(views: toViews)
} }
/** /**
...@@ -49,7 +49,11 @@ class IgnoreSubviewTransitionsPreprocessor: MotionCorePreprocessor { ...@@ -49,7 +49,11 @@ class IgnoreSubviewTransitionsPreprocessor: MotionCorePreprocessor {
continue continue
} }
let parentView = v is UITableView ? v.subviews.get(0) ?? v : v var parentView = v
if v is UITableView, let wrapperView = v.subviews.get(0) {
parentView = wrapperView
}
guard recursive else { guard recursive else {
for subview in parentView.subviews { for subview in parentView.subviews {
......
...@@ -36,7 +36,7 @@ class SourcePreprocessor: MotionCorePreprocessor { ...@@ -36,7 +36,7 @@ class SourcePreprocessor: MotionCorePreprocessor {
*/ */
override func process(fromViews: [UIView], toViews: [UIView]) { override func process(fromViews: [UIView], toViews: [UIView]) {
for fv in fromViews { for fv in fromViews {
guard let i = context[fv]?.motionIdentifier, let tv = context.destinationView(for: i) else { guard let motionIdentifier = context[fv]?.motionIdentifier, let tv = context.destinationView(for: motionIdentifier) else {
continue continue
} }
...@@ -61,6 +61,8 @@ fileprivate extension SourcePreprocessor { ...@@ -61,6 +61,8 @@ fileprivate extension SourcePreprocessor {
*/ */
func prepare(view: UIView, for targetView: UIView) { func prepare(view: UIView, for targetView: UIView) {
let targetPos = context.container.convert(targetView.layer.position, from: targetView.superview!) let targetPos = context.container.convert(targetView.layer.position, from: targetView.superview!)
let targetTransform = context.container.layer.flatTransformTo(layer: targetView.layer)
var state = context[view]! var state = context[view]!
/** /**
...@@ -69,11 +71,11 @@ fileprivate extension SourcePreprocessor { ...@@ -69,11 +71,11 @@ fileprivate extension SourcePreprocessor {
*/ */
state.coordinateSpace = .global state.coordinateSpace = .global
// Remove incompatible options.
state.position = targetPos state.position = targetPos
state.transform = nil state.transform = targetTransform
// Remove incompatible options.
state.size = nil state.size = nil
state.cornerRadius = nil
if view.bounds.size != targetView.bounds.size { if view.bounds.size != targetView.bounds.size {
state.size = targetView.bounds.size state.size = targetView.bounds.size
...@@ -83,10 +85,6 @@ fileprivate extension SourcePreprocessor { ...@@ -83,10 +85,6 @@ fileprivate extension SourcePreprocessor {
state.cornerRadius = targetView.layer.cornerRadius state.cornerRadius = targetView.layer.cornerRadius
} }
if view.layer.transform != targetView.layer.transform {
state.transform = targetView.layer.transform
}
if view.layer.shadowColor != targetView.layer.shadowColor { if view.layer.shadowColor != targetView.layer.shadowColor {
state.shadowColor = targetView.layer.shadowColor state.shadowColor = targetView.layer.shadowColor
} }
......
...@@ -183,11 +183,11 @@ class TransitionPreprocessor: MotionCorePreprocessor { ...@@ -183,11 +183,11 @@ class TransitionPreprocessor: MotionCorePreprocessor {
return return
} }
guard let fv = m.fromView else { guard let tv = m.toView else {
return return
} }
guard let tv = m.toView else { guard let fv = m.fromView else {
return return
} }
...@@ -224,10 +224,10 @@ class TransitionPreprocessor: MotionCorePreprocessor { ...@@ -224,10 +224,10 @@ class TransitionPreprocessor: MotionCorePreprocessor {
defaultAnimation = .none defaultAnimation = .none
} else if isNavigationController { } else if isNavigationController {
defaultAnimation = isPresenting ? .push(direction:.left) : .pull(direction:.right) defaultAnimation = isPresenting ? .push(direction: .left) : .pull(direction: .right)
} else if isTabBarController { } else if isTabBarController {
defaultAnimation = isPresenting ? .slide(direction:.left) : .slide(direction:.right) defaultAnimation = isPresenting ? .slide(direction: .left) : .slide(direction: .right)
} else { } else {
defaultAnimation = .fade defaultAnimation = .fade
......
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