appandflow / appandflow/react-native-safe-area-context
returning inset bottom on samsung S8 even with edge-to-edge hidden nav bar
- 主要言語
- TypeScript
- スター
- 2.8k
- フォーク
- 258
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 2
説明
i'm using expo 52 and edge-to-edge support and when i tested on my samsung galaxy s8, the navigation bar is hidden but the inset is wrong.

the value should be zero since the nav is hidden but it's 144.
```kotlin
fun getSafeAreaInsets(view: View): EdgeInsets? {
// The view has not been layout yet.
if (view.height == 0) {
return null
}
val rootView = view.rootView
val windowInsets = getRootWindowInsetsCompat(rootView) ?: return null
// Calculate the part of the view that overlaps with window insets.
val windowWidth = rootView.width.toFloat()
val windowHeight = rootView.height.toFloat()
val visibleRect = android.graphics.Rect()
view.getGlobalVisibleRect(visibleRect)
Log.d(
"DebugTag", // Replace with your desired tag
"Computed values: top=${visibleRect.top}, height=${view.height}, " +
"windowHeight=$windowHeight, insetsBottom=${windowInsets.bottom}, " +
"result=${max(min(visibleRect.top + view.height - windowHeight, 0f) + windowInsets.bottom, 0f)}"
)
return EdgeInsets(
top = max(windowInsets.top - visibleRect.top, 0f),
right = max(min(visibleRect.left + view.width - windowWidth, 0f) + windowInsets.right, 0f),
bottom = max(min(visibleRect.top + view.height - windowHeight, 0f) + windowInsets.bottom, 0f),
left = max(windowInsets.left - visibleRect.left, 0f))
}
```
```
Computed values: top=0, height=2220, windowHeight=2220.0, insetsBottom=144.0, result=144.0
```
trying to understand a bit, `getRootWindowInsetsCompatM` seems to be the function used to get the insets on my samsung.
insets in `getRootWindowInsetsCompatM` uses `rootView.rootWindowInsets` which returns:
```
// without navigation bar showing
API Level: WindowInsets{systemWindowInsets=Rect(0, 72 - 0, 144) windowDecorInsets=Rect(0, 0 - 0, 0) stableInsets=Rect(0, 72 - 0, 144)}
```
i try to reactivate the navigationBar to see what was logged and it looks like it gets the same values :/
```
// with navigation bar showing
API Level: WindowInsets{systemWindowInsets=Rect(0, 72 - 0, 144) windowDecorInsets=Rect(0, 0 - 0, 0) stableInsets=Rect(0, 72 - 0, 144)}
```
issue also seems to be that the code below return true even when the navigation bar is hidden :/
```rootWindowInsets?.isVisible(WindowInsetsCompat.Type.navigationBars())```
what i maybe found so far but need `activity` is something like this [https://stackoverflow.com/questions/51317263/how-to-know-when-samsung-s8-s8-s9-ect-bottom-navigation-bar-is-visible](https://stackoverflow.com/questions/51317263/how-to-know-when-samsung-s8-s8-s9-ect-bottom-navigation-bar-is-visible)
if you want me to test a specific code to replace the `rootView.rootWindowInsets` and see if it returns the right value, happy to help
コントリビューションガイド
評価
この issue はまだ評価されていません。