Skip to content

Commit

Permalink
Restore behaviour of StackAnimationNone - PoC (there is still some he…
Browse files Browse the repository at this point in the history
…ader animation)
  • Loading branch information
kkafar committed Dec 13, 2024
1 parent 2152383 commit 567242b
Showing 1 changed file with 56 additions and 18 deletions.
74 changes: 56 additions & 18 deletions ios/RNSScreenStackAnimator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)t
}

if (screen != nil && screen.stackAnimation == RNSScreenStackAnimationNone) {
return 0;
return 0.0;
}

if (screen != nil && screen.transitionDuration != nil && [screen.transitionDuration floatValue] >= 0) {
Expand Down Expand Up @@ -489,6 +489,34 @@ - (void)animateWithNoAnimation:(id<UIViewControllerContextTransitioning>)transit
}
}

- (void)animateNoneWithTransitionContext:(id<UIViewControllerContextTransitioning>)transitionContext
toVC:(UIViewController *)toViewController
fromVC:(UIViewController *)fromViewController
{
if (_operation == UINavigationControllerOperationPush) {
[[transitionContext containerView] addSubview:toViewController.view];
[UIView animateWithDuration:[self transitionDuration:transitionContext]
animations:^{
toViewController.view.alpha = 1.0;
}
completion:^(BOOL finished) {
toViewController.view.alpha = 1.0;
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
} else if (_operation == UINavigationControllerOperationPop) {
[[transitionContext containerView] insertSubview:toViewController.view belowSubview:fromViewController.view];

[UIView animateWithDuration:[self transitionDuration:transitionContext]
animations:^{
fromViewController.view.alpha = 0.0;
}
completion:^(BOOL finished) {
fromViewController.view.alpha = 1.0;
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
}

#pragma mark - Public API

- (nullable id<UITimingCurveProvider>)timingParamsForAnimationCompletion
Expand All @@ -509,24 +537,34 @@ - (void)animateTransitionWithStackAnimation:(RNSScreenStackAnimation)animation
toVC:(UIViewController *)toVC
fromVC:(UIViewController *)fromVC
{
if (animation == RNSScreenStackAnimationSimplePush) {
[self animateSimplePushWithShadowEnabled:shadowEnabled transitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
} else if (animation == RNSScreenStackAnimationSlideFromLeft) {
[self animateSlideFromLeftWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
} else if (animation == RNSScreenStackAnimationFade || animation == RNSScreenStackAnimationNone) {
[self animateFadeWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
} else if (animation == RNSScreenStackAnimationSlideFromBottom) {
[self animateSlideFromBottomWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
} else if (animation == RNSScreenStackAnimationFadeFromBottom) {
[self animateFadeFromBottomWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
switch (animation) {
case RNSScreenStackAnimationSimplePush:
[self animateSimplePushWithShadowEnabled:shadowEnabled
transitionContext:transitionContext
toVC:toVC
fromVC:fromVC];
return;
case RNSScreenStackAnimationSlideFromLeft:
[self animateSlideFromLeftWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
case RNSScreenStackAnimationFade:
[self animateFadeWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
case RNSScreenStackAnimationSlideFromBottom:
[self animateSlideFromBottomWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
case RNSScreenStackAnimationFadeFromBottom:
[self animateFadeFromBottomWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
return;
case RNSScreenStackAnimationNone:
[self animateNoneWithTransitionContext:transitionContext toVC:toVC fromVC:fromVC];
default:
// simple_push is the default custom animation
[self animateSimplePushWithShadowEnabled:shadowEnabled
transitionContext:transitionContext
toVC:toVC
fromVC:fromVC];
}
// simple_push is the default custom animation
[self animateSimplePushWithShadowEnabled:shadowEnabled transitionContext:transitionContext toVC:toVC fromVC:fromVC];
}

+ (UISpringTimingParameters *)defaultSpringTimingParametersApprox
Expand Down

0 comments on commit 567242b

Please sign in to comment.