Skip to content

Commit 8ebd657

Browse files
committed
Some light cleanup
1 parent 34fef3d commit 8ebd657

1 file changed

Lines changed: 23 additions & 27 deletions

File tree

ios/tabs/host/RNSTabBarController.mm

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
*/
1515
static NSString *const kMoreNavigationControllerScreenKey = @"rnscreens_moreNavigationController";
1616

17-
@interface RNSTabBarController () <UITabBarControllerDelegate>
17+
// We need UINavigationControllerDelegate to handle navigation within `moreNavigationController`
18+
@interface RNSTabBarController () <UITabBarControllerDelegate, UINavigationControllerDelegate>
1819
@end
1920

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`
2521
@interface RNSTabBarController ()
2622

2723
/// Consulted by the ISA-swizzled `pushViewController:animated:` on `moreNavigationController`
@@ -275,6 +271,27 @@ - (void)userDidSelectViewController:(nonnull UIViewController *)viewController
275271
[self.tabsHostComponentView tabBarController:self didUpdateStateTo:_navigationState withContext:updateContext];
276272
}
277273

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+
278295
#pragma mark - UITabBarControllerDelegate
279296

280297
// These methods are not called on programatic selection!
@@ -356,27 +373,6 @@ - (void)navigationController:(UINavigationController *)navigationController
356373
#endif // RNS_MORE_NAVIGATION_CONTROLLER_AVAILABLE
357374
}
358375

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-
380376
#pragma mark - Signals related
381377

382378
- (void)updateChildViewControllersIfNeeded

0 commit comments

Comments
 (0)