Skip to content

Comments

feat(Android, SAV+Stack): add support for SAV in Stack#3405

Open
kligarski wants to merge 18 commits intomainfrom
@kligarski/android-stack-sav-support
Open

feat(Android, SAV+Stack): add support for SAV in Stack#3405
kligarski wants to merge 18 commits intomainfrom
@kligarski/android-stack-sav-support

Conversation

@kligarski
Copy link
Contributor

@kligarski kligarski commented Nov 19, 2025

Description

Adds support for SAV in Stack on Android. Fixes handling insets by the header (CustomToolbar).

3405.mp4

Fixes #3398.
Closes https://github.com/software-mansion/react-native-screens-labs/issues/464.

Changes

  • use different insets listener API based on Android SDK (<30/>=30) to correctly handle consuming display cutout inset
  • override ScreensCoordinatorLayout's dispatchApplyWindowInsets to manage order and flow of inset consumption
  • add screenInsets in CustomToolbar to store insets designated for Screen component
  • fix bug with missing menuView in CustomToolbar when used in nested stack
  • add Test3405

Test code and steps to reproduce

Run Test3405.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@Ubax
Copy link
Contributor

Ubax commented Jan 21, 2026

@kligarski sorry for the delay. I can confirm that this change fixes the issue in expo.

Thank you

Comment on lines +377 to +401
private fun shouldReadInsetsEarlyFromDecorView(): Boolean {
if (insetsApplied ||
headerConfig?.isHeaderHidden == true ||
headerConfig?.isHeaderTranslucent == true
) {
return false
}

// This is a heuristic - if a screen with non-translucent header is above us, we assume that
// it will handle the insets. If so, we don't want to read insets from DecorView as they
// would be accounted for more than once.
var current = parentAsView()
while (current != null) {
if (current is Screen &&
current.headerConfig?.isHeaderHidden == false &&
current.headerConfig?.isHeaderTranslucent == false
) {
return false
}
current = current.parentAsView()
}

return true
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to adjust the workaround from #3442 to handle nested stacks. In theory, we can also check headerConfig.toolbar.{shouldApplyTopInset, shouldAvoidDisplayCutout} but they are hard-coded to true right now.

@kligarski kligarski requested a review from t0maboro February 12, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] When stack is wrapped with SafeAreaView, then the insets are still applied to header

3 participants