|
1 | 1 | package com.swmansion.rnscreens.gamma.tabs |
2 | 2 |
|
3 | 3 | import android.content.res.Configuration |
| 4 | +import android.os.Build |
4 | 5 | import android.view.Choreographer |
5 | 6 | import android.view.Gravity |
6 | 7 | import android.view.MenuItem |
7 | 8 | import android.view.View |
| 9 | +import android.view.WindowInsets |
8 | 10 | import android.widget.FrameLayout |
9 | 11 | import androidx.appcompat.view.ContextThemeWrapper |
| 12 | +import androidx.core.view.children |
10 | 13 | import androidx.fragment.app.FragmentManager |
11 | 14 | import com.facebook.react.modules.core.ReactChoreographer |
12 | 15 | import com.facebook.react.uimanager.ThemedReactContext |
@@ -444,6 +447,26 @@ class TabsHost( |
444 | 447 | override fun getInterfaceInsets(): EdgeInsets = |
445 | 448 | EdgeInsets(0.0f, 0.0f, (bottomNavigationView.bottom - bottomNavigationView.top).toFloat(), 0.0f) |
446 | 449 |
|
| 450 | + override fun dispatchApplyWindowInsets(insets: WindowInsets?): WindowInsets? { |
| 451 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
| 452 | + return super.dispatchApplyWindowInsets(insets) |
| 453 | + } |
| 454 | + |
| 455 | + // On Android versions prior to R, insets dispatch is broken. |
| 456 | + // In order to mitigate this, we override dispatchApplyWindowInsets with |
| 457 | + // correct implementation. To simplify it, we skip the call to TabsHost's |
| 458 | + // onApplyWindowInsets. |
| 459 | + if (insets?.isConsumed ?: true) { |
| 460 | + return insets |
| 461 | + } |
| 462 | + |
| 463 | + for (child in children) { |
| 464 | + child.dispatchApplyWindowInsets(insets) |
| 465 | + } |
| 466 | + |
| 467 | + return insets |
| 468 | + } |
| 469 | + |
447 | 470 | internal fun onViewManagerAddEventEmitters() { |
448 | 471 | // When this is called from View Manager the view tag is already set |
449 | 472 | check(id != NO_ID) { "[RNScreens] TabsHost must have its tag set when registering event emitters" } |
|
0 commit comments