Skip to content

feat: new method getBottomTabHeight added to BottomNavigationBar #4408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions src/components/BottomNavigation/BottomNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ export type Props<Route extends BaseRoute> = {
* Get label text for the tab, uses `route.title` by default. Use `renderLabel` to replace label component.
*/
getLabelText?: (props: { route: Route }) => string | undefined;
/**
* Get the height of the Bottom Tab. Useful for Custom Tab bars.
*/
getBottomTabHeight?: (height: number) => void;
/**
* Get the id to locate this tab button in tests, uses `route.testID` by default.
*/
Expand Down Expand Up @@ -366,6 +370,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
getColor = ({ route }: { route: Route }) => route.color,
getAccessibilityLabel = ({ route }: { route: Route }) =>
route.accessibilityLabel,
getBottomTabHeight,
getTestID = ({ route }: { route: Route }) => route.testID,
activeColor,
inactiveColor,
Expand Down Expand Up @@ -428,6 +433,13 @@ const BottomNavigationBar = <Route extends BaseRoute>({
*/
const [layout, onLayout] = useLayout();

/**
* Gets the height of the Bottom Tabs when using Custom Tab bar.
*/
React.useEffect(() => {
layout.measured && getBottomTabHeight?.(layout.height);
}, [layout.measured, getBottomTabHeight]);

/**
* Track whether the keyboard is visible to show and hide the navigation bar.
*/
Expand Down