Skip to content

Commit

Permalink
fix: pass icon name, remove dispatchGlobalLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Oct 2, 2024
1 parent c0990a9 commit 3197715
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
18 changes: 6 additions & 12 deletions android/src/main/java/com/rcttabview/RCTTabView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.rcttabview
import android.content.Context
import android.view.Choreographer
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.content.res.AppCompatResources
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
Expand Down Expand Up @@ -40,16 +38,13 @@ class ReactBottomNavigationView(context: Context) : BottomNavigationView(context

private fun onTabSelected(item: MenuItem) {
val selectedItem = items?.first { it.title == item.title }
if (selectedItem == null) {
return
}

startAnimation()

val event = Arguments.createMap().apply {
putString("key", selectedItem.key)
selectedItem?.let {
val event = Arguments.createMap().apply {
putString("key", selectedItem.key)
}
onTabSelectedListener?.invoke(event)
startAnimation()
}
onTabSelectedListener?.invoke(event)
}

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

// Fixes issues with BottomNavigationView children layouting.
private fun measureAndLayout() {
viewTreeObserver.dispatchOnGlobalLayout();
measure(
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
Expand Down
3 changes: 2 additions & 1 deletion src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type BaseRoute = {
title?: string;
badge?: string;
lazy?: boolean;
icon?: string;
};

type NavigationState<Route extends BaseRoute> = {
Expand Down Expand Up @@ -56,7 +57,7 @@ const TabView = <Route extends BaseRoute>({
const items: TabViewItems = navigationState.routes.map((route) => ({

Check failure on line 57 in src/TabView.tsx

View workflow job for this annotation

GitHub Actions / lint

Type '{ key: string; title: string; icon: string | undefined; badge: string | undefined; }[]' is not assignable to type 'TabViewItems'.
key: route.key,
title: route.title ?? route.key,
icon: 'document.fill',
icon: route.icon,
badge: route.badge,
}));

Expand Down

0 comments on commit 3197715

Please sign in to comment.