appandflow / appandflow/react-native-safe-area-context

returning inset bottom on samsung S8 even with edge-to-edge hidden nav bar

オープン
#555 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
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.

![388208896-83a72475-5420-48ea-8e63-be5b6ef2a3c1 (1)](https://github.com/user-attachments/assets/02636d47-7a1d-4249-b48a-724c3d70dbf4)

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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。