Skip to content

Commit

Permalink
Add "old" implementation for reference & comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Dec 13, 2024
1 parent 567242b commit 4ecda0d
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,11 @@ - (void)dismissOnReload
// otherwise the screen will be just popped immediately due to no animation
((operation == UINavigationControllerOperationPop && shouldCancelDismiss) || _isFullWidthSwiping ||
[RNSScreenStackAnimator isCustomAnimation:screen.stackAnimation] || _customAnimation)) {
return [[RNSScreenStackAnimator alloc] initWithOperation:operation];
if (rns::kUsesNewAnimatorImpl) {
return [[RNSScreenStackAnimator alloc] initWithOperation:operation];
} else {
return [[RNSScreenStackAnimatorLegacy alloc] initWithOperation:operation];
}
}
return nil;
}
Expand Down
25 changes: 25 additions & 0 deletions ios/RNSScreenStackAnimator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#pragma once

#import "RNSScreen.h"

namespace rns {
constexpr bool kUsesNewAnimatorImpl = false;
}

@interface RNSScreenStackAnimator : NSObject <UIViewControllerAnimatedTransitioning>

/// This property is filled whenever there is an ongoing animation and cleared on animation end.
Expand All @@ -18,3 +24,22 @@
+ (BOOL)isCustomAnimation:(RNSScreenStackAnimation)animation;

@end

@interface RNSScreenStackAnimatorLegacy : NSObject <UIViewControllerAnimatedTransitioning>

/// This property is filled whenever there is an ongoing animation and cleared on animation end.
@property (nonatomic, strong, nullable, readonly) UIViewPropertyAnimator *inFlightAnimator;

- (nonnull instancetype)initWithOperation:(UINavigationControllerOperation)operation;

/// In case of interactive / interruptible transition (e.g. swipe back gesture) this method should return
/// timing parameters expected by animator to be used for animation completion (e.g. when user's
/// gesture had ended).
///
/// @return timing curve provider expected to be used for animation completion or nil,
/// when there is no interactive transition running.
- (nullable id<UITimingCurveProvider>)timingParamsForAnimationCompletion;

+ (BOOL)isCustomAnimation:(RNSScreenStackAnimation)animation;

@end
Loading

0 comments on commit 4ecda0d

Please sign in to comment.