Skip to content

Commit ac36c43

Browse files
author
Khoroshikh Arkadii
committed
fix(Android, Stack v4): fall back to rootWindowInsets for status bar top when ancestor consumed insets
When an ancestor view (e.g. SafeAreaProvider from react-native-safe-area-context) consumes the systemBars top inset, unhandledInsets.top becomes 0. As a result, CustomToolbar computes paddingTop = 0 and the header title renders behind the status bar on Android 15 (SDK 35) with edge-to-edge enabled. Fix: for the status bar top height specifically, fall back to rootWindowInsets when unhandledInsets.top == 0. rootWindowInsets always contains the raw window insets regardless of what ancestor views have consumed. This preserves the intent of software-mansion#3240 (use ancestor-received insets when available) while fixing the regression on setups with SafeAreaProvider wrapping the app.
1 parent 840f140 commit ac36c43

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,20 @@ open class CustomToolbar(
168168
// We want to handle display cutout always, no matter the HeaderConfig prop values.
169169
// If there are no cutout displays, we want to apply the additional padding to
170170
// respect the status bar.
171+
//
172+
// Use rootWindowInsets as a fallback for status bar top height when unhandledInsets
173+
// reports 0. This can happen when an ancestor view (e.g. SafeAreaProvider from
174+
// react-native-safe-area-context) has already consumed the top systemBars inset, causing
175+
// unhandledInsets.top == 0 and the toolbar title to render behind the status bar.
176+
// rootWindowInsets always contains the raw window insets regardless of consumption by ancestors.
177+
val statusBarTop = if (shouldApplyTopInset) {
178+
val fromUnhandled = systemBarInsets.top
179+
if (fromUnhandled > 0) fromUnhandled else resolveInsetsOrZero(WindowInsetsCompat.Type.systemBars()).top
180+
} else 0
171181
val verticalInsets =
172182
InsetsCompat.of(
173183
0,
174-
max(cutoutInsets.top, if (shouldApplyTopInset) systemBarInsets.top else 0),
184+
max(cutoutInsets.top, statusBarTop),
175185
0,
176186
max(cutoutInsets.bottom, 0),
177187
)

0 commit comments

Comments
 (0)