Skip to content

Commit 2eebe0a

Browse files
committed
fix: android tabBarIcon not visible when build to apk
1 parent fc096de commit 2eebe0a

File tree

1 file changed

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

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.content.res.ColorStateList
66
import android.graphics.Typeface
77
import android.graphics.drawable.ColorDrawable
88
import android.graphics.drawable.Drawable
9+
import android.net.Uri
910
import android.os.Build
1011
import android.util.Log
1112
import android.util.TypedValue
@@ -180,10 +181,27 @@ class ReactBottomNavigationView(context: Context) : BottomNavigationView(context
180181
itemRippleColor = color
181182
}
182183

184+
private fun formatUri(uri: Uri): Uri {
185+
return when (uri.scheme) {
186+
"res" -> {
187+
val uriString = uri.toString()
188+
val parts = uriString.split(":/")
189+
190+
if (parts.size > 1) {
191+
val resourceId = parts[1].toIntOrNull()
192+
Uri.parse("android.resource://${context.packageName}/${resourceId}")
193+
} else {
194+
uri
195+
}
196+
}
197+
else -> uri
198+
}
199+
}
200+
183201
@SuppressLint("CheckResult")
184202
private fun getDrawable(imageSource: ImageSource, onDrawableReady: (Drawable?) -> Unit) {
185203
val request = ImageRequest.Builder(context)
186-
.data(imageSource.uri)
204+
.data(formatUri(imageSource.uri))
187205
.target { drawable ->
188206
post { onDrawableReady(drawable.asDrawable(context.resources)) }
189207
}

0 commit comments

Comments
 (0)