react-native-navigation的迁移库

StackControllerDelegate.m 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "StackControllerDelegate.h"
  2. #import "StackTransitionDelegate.h"
  3. #import "UIViewController+LayoutProtocol.h"
  4. @implementation StackControllerDelegate {
  5. RNNEventEmitter* _eventEmitter;
  6. UIViewController* _presentedViewController;
  7. }
  8. - (instancetype)initWithEventEmitter:(RNNEventEmitter *)eventEmitter {
  9. self = [super init];
  10. _eventEmitter = eventEmitter;
  11. return self;
  12. }
  13. - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  14. if (_presentedViewController && ![navigationController.viewControllers containsObject:_presentedViewController]) {
  15. [_presentedViewController screenPopped];
  16. }
  17. _presentedViewController = viewController;
  18. }
  19. - (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
  20. animationControllerForOperation:(UINavigationControllerOperation)operation
  21. fromViewController:(UIViewController*)fromVC
  22. toViewController:(UIViewController*)toVC {
  23. if (operation == UINavigationControllerOperationPush && toVC.resolveOptions.animations.push.hasCustomAnimation) {
  24. return [[StackTransitionDelegate alloc] initWithScreenTransition:toVC.resolveOptions.animations.push bridge:_eventEmitter.bridge];
  25. } else if (operation == UINavigationControllerOperationPop && fromVC.resolveOptions.animations.pop.hasCustomAnimation) {
  26. return [[StackTransitionDelegate alloc] initWithScreenTransition:fromVC.resolveOptions.animations.pop bridge:_eventEmitter.bridge];
  27. } else {
  28. return nil;
  29. }
  30. return nil;
  31. }
  32. @end