Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for disabling animations when presenting/dismissing modals on iOS #337

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 20 additions & 1 deletion ios/RNSScreenStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
for (NSUInteger i = changeRootIndex; i < controllers.count; i++) {
UIViewController *next = controllers[i];
BOOL animate = (i == controllers.count - 1);

if (animate && [next.view isKindOfClass:[RNSScreenView class]]) {
RNSScreenView *screen = (RNSScreenView*)next.view;
if (screen.stackAnimation == RNSScreenStackAnimationNone) {
animate = NO;
}
}

[previous presentViewController:next
animated:animate
completion:animate ? dispatchFinishTransitioning : nil];
Expand All @@ -221,8 +229,19 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
};

if (changeRootController.presentedViewController) {
BOOL animate = (changeRootIndex == controllers.count);

UIViewController *lastTop = _controller.viewControllers.lastObject;

if (animate && lastTop && [lastTop.view isKindOfClass:[RNSScreenView class]]) {
RNSScreenView *screen = (RNSScreenView*)lastTop.view;
if (screen.stackAnimation == RNSScreenStackAnimationNone) {
animate = NO;
}
}

[changeRootController
dismissViewControllerAnimated:(changeRootIndex == controllers.count)
dismissViewControllerAnimated:animate
completion:finish];
} else {
finish();
Expand Down