Skip to content

Commit

Permalink
Fix top bar component layout frame size (#5015)
Browse files Browse the repository at this point in the history
* Fix top bar component layout frame size

* Update RNNReactView.m
  • Loading branch information
yogevbd authored Apr 23, 2019
1 parent 0e888fb commit 1993b93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/ios/RNNReactView.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ - (void)setAlignment:(NSString *)alignment {
self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
} else {
self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
__weak RNNReactView *weakSelf = self;
[self setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicSize) {
[weakSelf setFrame:CGRectMake(0, 0, intrinsicSize.width, intrinsicSize.height)];
}];
}
}

Expand Down
15 changes: 1 addition & 14 deletions lib/ios/RNNViewControllerPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,9 @@ - (void)setCustomNavigationTitleView:(RNNNavigationOptions *)options perform:(RN
if (options.topBar.title.component.name.hasValue) {
_customTitleView = (RNNReactView*)[_componentRegistry createComponentIfNotExists:options.topBar.title.component parentComponentId:viewController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
_customTitleView.backgroundColor = UIColor.clearColor;

NSString* alignment = [options.topBar.title.component.alignment getWithDefaultValue:@""];
[_customTitleView setAlignment:alignment];

BOOL isCenter = [alignment isEqualToString:@"center"];
__weak RNNReactView *weakTitleView = _customTitleView;
CGRect frame = viewController.navigationController.navigationBar.bounds;
[_customTitleView setFrame:frame];
[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
if (isCenter) {
[weakTitleView setFrame:CGRectMake(0, 0, intrinsicContentSize.width, intrinsicContentSize.height)];
} else {
[weakTitleView setFrame:frame];
}
}];


viewController.navigationItem.titleView = _customTitleView;
} else {
[_customTitleView removeFromSuperview];
Expand Down

0 comments on commit 1993b93

Please sign in to comment.