Skip to content

Commit

Permalink
Fix react view title fill alignment (#5681)
Browse files Browse the repository at this point in the history
React view title layout didn't recalculated it size on orientation change which caused it to look bad on iPads.
  • Loading branch information
yogevbd authored and guyca committed Nov 24, 2019
1 parent 9e8d74a commit 619af3e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/ios/RNNReactView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#import "RCTHelpers.h"
#import <React/RCTUIManager.h>

@implementation RNNReactView
@implementation RNNReactView {
BOOL _fillParent;
}

- (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
Expand Down Expand Up @@ -44,10 +46,19 @@ - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
}
}

- (CGSize)intrinsicContentSize {
if (_fillParent) {
return UILayoutFittingExpandedSize;
} else {
return [super intrinsicContentSize];
}
}

- (void)setAlignment:(NSString *)alignment inFrame:(CGRect)frame {
if ([alignment isEqualToString:@"fill"]) {
_fillParent = YES;
self.translatesAutoresizingMaskIntoConstraints = NO;
self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
[self setFrame:frame];
} else {
self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
__weak RNNReactView *weakSelf = self;
Expand Down

0 comments on commit 619af3e

Please sign in to comment.