From d1c35c618a77a7dac81fa7806dd81aee005d5dee Mon Sep 17 00:00:00 2001 From: Joar Kosberg Date: Fri, 25 Jul 2025 08:59:25 +0200 Subject: [PATCH 1/2] Apply typeface and size individually in android text appearance. --- .../main/java/com/rcttabview/RCTTabView.kt | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) 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 41547fd1..1e1040eb 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 @@ -399,27 +399,34 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) { } private fun updateTextAppearance() { - if (fontSize != null || fontFamily != null || fontWeight != null) { - val menuView = bottomNavigation.getChildAt(0) as? ViewGroup ?: return - val size = fontSize?.toFloat()?.takeIf { it > 0 } ?: 12f - val typeface = ReactFontManager.getInstance().getTypeface( + // Early return if there is no custom text appearance + if (fontSize == null && fontFamily == null && fontWeight == null) { + return + } + + val typeface = if (fontFamily != null || fontWeight != null) { + ReactFontManager.getInstance().getTypeface( fontFamily ?: "", Utils.getTypefaceStyle(fontWeight), context.assets ) - - for (i in 0 until menuView.childCount) { - val item = menuView.getChildAt(i) - val largeLabel = - item.findViewById(com.google.android.material.R.id.navigation_bar_item_large_label_view) - val smallLabel = - item.findViewById(com.google.android.material.R.id.navigation_bar_item_small_label_view) - - listOf(largeLabel, smallLabel).forEach { label -> - label?.apply { + } else null + val size = fontSize?.toFloat()?.takeIf { it > 0 } + + val menuView = bottomNavigation.getChildAt(0) as? ViewGroup ?: return + for (i in 0 until menuView.childCount) { + val item = menuView.getChildAt(i) + val largeLabel = + item.findViewById(com.google.android.material.R.id.navigation_bar_item_large_label_view) + val smallLabel = + item.findViewById(com.google.android.material.R.id.navigation_bar_item_small_label_view) + + listOf(largeLabel, smallLabel).forEach { label -> + label?.apply { + size?.let { size -> setTextSize(TypedValue.COMPLEX_UNIT_SP, size) - setTypeface(typeface) } + typeface?.let { setTypeface(it) } } } } From 7b92802e49bb0896a5fc514d097bcb6f929286a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwa=C5=9Bniewski?= Date: Wed, 30 Jul 2025 09:18:59 +0200 Subject: [PATCH 2/2] Create bright-windows-sip.md --- .changeset/bright-windows-sip.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/bright-windows-sip.md diff --git a/.changeset/bright-windows-sip.md b/.changeset/bright-windows-sip.md new file mode 100644 index 00000000..8108d184 --- /dev/null +++ b/.changeset/bright-windows-sip.md @@ -0,0 +1,5 @@ +--- +"react-native-bottom-tabs": patch +--- + +fix: apply typeface and size individually in android text appearance.