@@ -17,6 +17,7 @@ import android.view.MenuItem
1717import android.view.View
1818import android.view.ViewGroup
1919import android.widget.FrameLayout
20+ import android.widget.LinearLayout
2021import android.widget.TextView
2122import androidx.viewpager2.widget.ViewPager2
2223import coil3.ImageLoader
@@ -34,7 +35,7 @@ import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY
3435import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_UNLABELED
3536import com.google.android.material.transition.platform.MaterialFadeThrough
3637
37- class ReactBottomNavigationView (context : ReactContext ) : FrameLayout (context) {
38+ class ReactBottomNavigationView (context : ReactContext ) : LinearLayout (context) {
3839 private val reactContext: ReactContext = context
3940 private val bottomNavigation = BottomNavigationView (context)
4041 private val viewPager = ViewPager2 (context)
@@ -65,23 +66,21 @@ class ReactBottomNavigationView(context: ReactContext) : FrameLayout(context) {
6566 .build()
6667
6768 init {
69+ orientation = VERTICAL
6870 viewPager.adapter = viewPagerAdapter
6971 viewPager.isUserInputEnabled = false
7072
71- viewPager.id = View .generateViewId()
7273 addView(
7374 viewPager, LayoutParams (
7475 LayoutParams .MATCH_PARENT ,
75- LayoutParams . MATCH_PARENT
76- )
76+ 0 ,
77+ ). apply { weight = 1f }
7778 )
7879
7980 addView(bottomNavigation, LayoutParams (
8081 LayoutParams .MATCH_PARENT ,
8182 LayoutParams .WRAP_CONTENT
82- ).apply {
83- gravity = Gravity .BOTTOM
84- })
83+ ))
8584
8685 post {
8786 addOnLayoutChangeListener { _, left, top, right, bottom,
@@ -90,12 +89,8 @@ class ReactBottomNavigationView(context: ReactContext) : FrameLayout(context) {
9089 val newHeight = bottom - top
9190
9291 if (newWidth != lastReportedSize?.width || newHeight != lastReportedSize?.height) {
93- // We subtract bottom navigation height from the screen height
94- // This should be refactored for adaptive navigation
95- val availableHeight = viewPager.height - bottomNavigation.height
96-
9792 val dpWidth = Utils .convertPixelsToDp(context, viewPager.width)
98- val dpHeight = Utils .convertPixelsToDp(context, availableHeight )
93+ val dpHeight = Utils .convertPixelsToDp(context, viewPager.height )
9994
10095 onNativeLayoutListener?.invoke(dpWidth, dpHeight)
10196 lastReportedSize = Size (newWidth, newHeight)
0 commit comments