Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,20 @@ open class CustomToolbar(
// We want to handle display cutout always, no matter the HeaderConfig prop values.
// If there are no cutout displays, we want to apply the additional padding to
// respect the status bar.
//
// Use rootWindowInsets as a fallback for status bar top height when unhandledInsets
// reports 0. This can happen when an ancestor view (e.g. SafeAreaProvider from
// react-native-safe-area-context) has already consumed the top systemBars inset, causing
// unhandledInsets.top == 0 and the toolbar title to render behind the status bar.
// rootWindowInsets always contains the raw window insets regardless of consumption by ancestors.
val statusBarTop = if (shouldApplyTopInset) {
val fromUnhandled = systemBarInsets.top
if (fromUnhandled > 0) fromUnhandled else resolveInsetsOrZero(WindowInsetsCompat.Type.systemBars()).top
} else 0
val verticalInsets =
InsetsCompat.of(
0,
max(cutoutInsets.top, if (shouldApplyTopInset) systemBarInsets.top else 0),
max(cutoutInsets.top, statusBarTop),
0,
max(cutoutInsets.bottom, 0),
)
Expand Down