Skip to content
Merged
Show file tree
Hide file tree
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 @@ -193,6 +193,13 @@ class TabsHost(
updateNavigationMenuIfNeeded(oldValue, newValue)
}

var tabBarHidden: Boolean by Delegates.observable(false) { _, oldValue, newValue ->
if (newValue != oldValue) {
updateInterfaceInsets()
updateNavigationMenuIfNeeded(oldValue, newValue)
}
}

private fun <T> updateNavigationMenuIfNeeded(
oldValue: T,
newValue: T,
Expand Down Expand Up @@ -491,9 +498,15 @@ class TabsHost(
val newHeight = bottom - top

if (newHeight != oldHeight) {
interfaceInsetsChangeListener?.apply {
this.onInterfaceInsetsChange(EdgeInsets(0.0f, 0.0f, 0.0f, newHeight.toFloat()))
}
updateInterfaceInsets(newHeight)
}
}

private fun updateInterfaceInsets(newHeight: Int? = null) {
val height = if (tabBarHidden) 0 else (newHeight ?: bottomNavigationView.height)

interfaceInsetsChangeListener?.apply {
this.onInterfaceInsetsChange(EdgeInsets(0.0f, 0.0f, 0.0f, height.toFloat()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TabsHostAppearanceApplicator(
}

fun updateSharedAppearance(tabsHost: TabsHost) {
bottomNavigationView.isVisible = true
bottomNavigationView.isVisible = !tabsHost.tabBarHidden
bottomNavigationView.setBackgroundColor(
tabsHost.tabBarBackgroundColor
?: resolveColorAttr(com.google.android.material.R.attr.colorSurfaceContainer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ class TabsHostViewManager :
value: String?,
) = Unit

@ReactProp(name = "tabBarHidden")
override fun setTabBarHidden(
view: TabsHost,
value: Boolean,
) = Unit
) {
view.tabBarHidden = value
}

// Android additional

Expand Down
17 changes: 9 additions & 8 deletions src/components/bottom-tabs/BottomTabs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ export interface BottomTabsProps extends ViewProps {
) => void;
// #endregion Events

// #region General
/**
* @summary Hides the tab bar.
*
* @default false
*/
tabBarHidden?: boolean;
// #endregion General

// #region Android-only appearance
/**
* @summary Specifies the background color for the entire tab bar.
Expand Down Expand Up @@ -204,14 +213,6 @@ export interface BottomTabsProps extends ViewProps {
* @supported iOS 18 or higher
*/
tabBarControllerMode?: TabBarControllerMode;
/**
* @summary Hides the tab bar.
*
* @default false
*
* @platform ios
*/
tabBarHidden?: boolean;
// #endregion iOS-only appearance

// #region Experimental support
Expand Down
Loading