Skip to content

Commit d23a888

Browse files
committed
fix: appearance issues with dark mode switches on Android
1 parent 3d0ac88 commit d23a888

File tree

1 file changed

+8
-6
lines changed
  • packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
5656
private var fontSize: Int? = null
5757
private var fontFamily: String? = null
5858
private var fontWeight: Int? = null
59+
private var labeled: Boolean? = null
5960
private var lastReportedSize: Size? = null
6061
private var hasCustomAppearance = false
6162
private var uiModeConfiguration: Int = Configuration.UI_MODE_NIGHT_UNDEFINED
@@ -260,10 +261,13 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
260261
}
261262
}
262263
}
263-
updateTextAppearance()
264-
updateTintColors()
265264
}
266265
}
266+
// Update tint colors and text appearance after updating all items.
267+
post {
268+
updateTextAppearance()
269+
updateTintColors()
270+
}
267271
}
268272

269273
private fun getOrCreateItem(index: Int, title: String): MenuItem {
@@ -295,6 +299,7 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
295299
}
296300

297301
fun setLabeled(labeled: Boolean?) {
302+
this.labeled = labeled
298303
bottomNavigation.labelVisibilityMode = when (labeled) {
299304
false -> {
300305
LABEL_VISIBILITY_UNLABELED
@@ -310,7 +315,6 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
310315

311316
fun setRippleColor(color: ColorStateList) {
312317
bottomNavigation.itemRippleColor = color
313-
hasCustomAppearance = true
314318
}
315319

316320
@SuppressLint("CheckResult")
@@ -354,18 +358,15 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
354358
fun setActiveTintColor(color: Int?) {
355359
activeTintColor = color
356360
updateTintColors()
357-
hasCustomAppearance = true
358361
}
359362

360363
fun setInactiveTintColor(color: Int?) {
361364
inactiveTintColor = color
362365
updateTintColors()
363-
hasCustomAppearance = true
364366
}
365367

366368
fun setActiveIndicatorColor(color: ColorStateList) {
367369
bottomNavigation.itemActiveIndicatorColor = color
368-
hasCustomAppearance = true
369370
}
370371

371372
fun setFontSize(size: Int) {
@@ -457,6 +458,7 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
457458
bottomNavigation = BottomNavigationView(context)
458459
addView(bottomNavigation)
459460
updateItems(items)
461+
setLabeled(this.labeled)
460462
uiModeConfiguration = newConfig?.uiMode ?: uiModeConfiguration
461463
}
462464
}

0 commit comments

Comments
 (0)