Skip to content

Commit

Permalink
fix(iOS): Remove calculating status bar height in useAnimatedHeaderHe…
Browse files Browse the repository at this point in the history
…ight when header is not shown (#2033)

## Description

This PR fixes the behaviour of `useAnimatedHeaderHeight`, when header is
not shown.
Currently, it includes the status bar height when `headerShown` prop is
false. This is wrong, since we don't have a header in such scenario and
we don't want to include status bar there. Therefore, when navigation
controller does not exist or `isNavigationBarHidden` is set to true, we
simply return 0.

## Changes

- Removed calculating status bar height when header is not shown.

## Test code and steps to reproduce

You can use `Test1802.tsx` to test these changes.

## Checklist

- [x] Ensured that CI passes
  • Loading branch information
tboba authored Feb 21, 2024
1 parent a8f7f86 commit 050973e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1111,17 +1111,11 @@ - (CGFloat)calculateHeaderHeightIsModal:(BOOL)isModal
{
UINavigationController *navctr = [self getVisibleNavigationControllerIsModal:isModal];

// If navigation controller doesn't exists (or it is hidden) we want to handle two possible cases.
// If there's no navigation controller for the modal, we simply don't want to return header height, as modal possibly
// does not have header and we don't want to count status bar. If there's no navigation controller for the view we
// just want to return status bar height (if it's hidden, it will simply return 0).
// If there's no navigation controller for the modal (or the navigation bar is hidden), we simply don't want to
// return header height, as modal possibly does not have header when navigation controller is nil,
// and we don't want to count status bar if navigation bar is hidden (inset could be negative).
if (navctr == nil || navctr.isNavigationBarHidden) {
if (isModal) {
return 0;
} else {
CGSize statusBarSize = [self getStatusBarHeightIsModal:isModal];
return MIN(statusBarSize.width, statusBarSize.height);
}
return 0;
}

CGFloat navbarHeight = navctr.navigationBar.frame.size.height;
Expand Down

0 comments on commit 050973e

Please sign in to comment.