Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class TabsHost(

private var interfaceInsetsChangeListener: SafeAreaView? = null

// We need to differentiate between user tapping the menu item
// and update requested from JS.
private var menuItemSelectedViaContainerUpdate = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something, or is this supposed to not be triggered when controlledBottomTabs=false, but it is? Also IMO the name is a bit unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android, only controlled bottom tabs are currently supported.

I did use viaContainerUpdate name because I guess that there is a possibility to call container update from native code, not only as a result of JS focused tab change. I can maybe reverse the logic and use menuItemSelectedByUser or something like this but I'm not sure.


private val appearanceCoordinator =
TabsHostAppearanceCoordinator(wrappedContext, bottomNavigationView, tabScreenFragments)

Expand Down Expand Up @@ -221,7 +225,12 @@ class TabsHost(
val fragment = getFragmentForMenuItemId(item.itemId)
val tabKey = fragment?.tabScreen?.tabKey ?: "undefined"
eventEmitter.emitOnNativeFocusChange(tabKey)
true
if (menuItemSelectedViaContainerUpdate) {
menuItemSelectedViaContainerUpdate = false
true
} else {
false
}
}
}

Expand Down Expand Up @@ -317,6 +326,7 @@ class TabsHost(

appearanceCoordinator.updateTabAppearance(this)

menuItemSelectedViaContainerUpdate = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call it in updateSelectedTab instead of updateBottomNavigationViewAppearance? It would be a bit more logical there, or these 2 are not always called together ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it as well but I think on Android managing BottomNavigationView and shown screens/fragments is separated and those methods reflect that. Maybe we should think about renaming those methods though.

bottomNavigationView.selectedItemId =
checkNotNull(getSelectedTabScreenFragmentId()) { "[RNScreens] A single selected tab must be present" }

Expand Down
Loading