We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
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.
getRootWindowInsetsCompatM
insets in getRootWindowInsetsCompatM uses rootView.rootWindowInsets which returns:
rootView.rootWindowInsets
// 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
activity
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
The text was updated successfully, but these errors were encountered:
lequanghuylc/react-native-detect-navbar-android#9 (comment)
Sorry, something went wrong.
No branches or pull requests
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.
trying to understand a bit,
getRootWindowInsetsCompatM
seems to be the function used to get the insets on my samsung.insets in
getRootWindowInsetsCompatM
usesrootView.rootWindowInsets
which returns:i try to reactivate the navigationBar to see what was logged and it looks like it gets the same values :/
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-visibleif you want me to test a specific code to replace the
rootView.rootWindowInsets
and see if it returns the right value, happy to helpThe text was updated successfully, but these errors were encountered: