Browse Source

disabled back gesture support (#2273)

* disabled back gesture support

* changed disabledBackGesture prop name to popGesture
yogevbd 7 years ago
parent
commit
59d3bb3e9c

+ 2
- 2
README.md View File

124
 |--------------------|-----|----|-----|
124
 |--------------------|-----|----|-----|
125
 | screenBackgroundColor        |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       |  Wix|
125
 | screenBackgroundColor        |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       |  Wix|
126
 | orientation       |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
126
 | orientation       |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
127
-| disabledBackGesture        |  WIP @gran33     |    / iOS specific     |
127
+| disabledBackGesture        |       |    / iOS specific     |
128
 | screenBackgroundImageName        |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
128
 | screenBackgroundImageName        |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
129
 | rootBackgroundImageName              |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
129
 | rootBackgroundImageName              |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
130
 | sideMenuVisible          |        [Contribute](/docs/docs/CONTRIBUTING.md)   | [Contribute](/docs/docs/CONTRIBUTING.md) |
130
 | sideMenuVisible          |        [Contribute](/docs/docs/CONTRIBUTING.md)   | [Contribute](/docs/docs/CONTRIBUTING.md) |
192
 | orientation     |  ✅   |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
192
 | orientation     |  ✅   |    ✅     |   [Contribute](/docs/docs/CONTRIBUTING.md)          | Wix|
193
 | statusBarHideWithTopBar        |  ✅   |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
193
 | statusBarHideWithTopBar        |  ✅   |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
194
 | statusBarHidden       |  ✅   |    ✅       |     [Contribute](/docs/docs/CONTRIBUTING.md)      | WIX |
194
 | statusBarHidden       |  ✅   |    ✅       |     [Contribute](/docs/docs/CONTRIBUTING.md)      | WIX |
195
-| disabledBackGesture       |   ✅  |  WIP @gran33     |    / iOS specific     |
195
+| disabledBackGesture       |   ✅  |    |    / iOS specific     |
196
 | screenBackgroundImageName         |   ✅  |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
196
 | screenBackgroundImageName         |   ✅  |   [Contribute](/docs/docs/CONTRIBUTING.md)      |    [Contribute](/docs/docs/CONTRIBUTING.md)        |
197
 | rootBackgroundImageName            |  ✅   |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
197
 | rootBackgroundImageName            |  ✅   |    [Contribute](/docs/docs/CONTRIBUTING.md)     |    [Contribute](/docs/docs/CONTRIBUTING.md)       |
198
 | setButtons          |   ✅     |    ✅    | [Contribute](/docs/docs/CONTRIBUTING.md) | @Johan-dutoit|
198
 | setButtons          |   ✅     |    ✅    | [Contribute](/docs/docs/CONTRIBUTING.md) | @Johan-dutoit|

+ 1
- 0
lib/ios/RNNNavigationOptions.h View File

15
 @property (nonatomic, strong) NSArray* rightButtons;
15
 @property (nonatomic, strong) NSArray* rightButtons;
16
 @property (nonatomic, strong) NSNumber* statusBarBlur;
16
 @property (nonatomic, strong) NSNumber* statusBarBlur;
17
 @property (nonatomic, strong) NSNumber* statusBarHideWithTopBar;
17
 @property (nonatomic, strong) NSNumber* statusBarHideWithTopBar;
18
+@property (nonatomic, strong) NSNumber* popGesture;
18
 @property (nonatomic, strong) RNNTopBarOptions* topBar;
19
 @property (nonatomic, strong) RNNTopBarOptions* topBar;
19
 @property (nonatomic, strong) RNNTabBarOptions* tabBar;
20
 @property (nonatomic, strong) RNNTabBarOptions* tabBar;
20
 
21
 

+ 4
- 0
lib/ios/RNNNavigationOptions.m View File

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

+ 16
- 0
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

122
 	XCTAssertTrue([self.uut.view.backgroundColor isEqual:expectedColor]);
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
 -(void)testTopBarTextFontFamily_validFont{
141
 -(void)testTopBarTextFontFamily_validFont{
126
 	NSString* inputFont = @"HelveticaNeue";
142
 	NSString* inputFont = @"HelveticaNeue";
127
 	__unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
143
 	__unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];