Commit 392f0689 by Daniel Dahan

development: fixed issue when detecting motion transitions

parent df2f0742
...@@ -1408,7 +1408,7 @@ ...@@ -1408,7 +1408,7 @@
INFOPLIST_FILE = Sources/Info.plist; INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Material; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Material;
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
...@@ -1433,7 +1433,7 @@ ...@@ -1433,7 +1433,7 @@
INFOPLIST_FILE = Sources/Info.plist; INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Material; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Material;
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
...@@ -1457,7 +1457,7 @@ ...@@ -1457,7 +1457,7 @@
); );
INFOPLIST_FILE = Tests/Info.plist; INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-iOS-Tests"; PRODUCT_BUNDLE_IDENTIFIER = "com.cosmicmind.Material-iOS-Tests";
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
...@@ -1475,7 +1475,7 @@ ...@@ -1475,7 +1475,7 @@
); );
INFOPLIST_FILE = Tests/Info.plist; INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-iOS-Tests"; PRODUCT_BUNDLE_IDENTIFIER = "com.cosmicmind.Material-iOS-Tests";
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
...@@ -1498,7 +1498,7 @@ ...@@ -1498,7 +1498,7 @@
INFOPLIST_FILE = Sources/Info.plist; INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Material; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Material;
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SDKROOT = macosx; SDKROOT = macosx;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
...@@ -1522,7 +1522,7 @@ ...@@ -1522,7 +1522,7 @@
INFOPLIST_FILE = Sources/Info.plist; INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Material; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Material;
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SDKROOT = macosx; SDKROOT = macosx;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
...@@ -1542,7 +1542,7 @@ ...@@ -1542,7 +1542,7 @@
INFOPLIST_FILE = Tests/Info.plist; INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11; MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-OSX-Tests"; PRODUCT_BUNDLE_IDENTIFIER = "com.cosmicmind.Material-OSX-Tests";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
...@@ -1559,7 +1559,7 @@ ...@@ -1559,7 +1559,7 @@
INFOPLIST_FILE = Tests/Info.plist; INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11; MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-OSX-Tests"; PRODUCT_BUNDLE_IDENTIFIER = "com.cosmicmind.Material-OSX-Tests";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
......
...@@ -117,7 +117,7 @@ public struct Motion { ...@@ -117,7 +117,7 @@ public struct Motion {
cancelable?(false) cancelable?(false)
} }
return cancelable; return cancelable
} }
/** /**
......
...@@ -235,7 +235,7 @@ open class MotionTransition: NSObject { ...@@ -235,7 +235,7 @@ open class MotionTransition: NSObject {
open var transitionContext: UIViewControllerContextTransitioning! open var transitionContext: UIViewControllerContextTransitioning!
open var delay: TimeInterval = 0 open var delay: TimeInterval = 0
open var duration: TimeInterval = 0 open var duration: TimeInterval = 0.35
open var containerView: UIView! open var containerView: UIView!
open var transitionView = UIView() open var transitionView = UIView()
...@@ -331,11 +331,11 @@ extension MotionTransition { ...@@ -331,11 +331,11 @@ extension MotionTransition {
fileprivate func prepareTransitionPairs() { fileprivate func prepareTransitionPairs() {
for from in fromSubviews { for from in fromSubviews {
for to in toSubviews { guard 0 < from.motionTransitionIdentifier.utf16.count else {
guard 0 < from.motionTransitionAnimations.count else { continue
return
} }
for to in toSubviews {
guard to.motionTransitionIdentifier == from.motionTransitionIdentifier else { guard to.motionTransitionIdentifier == from.motionTransitionIdentifier else {
continue continue
} }
...@@ -372,17 +372,14 @@ extension MotionTransition { ...@@ -372,17 +372,14 @@ extension MotionTransition {
addBackgroundMotionAnimation() addBackgroundMotionAnimation()
cleanupAnimation() cleanupAnimation()
cleanupFromView() hideFromView()
cleanupTransitionSnapshot() removeTransitionSnapshot()
} }
} }
extension MotionTransition { extension MotionTransition {
fileprivate func addTransitionAnimations() { fileprivate func addTransitionAnimations() {
for (from, to) in transitionPairs { for (from, to) in transitionPairs {
let t = motionDelay(animations: to.motionTransitionAnimations)
let d = motionDuration(animations: to.motionTransitionAnimations)
var snapshotAnimations = [CABasicAnimation]() var snapshotAnimations = [CABasicAnimation]()
var snapshotChildAnimations = [CABasicAnimation]() var snapshotChildAnimations = [CABasicAnimation]()
...@@ -399,10 +396,12 @@ extension MotionTransition { ...@@ -399,10 +396,12 @@ extension MotionTransition {
snapshotChildAnimations.append(sizeAnimation) snapshotChildAnimations.append(sizeAnimation)
snapshotChildAnimations.append(Motion.position(x: to.bounds.width / 2, y: to.bounds.height / 2)) snapshotChildAnimations.append(Motion.position(x: to.bounds.width / 2, y: to.bounds.height / 2))
let d = motionDuration(animations: to.motionTransitionAnimations)
let snapshot = from.motionTransitionSnapshot(afterUpdates: true) let snapshot = from.motionTransitionSnapshot(afterUpdates: true)
transitionView.addSubview(snapshot) transitionView.addSubview(snapshot)
Motion.delay(t) { [weak self, weak to] in Motion.delay(motionDelay(animations: to.motionTransitionAnimations)) { [weak self, weak to] in
guard let s = self else { guard let s = self else {
return return
} }
...@@ -451,7 +450,7 @@ extension MotionTransition { ...@@ -451,7 +450,7 @@ extension MotionTransition {
} }
fileprivate func motionDuration(animations: [MotionAnimation]) -> TimeInterval { fileprivate func motionDuration(animations: [MotionAnimation]) -> TimeInterval {
var t: TimeInterval = 0 var t: TimeInterval = 0.35
for a in animations { for a in animations {
switch a { switch a {
case let .duration(time): case let .duration(time):
...@@ -492,13 +491,13 @@ extension MotionTransition { ...@@ -492,13 +491,13 @@ extension MotionTransition {
} }
} }
fileprivate func cleanupFromView() { fileprivate func hideFromView() {
Motion.delay(delay) { [weak self] in Motion.delay(delay) { [weak self] in
self?.fromView.isHidden = true self?.fromView.isHidden = true
} }
} }
fileprivate func cleanupTransitionSnapshot() { fileprivate func removeTransitionSnapshot() {
Motion.delay(delay) { [weak self] in Motion.delay(delay) { [weak self] in
self?.transitionSnapshot.removeFromSuperview() self?.transitionSnapshot.removeFromSuperview()
} }
......
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