diff --git a/.changeset/giant-years-turn.md b/.changeset/giant-years-turn.md new file mode 100644 index 00000000..9dc9ad5e --- /dev/null +++ b/.changeset/giant-years-turn.md @@ -0,0 +1,5 @@ +--- +"react-native-bottom-tabs": patch +--- + +feat: support more than 6 screens on Android diff --git a/packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt b/packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt index 7ed9d535..390579ed 100644 --- a/packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt +++ b/packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt @@ -34,8 +34,14 @@ import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_UNLABELED import com.google.android.material.transition.platform.MaterialFadeThrough +class ExtendedBottomNavigationView(context: Context) : BottomNavigationView(context) { + override fun getMaxItemCount(): Int { + return 100 + } +} + class ReactBottomNavigationView(context: Context) : LinearLayout(context) { - private var bottomNavigation = BottomNavigationView(context) + private var bottomNavigation = ExtendedBottomNavigationView(context) val layoutHolder = FrameLayout(context) var onTabSelectedListener: ((key: String) -> Unit)? = null @@ -456,7 +462,7 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) { // React Native opts out ouf Activity re-creation when configuration changes, this workarounds that. // We also opt-out of this recreation when custom styles are used. removeView(bottomNavigation) - bottomNavigation = BottomNavigationView(context) + bottomNavigation = ExtendedBottomNavigationView(context) addView(bottomNavigation) updateItems(items) setLabeled(this.labeled) diff --git a/packages/react-native-bottom-tabs/src/TabView.tsx b/packages/react-native-bottom-tabs/src/TabView.tsx index 3854669c..9332c7d7 100644 --- a/packages/react-native-bottom-tabs/src/TabView.tsx +++ b/packages/react-native-bottom-tabs/src/TabView.tsx @@ -162,7 +162,7 @@ interface Props { }; } -const ANDROID_MAX_TABS = 6; +const ANDROID_MAX_TABS = 100; const TabView = ({ navigationState,