|
14 | 14 | */ |
15 | 15 | static NSString *const kMoreNavigationControllerScreenKey = @"rnscreens_moreNavigationController"; |
16 | 16 |
|
17 | | -@interface RNSTabBarController () <UITabBarControllerDelegate> |
| 17 | +// We need UINavigationControllerDelegate to handle navigation within `moreNavigationController` |
| 18 | +@interface RNSTabBarController () <UITabBarControllerDelegate, UINavigationControllerDelegate> |
18 | 19 | @end |
19 | 20 |
|
20 | | -// We need this to handle navigation within `moreNavigationController` |
21 | | -@interface RNSTabBarController () <UINavigationControllerDelegate> |
22 | | -@end |
23 | | - |
24 | | -// We need this to handle navigation within `moreNavigationController` |
25 | 21 | @interface RNSTabBarController () |
26 | 22 |
|
27 | 23 | /// Consulted by the ISA-swizzled `pushViewController:animated:` on `moreNavigationController` |
@@ -275,6 +271,27 @@ - (void)userDidSelectViewController:(nonnull UIViewController *)viewController |
275 | 271 | [self.tabsHostComponentView tabBarController:self didUpdateStateTo:_navigationState withContext:updateContext]; |
276 | 272 | } |
277 | 273 |
|
| 274 | +- (void)onDidPreventUserFromSelectingViewControllerWithKey:(nonnull NSString *)screenKey |
| 275 | +{ |
| 276 | + [self.tabsHostComponentView tabBarController:self preventedSelectionOf:screenKey currentState:_navigationState]; |
| 277 | +} |
| 278 | + |
| 279 | +- (BOOL)shouldPreventNativeTabSelection:(nonnull UIViewController *)nextViewController |
| 280 | +{ |
| 281 | + // This handles the tabsHostComponentView nullability |
| 282 | + if ([self.tabsHostComponentView experimental_controlNavigationStateInJS]) { |
| 283 | + return YES; |
| 284 | + } |
| 285 | + |
| 286 | + if (![nextViewController isKindOfClass:RNSTabsScreenViewController.class]) { |
| 287 | + // Allow for more view controller selection |
| 288 | + return NO; |
| 289 | + } |
| 290 | + |
| 291 | + auto *screenViewController = static_cast<RNSTabsScreenViewController *>(nextViewController); |
| 292 | + return screenViewController.isPreventNativeSelectionEnabled; |
| 293 | +} |
| 294 | + |
278 | 295 | #pragma mark - UITabBarControllerDelegate |
279 | 296 |
|
280 | 297 | // These methods are not called on programatic selection! |
@@ -356,27 +373,6 @@ - (void)navigationController:(UINavigationController *)navigationController |
356 | 373 | #endif // RNS_MORE_NAVIGATION_CONTROLLER_AVAILABLE |
357 | 374 | } |
358 | 375 |
|
359 | | -- (void)onDidPreventUserFromSelectingViewControllerWithKey:(nonnull NSString *)screenKey |
360 | | -{ |
361 | | - [self.tabsHostComponentView tabBarController:self preventedSelectionOf:screenKey currentState:_navigationState]; |
362 | | -} |
363 | | - |
364 | | -- (BOOL)shouldPreventNativeTabSelection:(nonnull UIViewController *)nextViewController |
365 | | -{ |
366 | | - // This handles the tabsHostComponentView nullability |
367 | | - if ([self.tabsHostComponentView experimental_controlNavigationStateInJS]) { |
368 | | - return YES; |
369 | | - } |
370 | | - |
371 | | - if (![nextViewController isKindOfClass:RNSTabsScreenViewController.class]) { |
372 | | - // Allow for more view controller selection |
373 | | - return NO; |
374 | | - } |
375 | | - |
376 | | - auto *screenViewController = static_cast<RNSTabsScreenViewController *>(nextViewController); |
377 | | - return screenViewController.isPreventNativeSelectionEnabled; |
378 | | -} |
379 | | - |
380 | 376 | #pragma mark - Signals related |
381 | 377 |
|
382 | 378 | - (void)updateChildViewControllersIfNeeded |
|
0 commit comments