From 2d8592c54534d8d1aba843b3ad8362c92ac1a139 Mon Sep 17 00:00:00 2001 From: tboba Date: Wed, 11 Oct 2023 10:17:38 +0200 Subject: [PATCH] Change place of updating header height --- ios/RNSScreenStackHeaderConfig.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 5ce35e2c8f..1923f1c534 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -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]; + } } } @@ -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) && \ @@ -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