Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Add support for transitions with custom presented views. #55

Merged
merged 2 commits into from
Nov 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions src/private/MDMViewControllerTransitionCoordinator.m
Original file line number Diff line number Diff line change
Expand Up @@ -313,35 +313,43 @@ - (void)initiateTransition {
_root.transitionContext = _transitionContext;

UIViewController *from = [_transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
if (from) {
UIView *fromView = [_transitionContext viewForKey:UITransitionContextFromViewKey];
if (fromView == nil) {
fromView = from.view;
}
if (fromView != nil && fromView == from.view) {
CGRect finalFrame = [_transitionContext finalFrameForViewController:from];
if (!CGRectIsEmpty(finalFrame)) {
from.view.frame = finalFrame;
fromView.frame = finalFrame;
}
}

UIViewController *to = [_transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
if (to) {
UIView *toView = [_transitionContext viewForKey:UITransitionContextToViewKey];
if (toView == nil) {
toView = to.view;
}
if (toView != nil && toView == to.view) {
CGRect finalFrame = [_transitionContext finalFrameForViewController:to];
if (!CGRectIsEmpty(finalFrame)) {
to.view.frame = finalFrame;
toView.frame = finalFrame;
}

switch (_direction) {
case MDMTransitionDirectionForward:
[_transitionContext.containerView addSubview:to.view];
break;
if (toView.superview == nil) {
switch (_direction) {
case MDMTransitionDirectionForward:
[_transitionContext.containerView addSubview:toView];
break;

case MDMTransitionDirectionBackward:
if (!to.view.superview) {
[_transitionContext.containerView insertSubview:to.view atIndex:0];
}
break;
case MDMTransitionDirectionBackward:
[_transitionContext.containerView insertSubview:toView atIndex:0];
break;
}
}

[to.view layoutIfNeeded];
}

[toView layoutIfNeeded];

[_root attemptFallback];
[self anticipateOnlyExplicitAnimations];

Expand Down