Commit c72a7322 by Daniel Dahan Committed by GitHub

Merge pull request #42 from OrkhanAlikhanov/issue-29

Fixed issue-29, unbalanced calls to begin/end appearance transitions
parents d3b27d75 7122dfd4
...@@ -65,6 +65,7 @@ extension MotionTransition { ...@@ -65,6 +65,7 @@ extension MotionTransition {
progress = 0 progress = 0
totalDuration = 0 totalDuration = 0
state = .possible state = .possible
isModalTransition = false
} }
state = .completing state = .completing
......
...@@ -41,6 +41,7 @@ extension MotionTransition: UIViewControllerTransitioningDelegate { ...@@ -41,6 +41,7 @@ extension MotionTransition: UIViewControllerTransitioningDelegate {
state = .notified state = .notified
isPresenting = true isPresenting = true
isModalTransition = true
fromViewController = fromViewController ?? presenting fromViewController = fromViewController ?? presenting
toViewController = toViewController ?? presented toViewController = toViewController ?? presented
...@@ -54,6 +55,7 @@ extension MotionTransition: UIViewControllerTransitioningDelegate { ...@@ -54,6 +55,7 @@ extension MotionTransition: UIViewControllerTransitioningDelegate {
state = .notified state = .notified
isPresenting = false isPresenting = false
isModalTransition = true
fromViewController = fromViewController ?? dismissed fromViewController = fromViewController ?? dismissed
return self return self
} }
......
...@@ -272,6 +272,13 @@ open class MotionTransition: NSObject { ...@@ -272,6 +272,13 @@ open class MotionTransition: NSObject {
/// Whether or not we are presenting the destination view controller. /// Whether or not we are presenting the destination view controller.
public internal(set) var isPresenting = true public internal(set) var isPresenting = true
/**
A boolean indicating if the transition is of modal type.
True if `viewController.present(_:animated:completion:)` or
`viewController.dismiss(animated:completion:)` is called, false otherwise.
*/
public internal(set) var isModalTransition = false
/// A boolean indicating whether the transition interactive or not. /// A boolean indicating whether the transition interactive or not.
public var isInteractive: Bool { public var isInteractive: Bool {
return !progressRunner.isRunning return !progressRunner.isRunning
...@@ -588,8 +595,10 @@ internal extension MotionTransition { ...@@ -588,8 +595,10 @@ internal extension MotionTransition {
return return
} }
if !isModalTransition {
fvc.beginAppearanceTransition(false, animated: true) fvc.beginAppearanceTransition(false, animated: true)
tvc.beginAppearanceTransition(true, animated: true) tvc.beginAppearanceTransition(true, animated: true)
}
processForMotionDelegate(viewController: fvc) { [weak self] in processForMotionDelegate(viewController: fvc) { [weak self] in
guard let `self` = self else { guard let `self` = self else {
...@@ -625,8 +634,10 @@ internal extension MotionTransition { ...@@ -625,8 +634,10 @@ internal extension MotionTransition {
return return
} }
if !isModalTransition {
tvc.endAppearanceTransition() tvc.endAppearanceTransition()
fvc.endAppearanceTransition() fvc.endAppearanceTransition()
}
processForMotionDelegate(viewController: fvc) { [weak self] in processForMotionDelegate(viewController: fvc) { [weak self] in
guard let `self` = self else { guard let `self` = self else {
......
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