diff --git a/lib/ios/RNNBasePresenter.h b/lib/ios/RNNBasePresenter.h index 418f8ff238d..ddda89f2afa 100644 --- a/lib/ios/RNNBasePresenter.h +++ b/lib/ios/RNNBasePresenter.h @@ -14,8 +14,6 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void); - (void)applyOptions:(RNNNavigationOptions *)options; -- (void)applyOptionsOnSetViewControllers:(RNNNavigationOptions *)options; - - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options; - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions; diff --git a/lib/ios/RNNBasePresenter.m b/lib/ios/RNNBasePresenter.m index c3586186ea4..8ba1b9811ad 100644 --- a/lib/ios/RNNBasePresenter.m +++ b/lib/ios/RNNBasePresenter.m @@ -19,10 +19,6 @@ - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions { } -- (void)applyOptionsOnSetViewControllers:(RNNNavigationOptions *)options { - -} - - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options { UIViewController* viewController = self.bindedViewController; diff --git a/lib/ios/RNNTabBarController.m b/lib/ios/RNNTabBarController.m index 14802a1d97e..7e543859e66 100644 --- a/lib/ios/RNNTabBarController.m +++ b/lib/ios/RNNTabBarController.m @@ -4,11 +4,6 @@ @implementation RNNTabBarController { NSUInteger _currentTabIndex; } -- (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers { - [super setViewControllers:viewControllers]; - [self.presenter applyOptionsOnSetViewControllers:self.resolveOptions]; -} - - (id)delegate { return self; } diff --git a/lib/ios/RNNTabBarPresenter.m b/lib/ios/RNNTabBarPresenter.m index c0321162d80..feba81116a8 100644 --- a/lib/ios/RNNTabBarPresenter.m +++ b/lib/ios/RNNTabBarPresenter.m @@ -3,7 +3,7 @@ @implementation RNNTabBarPresenter -- (void)applyOptionsOnSetViewControllers:(RNNNavigationOptions *)options { +- (void)applyOptionsOnInit:(RNNNavigationOptions *)options { UITabBarController* tabBarController = self.bindedViewController; [tabBarController rnn_setCurrentTabIndex:[options.bottomTabs.currentTabIndex getWithDefaultValue:0]]; } diff --git a/lib/ios/ReactNativeNavigationTests/RNNTabBarControllerTest.m b/lib/ios/ReactNativeNavigationTests/RNNTabBarControllerTest.m index 3291b1460d9..379af1e37e6 100644 --- a/lib/ios/ReactNativeNavigationTests/RNNTabBarControllerTest.m +++ b/lib/ios/ReactNativeNavigationTests/RNNTabBarControllerTest.m @@ -153,4 +153,14 @@ - (void)testSetSelectedIndexByComponentID_ShouldSetSelectedIndexWithCorrectIndex XCTAssertTrue(uut.selectedIndex == 1); } +- (void)testSetSelectedIndex_ShouldSetSelectedIndexWithCurrentTabIndex { + RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions]; + options.bottomTabs.currentTabIndex = [[IntNumber alloc] initWithValue:@(1)]; + + RNNRootViewController* vc = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:nil options:nil defaultOptions:nil]; + RNNTabBarController* uut = [[RNNTabBarController alloc] initWithLayoutInfo:nil creator:nil options:options defaultOptions:nil presenter:[RNNTabBarPresenter new] eventEmitter:nil childViewControllers:@[[UIViewController new], vc]]; + + XCTAssertTrue(uut.selectedIndex == 1); +} + @end diff --git a/lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m b/lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m index e9f7235a00d..24faffff885 100644 --- a/lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m +++ b/lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m @@ -54,13 +54,5 @@ - (void)testApplyOptions_shouldApplyOptions { [self.bindedViewController verify]; } -- (void)testApplyOptions_shouldApplyOptionsOnSetViewControllers { - RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions]; - initialOptions.bottomTabs.currentTabIndex = [[IntNumber alloc] initWithValue:@(1)]; - [[self.bindedViewController expect] rnn_setCurrentTabIndex:1]; - - [self.uut applyOptionsOnSetViewControllers:initialOptions]; - [self.bindedViewController verify]; -} @end