Procházet zdrojové kódy

disabled back gesture support (#2273)

* disabled back gesture support

* changed disabledBackGesture prop name to popGesture
yogevbd před 6 roky
rodič
revize
59d3bb3e9c

+ 2
- 2
README.md Zobrazit soubor

@@ -124,7 +124,7 @@ v2 is written in Test Driven Development. We have a test for every feature inclu
124 124
 |--------------------|-----|----|-----|
125 125
 | screenBackgroundColor        |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       |  Wix|
126 126
 | orientation       |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
127
-| disabledBackGesture        |  WIP @gran33     |    / iOS specific     |
127
+| disabledBackGesture        |       |    / iOS specific     |
128 128
 | screenBackgroundImageName        |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
129 129
 | rootBackgroundImageName              |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
130 130
 | sideMenuVisible          |        [Contribute](/docs/docs/CONTRIBUTING.md)   | [Contribute](/docs/docs/CONTRIBUTING.md) |
@@ -192,7 +192,7 @@ Note:  v1 properties with names beginning with 'navBar' are replaced in v2 with
192 192
 | orientation     |  ✅   |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
193 193
 | statusBarHideWithTopBar        |  ✅   |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
194 194
 | statusBarHidden       |  ✅   |    ✅       |     [Contribute](/docs/docs/CONTRIBUTING.md)      | WIX |
195
-| disabledBackGesture       |   ✅  |  WIP @gran33     |    / iOS specific     |
195
+| disabledBackGesture       |   ✅  |    |    / iOS specific     |
196 196
 | screenBackgroundImageName         |   ✅  |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
197 197
 | rootBackgroundImageName            |  ✅   |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
198 198
 | setButtons          |   ✅     |    ✅    | [Contribute](/docs/docs/CONTRIBUTING.md) | @Johan-dutoit|

+ 1
- 0
lib/ios/RNNNavigationOptions.h Zobrazit soubor

@@ -15,6 +15,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
15 15
 @property (nonatomic, strong) NSArray* rightButtons;
16 16
 @property (nonatomic, strong) NSNumber* statusBarBlur;
17 17
 @property (nonatomic, strong) NSNumber* statusBarHideWithTopBar;
18
+@property (nonatomic, strong) NSNumber* popGesture;
18 19
 @property (nonatomic, strong) RNNTopBarOptions* topBar;
19 20
 @property (nonatomic, strong) RNNTabBarOptions* tabBar;
20 21
 

+ 4
- 0
lib/ios/RNNNavigationOptions.m Zobrazit soubor

@@ -128,6 +128,10 @@ const NSInteger BLUR_TOPBAR_TAG = 78264802;
128 128
 		}
129 129
 	}
130 130
 	
131
+	if (self.popGesture) {
132
+		viewController.navigationController.interactivePopGestureRecognizer.enabled = [self.popGesture boolValue];
133
+	}
134
+	
131 135
 	if (self.screenBackgroundColor) {
132 136
 		UIColor* screenColor = [RCTConvert UIColor:self.screenBackgroundColor];
133 137
 		viewController.view.backgroundColor = screenColor;

+ 16
- 0
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m Zobrazit soubor

@@ -122,6 +122,22 @@
122 122
 	XCTAssertTrue([self.uut.view.backgroundColor isEqual:expectedColor]);
123 123
 }
124 124
 
125
+-(void)testPopGestureEnabled_true{
126
+	NSNumber* popGestureEnabled = @(1);
127
+	self.options.popGesture = popGestureEnabled;
128
+	__unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
129
+	[self.uut viewWillAppear:false];
130
+	XCTAssertTrue(self.uut.navigationController.interactivePopGestureRecognizer.enabled);
131
+}
132
+
133
+-(void)testPopGestureEnabled_false{
134
+	NSNumber* popGestureEnabled = @(0);
135
+	self.options.popGesture = popGestureEnabled;
136
+	__unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
137
+	[self.uut viewWillAppear:false];
138
+	XCTAssertFalse(self.uut.navigationController.interactivePopGestureRecognizer.enabled);
139
+}
140
+
125 141
 -(void)testTopBarTextFontFamily_validFont{
126 142
 	NSString* inputFont = @"HelveticaNeue";
127 143
 	__unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];