@@ -399,27 +399,34 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
399
399
}
400
400
401
401
private fun updateTextAppearance () {
402
- if (fontSize != null || fontFamily != null || fontWeight != null ) {
403
- val menuView = bottomNavigation.getChildAt(0 ) as ? ViewGroup ? : return
404
- val size = fontSize?.toFloat()?.takeIf { it > 0 } ? : 12f
405
- val typeface = ReactFontManager .getInstance().getTypeface(
402
+ // Early return if there is no custom text appearance
403
+ if (fontSize == null && fontFamily == null && fontWeight == null ) {
404
+ return
405
+ }
406
+
407
+ val typeface = if (fontFamily != null || fontWeight != null ) {
408
+ ReactFontManager .getInstance().getTypeface(
406
409
fontFamily ? : " " ,
407
410
Utils .getTypefaceStyle(fontWeight),
408
411
context.assets
409
412
)
410
-
411
- for (i in 0 until menuView.childCount) {
412
- val item = menuView.getChildAt(i)
413
- val largeLabel =
414
- item.findViewById<TextView >(com.google.android.material.R .id.navigation_bar_item_large_label_view)
415
- val smallLabel =
416
- item.findViewById<TextView >(com.google.android.material.R .id.navigation_bar_item_small_label_view)
417
-
418
- listOf (largeLabel, smallLabel).forEach { label ->
419
- label?.apply {
413
+ } else null
414
+ val size = fontSize?.toFloat()?.takeIf { it > 0 }
415
+
416
+ val menuView = bottomNavigation.getChildAt(0 ) as ? ViewGroup ? : return
417
+ for (i in 0 until menuView.childCount) {
418
+ val item = menuView.getChildAt(i)
419
+ val largeLabel =
420
+ item.findViewById<TextView >(com.google.android.material.R .id.navigation_bar_item_large_label_view)
421
+ val smallLabel =
422
+ item.findViewById<TextView >(com.google.android.material.R .id.navigation_bar_item_small_label_view)
423
+
424
+ listOf (largeLabel, smallLabel).forEach { label ->
425
+ label?.apply {
426
+ size?.let { size ->
420
427
setTextSize(TypedValue .COMPLEX_UNIT_SP , size)
421
- setTypeface(typeface)
422
428
}
429
+ typeface?.let { setTypeface(it) }
423
430
}
424
431
}
425
432
}
0 commit comments