Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save csknns/c420818029718f9184887e3be7e6a932 to your computer and use it in GitHub Desktop.
Save csknns/c420818029718f9184887e3be7e6a932 to your computer and use it in GitHub Desktop.
example of UIViewControllerTransitionCoordinator Mocked
class UIViewControllerTransitionCoordinatorMocked: NSObject, UIViewControllerTransitionCoordinator {
var animateWasCalled = false
func animate(alongsideTransition animation: ((UIViewControllerTransitionCoordinatorContext) -> Void)?, completion: ((UIViewControllerTransitionCoordinatorContext) -> Void)? = nil) -> Bool {
animateWasCalled = true
if let completion = completion {
completion(self)
}
return true
}
override init () { }
func animateAlongsideTransition(in view: UIView?, animation: ((UIViewControllerTransitionCoordinatorContext) -> Void)?, completion: ((UIViewControllerTransitionCoordinatorContext) -> Void)? = nil) -> Bool {
if let completion = completion {
completion(self)
}
return true
}
func notifyWhenInteractionEnds(_ handler: @escaping (UIViewControllerTransitionCoordinatorContext) -> Void) {
handler(self)
}
func notifyWhenInteractionChanges(_ handler: @escaping (UIViewControllerTransitionCoordinatorContext) -> Void) {
handler(self)
}
var isAnimated: Bool = false
var presentationStyle: UIModalPresentationStyle = .automatic
var initiallyInteractive: Bool = false
var isInterruptible: Bool = false
var isInteractive: Bool = false
var isCancelled: Bool = false
var transitionDuration: TimeInterval = 0.0
var percentComplete: CGFloat = 0.0
var completionVelocity: CGFloat = 0.0
var completionCurve: UIView.AnimationCurve = .easeIn
func viewController(forKey key: UITransitionContextViewControllerKey) -> UIViewController? {
return nil
}
func view(forKey key: UITransitionContextViewKey) -> UIView? {
return nil
}
var containerView: UIView = UIView()
var targetTransform: CGAffineTransform = .identity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment