Skip to content

Commit 8882434

Browse files
feat: Support more than 6 screens on Android (#339)
* feat: Support more than 6 screens on Android * Move class definition to top * Make max Android screens 100 instead * Create giant-years-turn.md --------- Co-authored-by: Oskar Kwaśniewski <oskarkwasniewski@icloud.com>
1 parent 3806377 commit 8882434

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.changeset/giant-years-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-native-bottom-tabs": patch
3+
---
4+
5+
feat: support more than 6 screens on Android

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY
3434
import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_UNLABELED
3535
import com.google.android.material.transition.platform.MaterialFadeThrough
3636

37+
class ExtendedBottomNavigationView(context: Context) : BottomNavigationView(context) {
38+
override fun getMaxItemCount(): Int {
39+
return 100
40+
}
41+
}
42+
3743
class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
38-
private var bottomNavigation = BottomNavigationView(context)
44+
private var bottomNavigation = ExtendedBottomNavigationView(context)
3945
val layoutHolder = FrameLayout(context)
4046

4147
var onTabSelectedListener: ((key: String) -> Unit)? = null
@@ -456,7 +462,7 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
456462
// React Native opts out ouf Activity re-creation when configuration changes, this workarounds that.
457463
// We also opt-out of this recreation when custom styles are used.
458464
removeView(bottomNavigation)
459-
bottomNavigation = BottomNavigationView(context)
465+
bottomNavigation = ExtendedBottomNavigationView(context)
460466
addView(bottomNavigation)
461467
updateItems(items)
462468
setLabeled(this.labeled)

packages/react-native-bottom-tabs/src/TabView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ interface Props<Route extends BaseRoute> {
162162
};
163163
}
164164

165-
const ANDROID_MAX_TABS = 6;
165+
const ANDROID_MAX_TABS = 100;
166166

167167
const TabView = <Route extends BaseRoute>({
168168
navigationState,

0 commit comments

Comments
 (0)