mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-27 01:34:25 +08:00
Fix screen container after rnsscreen layout change. (#215)
For native stack we introduced a new way of layouting screen controllers. We no longer rely on flexbox to layout them so that we can use native stack to provide a correct dimensions and safe area paddings. Unfortunately this change broke the old screen container. With this commit we are adapting layout change to old screen container that will now layout its direct children on the native side by making them take up the whole space of the container.
This commit is contained in:
committed by
GitHub
parent
2536837795
commit
5d5e8bfca6
@@ -8,33 +8,6 @@
|
||||
#import <React/RCTShadowView.h>
|
||||
#import <React/RCTTouchHandler.h>
|
||||
|
||||
@interface RNSScreenFrameData : NSObject
|
||||
@property (nonatomic, readonly) CGFloat rightInset;
|
||||
@property (nonatomic, readonly) CGFloat topInset;
|
||||
@property (nonatomic, readonly) CGFloat bottomInset;
|
||||
@property (nonatomic, readonly) CGFloat leftInset;
|
||||
@property (nonatomic, readonly) CGFloat navbarOffset;
|
||||
|
||||
- (instancetype)initWithInsets:(UIEdgeInsets)insets;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RNSScreenFrameData
|
||||
|
||||
- (instancetype)initWithInsets:(UIEdgeInsets)insets andNavbarOffset:(CGFloat)navbarOffset
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_topInset = insets.top;
|
||||
_bottomInset = insets.bottom;
|
||||
_leftInset = insets.left;
|
||||
_rightInset = insets.right;
|
||||
_navbarOffset = navbarOffset;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface RNSScreenView () <UIAdaptivePresentationControllerDelegate>
|
||||
@end
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
{
|
||||
subview.reactSuperview = self;
|
||||
[_reactSubviews insertObject:subview atIndex:atIndex];
|
||||
subview.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(RNSScreenView *)subview
|
||||
@@ -159,6 +160,10 @@
|
||||
[super layoutSubviews];
|
||||
[self reactAddControllerToClosestParent:_controller];
|
||||
_controller.view.frame = self.bounds;
|
||||
for (RNSScreenView *subview in _reactSubviews) {
|
||||
subview.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
|
||||
[subview setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user