Skip to content

Commit 70e1955

Browse files
authored
fix(android): properly set android background color (#258)
* fix(android): properly set android background color * docs: add missing changesets
1 parent 20ae835 commit 70e1955

File tree

4 files changed

+13
-23
lines changed

4 files changed

+13
-23
lines changed

.changeset/metal-bobcats-juggle.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+
fix: properly set background color on Android

.changeset/two-socks-tie.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+
fix: iOS crash on old architecture when setting font style

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.rcttabview
22

33
import android.annotation.SuppressLint
4+
import android.content.Context
45
import android.content.res.ColorStateList
5-
import android.graphics.Color
66
import android.graphics.drawable.ColorDrawable
77
import android.graphics.drawable.Drawable
88
import android.os.Build
@@ -20,14 +20,10 @@ import android.widget.LinearLayout
2020
import android.widget.TextView
2121
import androidx.core.view.children
2222
import androidx.core.view.forEachIndexed
23-
import androidx.core.view.isGone
24-
import androidx.core.view.isVisible
25-
import androidx.viewpager2.widget.ViewPager2
2623
import coil3.ImageLoader
2724
import coil3.asDrawable
2825
import coil3.request.ImageRequest
2926
import coil3.svg.SvgDecoder
30-
import com.facebook.react.bridge.ReactContext
3127
import com.facebook.react.bridge.ReadableArray
3228
import com.facebook.react.common.assets.ReactFontManager
3329
import com.facebook.react.modules.core.ReactChoreographer
@@ -38,8 +34,7 @@ import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY
3834
import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_UNLABELED
3935
import com.google.android.material.transition.platform.MaterialFadeThrough
4036

41-
class ReactBottomNavigationView(context: ReactContext) : LinearLayout(context) {
42-
private val reactContext: ReactContext = context
37+
class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
4338
private val bottomNavigation = BottomNavigationView(context)
4439
val layoutHolder = FrameLayout(context)
4540

@@ -335,11 +330,7 @@ class ReactBottomNavigationView(context: ReactContext) : LinearLayout(context) {
335330
val colorDrawable = ColorDrawable(backgroundColor)
336331

337332
bottomNavigation.itemBackground = colorDrawable
338-
backgroundTintList = ColorStateList.valueOf(backgroundColor)
339-
// Set navigationBarColor for edge-to-edge.
340-
if (Utils.isEdgeToEdge()) {
341-
reactContext.currentActivity?.window?.navigationBarColor = backgroundColor
342-
}
333+
bottomNavigation.backgroundTintList = ColorStateList.valueOf(backgroundColor)
343334
}
344335

345336
fun setActiveTintColor(color: Int?) {
@@ -430,9 +421,6 @@ class ReactBottomNavigationView(context: ReactContext) : LinearLayout(context) {
430421

431422
override fun onDetachedFromWindow() {
432423
super.onDetachedFromWindow()
433-
if (Utils.isEdgeToEdge()) {
434-
reactContext.currentActivity?.window?.navigationBarColor = Color.TRANSPARENT
435-
}
436424
imageLoader.shutdown()
437425
}
438426
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,5 @@ class Utils {
2727
)
2828
return baseColor.defaultColor
2929
}
30-
31-
// Detect `react-native-edge-to-edge` (https://github.com/zoontek/react-native-edge-to-edge)
32-
fun isEdgeToEdge() = try {
33-
Class.forName("com.zoontek.rnedgetoedge.EdgeToEdgePackage")
34-
true
35-
} catch (exception: ClassNotFoundException) {
36-
false
37-
}
3830
}
3931
}

0 commit comments

Comments
 (0)