Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ollieatkinson/5f2971ee123a88d21291c01656cde0b2 to your computer and use it in GitHub Desktop.
Save ollieatkinson/5f2971ee123a88d21291c01656cde0b2 to your computer and use it in GitHub Desktop.
func makeTestViewControllerTransitionCoordinator() -> UIViewControllerTransitionCoordinator {
class ViewControllerTransitionCoordinator: NSObject, UIViewControllerTransitionCoordinatorContext, UIViewControllerTransitionCoordinator {
public var isAnimated: Bool { return false }
public var presentationStyle: UIModalPresentationStyle { return .formSheet }
public var initiallyInteractive: Bool { return false }
@available(iOS 10.0, *)
public var isInterruptible: Bool { return false }
public var isInteractive: Bool { return false }
public var isCancelled: Bool { return false }
public var transitionDuration: TimeInterval { return 1 }
public var percentComplete: CGFloat { return 0 }
public var completionVelocity: CGFloat { return 1 }
public var completionCurve: UIViewAnimationCurve { return .easeIn }
@available(iOS 2.0, *)
public func viewController(forKey key: UITransitionContextViewControllerKey) -> UIViewController? {
return nil
}
@available(iOS 8.0, *)
public func view(forKey key: UITransitionContextViewKey) -> UIView? {
return nil
}
@available(iOS 2.0, *)
public var containerView: UIView { return UIView() }
@available(iOS 8.0, *)
public var targetTransform: CGAffineTransform { return .identity }
@available(iOS 10.0, *)
public func notifyWhenInteractionChanges(_ handler: @escaping (UIViewControllerTransitionCoordinatorContext) -> Void) {
}
@available(iOS, introduced: 7.0, deprecated: 10.0, message: "Use notifyWhenInteractionChangesUsingBlock")
public func notifyWhenInteractionEnds(_ handler: @escaping (UIViewControllerTransitionCoordinatorContext) -> Void) {
}
func animate(alongsideTransition animation: ((UIViewControllerTransitionCoordinatorContext) -> Void)?, completion: ((UIViewControllerTransitionCoordinatorContext) -> Void)?) -> Bool {
return true
}
func animateAlongsideTransition(
in view: UIView?,
animation: ((UIViewControllerTransitionCoordinatorContext) -> Void)?,
completion: ((UIViewControllerTransitionCoordinatorContext) -> Void)?
) -> Bool {
return true
}
}
return ViewControllerTransitionCoordinator()
}
@ollieatkinson
Copy link
Author

// Setup your test...

        viewController.viewWillTransition(to: .zero, with: makeTestViewControllerTransitionCoordinator())

// Validate the output...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment