Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve options from bottomTabs direct child in mergeChildOptions #6050

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/ios/RNNBottomTabsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ - (void)onChildAddToParent:(UIViewController *)child options:(RNNNavigationOptio

- (void)mergeChildOptions:(RNNNavigationOptions *)options child:(UIViewController *)child {
[super mergeChildOptions:options child:child];
[_bottomTabPresenter mergeOptions:options resolvedOptions:child.resolveOptions child:[self findViewController:child]];
[_dotIndicatorPresenter mergeOptions:options resolvedOptions:child.resolveOptions child:[self findViewController:child]];
UIViewController* childViewController = [self findViewController:child];
[_bottomTabPresenter mergeOptions:options resolvedOptions:childViewController.resolveOptions child:childViewController];
[_dotIndicatorPresenter mergeOptions:options resolvedOptions:childViewController.resolveOptions child:childViewController];
}

- (id<UITabBarControllerDelegate>)delegate {
Expand Down
30 changes: 30 additions & 0 deletions playground/ios/NavigationTests/RNNCommandsHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,36 @@ - (void)testMergeOptions_shouldMergeWithChildOnly {
XCTAssertTrue([secondChild.tabBarItem.title isEqualToString:@"Second"]);
}

- (void)testMergeOptions_shouldResolveTreeOptions {
[self.uut setReadyToReceiveCommands:true];
NSDictionary* mergeOptions = @{@"bottomTab": @{@"badge": @"Badge"}};

RNNNavigationOptions* firstChildOptions = [RNNNavigationOptions emptyOptions];

RNNNavigationOptions* secondChildOptions = [RNNNavigationOptions emptyOptions];
secondChildOptions.bottomTab.text = [Text withValue:@"Second"];
RNNNavigationOptions* stackOptions = [RNNNavigationOptions emptyOptions];
stackOptions.bottomTab.text = [Text withValue:@"First"];

RNNComponentViewController* firstChild = [RNNComponentViewController createWithComponentId:@"first" initialOptions:firstChildOptions];
RNNStackController* stack = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:stackOptions defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:@[firstChild]];
RNNComponentViewController* secondChild = [RNNComponentViewController createWithComponentId:@"second" initialOptions:secondChildOptions];

RNNBottomTabsController* tabBarController = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:[RNNNavigationOptions emptyOptions] defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:[RNNBasePresenter new] bottomTabPresenter:[BottomTabPresenterCreator createWithDefaultOptions:[RNNNavigationOptions emptyOptions]] dotIndicatorPresenter:nil eventEmitter:_eventEmmiter childViewControllers:@[stack, secondChild] bottomTabsAttacher:nil];

OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(tabBarController);
[self.mainWindow setRootViewController:tabBarController];
[secondChild viewWillAppear:YES];

[self.uut mergeOptions:firstChild.layoutInfo.componentId options:mergeOptions completion:^{

}];

XCTAssertTrue([stack.tabBarItem.badgeValue isEqualToString:@"Badge"]);
XCTAssertTrue([stack.tabBarItem.title isEqualToString:@"First"]);
XCTAssertTrue([secondChild.tabBarItem.title isEqualToString:@"Second"]);
}

- (void)testShowModal_shouldShowAnimated {
[self.uut setReadyToReceiveCommands:true];
self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions];
Expand Down