Skip to content

Commit

Permalink
Change place of updating header height
Browse files Browse the repository at this point in the history
  • Loading branch information
tboba committed Oct 11, 2023
1 parent 83c8abc commit 2d8592c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ - (void)updateViewControllerIfNeeded
// if nav is nil, it means we can be in a fullScreen modal, so there is no nextVC, but we still want to update
if (vc != nil && (nextVC == vc || isInFullScreenModal || isPresentingVC)) {
[RNSScreenStackHeaderConfig updateViewController:self.screenView.controller withConfig:self animated:YES];
// As the header might have change in `updateViewController` we need to ensure that header height
// returned by the `onHeaderHeightChange` event is correct.
if ([vc isKindOfClass:[RNSScreen class]]) {
[(RNSScreen *)vc calculateAndNotifyHeaderHeightChangeIsModal:NO];
}
}
}

Expand Down Expand Up @@ -353,6 +358,11 @@ + (void)willShowViewController:(UIViewController *)vc
withConfig:(RNSScreenStackHeaderConfig *)config
{
[self updateViewController:vc withConfig:config animated:animated];
// As the header might have change in `updateViewController` we need to ensure that header height
// returned by the `onHeaderHeightChange` event is correct.
if ([vc isKindOfClass:[RNSScreen class]]) {
[(RNSScreen *)vc calculateAndNotifyHeaderHeightChangeIsModal:NO];
}
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
Expand Down Expand Up @@ -666,10 +676,6 @@ + (void)updateViewController:(UIViewController *)vc
} else {
[self setAnimatedConfig:vc withConfig:config];
}

if ([vc isKindOfClass:[RNSScreen class]]) {
[((RNSScreen *)vc) calculateAndNotifyHeaderHeightChangeIsModal:NO];
}
}

- (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex
Expand Down

0 comments on commit 2d8592c

Please sign in to comment.