Skip to content

Commit 3197715

Browse files
committed
fix: pass icon name, remove dispatchGlobalLayout
1 parent c0990a9 commit 3197715

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package com.rcttabview
33
import android.content.Context
44
import android.view.Choreographer
55
import android.view.MenuItem
6-
import android.view.View
7-
import android.view.ViewGroup
86
import androidx.appcompat.content.res.AppCompatResources
97
import com.facebook.react.bridge.Arguments
108
import com.facebook.react.bridge.WritableMap
@@ -40,16 +38,13 @@ class ReactBottomNavigationView(context: Context) : BottomNavigationView(context
4038

4139
private fun onTabSelected(item: MenuItem) {
4240
val selectedItem = items?.first { it.title == item.title }
43-
if (selectedItem == null) {
44-
return
45-
}
46-
47-
startAnimation()
48-
49-
val event = Arguments.createMap().apply {
50-
putString("key", selectedItem.key)
41+
selectedItem?.let {
42+
val event = Arguments.createMap().apply {
43+
putString("key", selectedItem.key)
44+
}
45+
onTabSelectedListener?.invoke(event)
46+
startAnimation()
5147
}
52-
onTabSelectedListener?.invoke(event)
5348
}
5449

5550
// Refresh TabView children to fix issue with animations.
@@ -91,7 +86,6 @@ class ReactBottomNavigationView(context: Context) : BottomNavigationView(context
9186

9287
// Fixes issues with BottomNavigationView children layouting.
9388
private fun measureAndLayout() {
94-
viewTreeObserver.dispatchOnGlobalLayout();
9589
measure(
9690
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
9791
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))

src/TabView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type BaseRoute = {
99
title?: string;
1010
badge?: string;
1111
lazy?: boolean;
12+
icon?: string;
1213
};
1314

1415
type NavigationState<Route extends BaseRoute> = {
@@ -56,7 +57,7 @@ const TabView = <Route extends BaseRoute>({
5657
const items: TabViewItems = navigationState.routes.map((route) => ({
5758
key: route.key,
5859
title: route.title ?? route.key,
59-
icon: 'document.fill',
60+
icon: route.icon,
6061
badge: route.badge,
6162
}));
6263

0 commit comments

Comments
 (0)