Skip to content

Commit

Permalink
Fix bottomTabs attach mode for sideMenu (#6001)
Browse files Browse the repository at this point in the history
Co-authored-by: Guy Carmeli <[email protected]>
  • Loading branch information
yogevbd and guyca authored Mar 11, 2020
1 parent 979cb6e commit 7d6029f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/ios/RNNSideMenuChildVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo creator:(id<RNNCo
}

- (void)render {
[self.getCurrentChild render];
[self addChildViewController:self.child];
[self.child.view setFrame:self.view.bounds];
[self.view addSubview:self.child.view];
[self.view bringSubviewToFront:self.child.view];
[self.child render];
}

- (void)setChild:(UIViewController<RNNLayoutProtocol> *)child {
_child = child;
[self addChildViewController:self.child];
[self.child.view setFrame:self.view.bounds];
[self.view addSubview:self.child.view];
[self.view bringSubviewToFront:self.child.view];
}

- (void)setWidth:(CGFloat)width {
Expand Down
16 changes: 15 additions & 1 deletion lib/ios/RNNSideMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ @implementation RNNSideMenuController

- (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo creator:(id<RNNComponentViewCreator>)creator childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNBasePresenter *)presenter eventEmitter:(RNNEventEmitter *)eventEmitter {
[self setControllers:childViewControllers];
self = [super initWithCenterViewController:self.center leftDrawerViewController:self.left rightDrawerViewController:self.right];
self = [super init];

self.presenter = presenter;
[self.presenter bindViewController:self];
Expand All @@ -38,6 +38,20 @@ - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {
[self.presenter setDefaultOptions:defaultOptions];
}

- (void)loadView {
[super loadView];
[self setCenterViewController:self.center];
[self setLeftDrawerViewController:self.left];
[self setRightDrawerViewController:self.right];
}

- (void)render {
[super render];
[self.center render];
[self.left render];
[self.right render];
}

- (void)setAnimationType:(NSString *)animationType {
MMDrawerControllerDrawerVisualStateBlock animationTypeStateBlock = nil;
if ([animationType isEqualToString:@"door"]) animationTypeStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
Expand Down
4 changes: 2 additions & 2 deletions lib/ios/UIViewController+LayoutProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ - (void)render {
[self readyForPresentation];
}

[self.presentedComponentViewController setReactViewReadyCallback:^{
[self.getCurrentChild setReactViewReadyCallback:^{
[self.presenter renderComponents:self.resolveOptionsWithDefault perform:^{
[self readyForPresentation];
}];
}];

[self.presentedComponentViewController render];
[self.getCurrentChild render];
}

- (void)readyForPresentation {
Expand Down
6 changes: 5 additions & 1 deletion playground/ios/NavigationTests/RNNSideMenuPresenterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ @implementation RNNSideMenuPresenterTest
- (void)setUp {
[super setUp];
self.uut = [[RNNSideMenuPresenter alloc] init];
self.boundViewController = [OCMockObject partialMockForObject:[RNNSideMenuController new]];
self.boundViewController = [OCMockObject partialMockForObject:[[RNNSideMenuController alloc] initWithLayoutInfo:nil creator:nil childViewControllers:@[[self createChildVC:RNNSideMenuChildTypeCenter]] options:nil defaultOptions:nil presenter:nil eventEmitter:nil]];
[self.uut bindViewController:self.boundViewController];
self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
}

- (RNNSideMenuChildVC *)createChildVC:(RNNSideMenuChildType)type {
return [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:[UIViewController new] type:type];
}

- (void)testApplyOptionsShouldSetDefaultValues {
[[self.boundViewController expect] side:MMDrawerSideLeft enabled:YES];
[[self.boundViewController expect] side:MMDrawerSideRight enabled:YES];
Expand Down

0 comments on commit 7d6029f

Please sign in to comment.