Преглед на файлове

[iOS] Enable back swipe gesture when a navBar is hidden. Resolves this issue: https://github.com/wix/react-native-navigation/issues/930 (#1391)

added 03d380f8a9 back and also applied this fix https://github.com/wix/react-native-navigation/issues/428#issuecomment-278268928 on top of it
Grundmanis преди 7 години
родител
ревизия
ff803dd4b0
променени са 1 файла, в които са добавени 22 реда и са изтрити 0 реда
  1. 22
    0
      ios/RCCViewController.m

+ 22
- 0
ios/RCCViewController.m Целия файл

@@ -26,6 +26,7 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
26 26
 @property (nonatomic) BOOL _statusBarTextColorSchemeLight;
27 27
 @property (nonatomic, strong) NSDictionary *originalNavBarImages;
28 28
 @property (nonatomic, strong) UIImageView *navBarHairlineImageView;
29
+@property (nonatomic, weak) id <UIGestureRecognizerDelegate> originalInteractivePopGestureDelegate;
29 30
 @end
30 31
 
31 32
 @implementation RCCViewController
@@ -484,6 +485,21 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
484 485
     self.navBarHairlineImageView.hidden = NO;
485 486
   }
486 487
   
488
+ //Bug fix: in case there is a interactivePopGestureRecognizer, it prevents react-native from getting touch events on the left screen area that the gesture handles
489
+ //overriding the delegate of the gesture prevents this from happening while keeping the gesture intact (another option was to disable it completely by demand)
490
+ self.originalInteractivePopGestureDelegate = nil;
491
+ if(self.navigationController.viewControllers.count > 1){
492
+   if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil)
493
+   {
494
+     id <UIGestureRecognizerDelegate> interactivePopGestureRecognizer = self.navigationController.interactivePopGestureRecognizer.delegate;
495
+     if (interactivePopGestureRecognizer != nil)
496
+     {
497
+       self.originalInteractivePopGestureDelegate = interactivePopGestureRecognizer;
498
+       self.navigationController.interactivePopGestureRecognizer.delegate = self;
499
+     }
500
+   }
501
+ }
502
+  
487 503
   NSString *navBarCustomView = self.navigatorStyle[@"navBarCustomView"];
488 504
   if (navBarCustomView && ![self.navigationItem.titleView isKindOfClass:[RCCCustomTitleView class]]) {
489 505
     if ([self.view isKindOfClass:[RCTRootView class]]) {
@@ -524,6 +540,12 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
524 540
 
525 541
 -(void)setStyleOnDisappear {
526 542
   self.navBarHairlineImageView.hidden = NO;
543
+  
544
+  if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil && self.originalInteractivePopGestureDelegate != nil)
545
+  {
546
+    self.navigationController.interactivePopGestureRecognizer.delegate = self.originalInteractivePopGestureDelegate;
547
+    self.originalInteractivePopGestureDelegate = nil;
548
+  }
527 549
 }
528 550
 
529 551
 // only styles that can't be set on willAppear should be set here