react-native-navigation的迁移库

RNNOverlayManager.m 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #import "RNNOverlayManager.h"
  2. @implementation RNNOverlayManager {
  3. NSMutableDictionary* _overlayDict;
  4. }
  5. - (instancetype)init {
  6. self = [super init];
  7. _overlayDict = [[NSMutableDictionary alloc] init];
  8. return self;
  9. }
  10. #pragma mark - public
  11. - (void)showOverlay:(RNNRootViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
  12. [self cacheOverlay:viewController];
  13. [[[UIApplication sharedApplication] keyWindow] addSubview:viewController.view];
  14. completion();
  15. }
  16. - (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
  17. RNNRootViewController* viewController = [_overlayDict objectForKey:componentId];
  18. [self removeCachedOverlay:viewController];
  19. completion();
  20. }
  21. #pragma mark - private
  22. - (void)cacheOverlay:(RNNRootViewController*)viewController {
  23. [_overlayDict setObject:viewController forKey:viewController.componentId];
  24. }
  25. - (void)removeCachedOverlay:(RNNRootViewController*)viewController {
  26. [viewController.view removeFromSuperview];
  27. [_overlayDict removeObjectForKey:viewController.componentId];
  28. }
  29. @end