Skip to content

Commit 9dbdf69

Browse files
committed
feat: handle expo absolute positioning android
1 parent e23a390 commit 9dbdf69

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

android/src/main/java/com/unistyles/Insets.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,19 @@ class UnistylesInsets(private val reactApplicationContext: ReactApplicationConte
8787
@Suppress("DEPRECATION")
8888
private fun getBottomInset(baseInsets: Insets, window: Window): Int {
8989
val translucentNavigation = hasTranslucentNavigation(window)
90+
val fullScreenMode = hasFullScreenMode(window)
9091

9192
// Android 11 has inconsistent FLAG_LAYOUT_NO_LIMITS, which alone does nothing
9293
// https://stackoverflow.com/questions/64153785/android-11-window-setdecorfitssystemwindow-doesnt-show-screen-behind-status-a
9394
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
94-
if ((hasFullScreenMode(window) && translucentNavigation) || translucentNavigation) {
95+
if ((fullScreenMode && translucentNavigation) || translucentNavigation) {
9596
return baseInsets.bottom
9697
}
9798

9899
return 0
99100
}
100101

101-
return if (hasTranslucentNavigation(window) || hasFullScreenMode(window)) baseInsets.bottom else 0
102+
return if (translucentNavigation || fullScreenMode) baseInsets.bottom else 0
102103
}
103104

104105
private fun forceLandscapeInsets(baseInsets: Insets, window: Window): Boolean {
@@ -133,6 +134,8 @@ class UnistylesInsets(private val reactApplicationContext: ReactApplicationConte
133134
}
134135

135136
private fun hasFullScreenMode(window: Window): Boolean {
136-
return (window.attributes.flags and WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) == WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
137+
val decorFitsSystemWindows = window.decorView.fitsSystemWindows
138+
139+
return (window.attributes.flags and WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) == WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS || !decorFitsSystemWindows
137140
}
138141
}

0 commit comments

Comments
 (0)