Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-android-badge-colors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-native-bottom-tabs": patch
---

fix(android): add missing badgeBackgroundColor and badgeTextColor to TabInfo data class
Original file line number Diff line number Diff line change
Expand Up @@ -256,31 +256,9 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
if (item.badge != " ") {
badge.text = item.badge
}
// Apply badge colors if provided, or reset to theme defaults if null
if (item.badgeBackgroundColor != null) {
badge.backgroundColor = item.badgeBackgroundColor
} else {
// Reset to theme default color by resolving the colorError attribute
val typedValue = TypedValue()
context.theme.resolveAttribute(
com.google.android.material.R.attr.colorError,
typedValue,
true
)
badge.backgroundColor = typedValue.data
}
if (item.badgeTextColor != null) {
badge.badgeTextColor = item.badgeTextColor
} else {
// Reset to theme default text color by resolving the colorOnError attribute
val typedValue = TypedValue()
context.theme.resolveAttribute(
com.google.android.material.R.attr.colorOnError,
typedValue,
true
)
badge.badgeTextColor = typedValue.data
}
// Apply badge colors if provided (Material will use its default theme colors otherwise)
item.badgeBackgroundColor?.let { badge.backgroundColor = it }
item.badgeTextColor?.let { badge.badgeTextColor = it }
} else {
bottomNavigation.removeBadge(index)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data class TabInfo(
val key: String,
val title: String,
val badge: String?,
val badgeBackgroundColor: Int?,
val badgeTextColor: Int?,
val activeTintColor: Int?,
val hidden: Boolean,
val testID: String?
Expand Down Expand Up @@ -99,6 +101,8 @@ class RCTTabViewManager(context: ReactApplicationContext) :
key = item.getString("key") ?: "",
title = item.getString("title") ?: "",
badge = if (item.hasKey("badge")) item.getString("badge") else null,
badgeBackgroundColor = if (item.hasKey("badgeBackgroundColor")) item.getInt("badgeBackgroundColor") else null,
badgeTextColor = if (item.hasKey("badgeTextColor")) item.getInt("badgeTextColor") else null,
activeTintColor = if (item.hasKey("activeTintColor")) item.getInt("activeTintColor") else null,
hidden = if (item.hasKey("hidden")) item.getBoolean("hidden") else false,
testID = item.getString("testID")
Expand Down
Loading