Skip to content

feat(android): add bottom tab bar height property #2328

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 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
containerOffset: _providedContainerOffset,
topInset = 0,
bottomInset = 0,
android_bottomTabBarHeight = 0,
maxDynamicContentSize,

// animated callback shared values
Expand Down Expand Up @@ -180,6 +181,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
enableDynamicSizing,
topInset,
bottomInset,
android_bottomTabBarHeight,
});
}
//#endregion
Expand Down Expand Up @@ -1553,7 +1555,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
Math.abs(bottomInset - animatedContainerOffset.value.bottom)
)
: Math.abs(
_keyboardHeight - animatedContainerOffset.value.bottom
_keyboardHeight - animatedContainerOffset.value.bottom -
(Platform.OS === 'android' ? android_bottomTabBarHeight : 0)
);

/**
Expand Down
7 changes: 7 additions & 0 deletions src/components/bottomSheet/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export interface BottomSheetProps
* @default 0
*/
bottomInset?: number;
/**
* Bottom tab bar height value helps to avoid extra padding below text input on android,
* usually comes from `@react-navigation/bottom-tabs` hook `useBottomTabBarHeight`.
* @type number
* @default 0
*/
android_bottomTabBarHeight?: number;
/**
* Max dynamic content size height to limit the bottom sheet height
* from exceeding a provided size.
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/usePropsValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export const usePropsValidator = ({
enableDynamicSizing,
topInset,
bottomInset,
android_bottomTabBarHeight,
}: Pick<
BottomSheetProps,
'index' | 'snapPoints' | 'enableDynamicSizing' | 'topInset' | 'bottomInset'
'index' | 'snapPoints' | 'enableDynamicSizing' | 'topInset' | 'bottomInset' | 'android_bottomTabBarHeight'
>) => {
useMemo(() => {
//#region snap points
Expand Down Expand Up @@ -74,8 +75,12 @@ export const usePropsValidator = ({
typeof bottomInset === 'number' || typeof bottomInset === 'undefined',
`'bottomInset' was provided but with wrong type ! expected type is a number.`
);
invariant(
typeof android_bottomTabBarHeight === 'number' || typeof android_bottomTabBarHeight === 'undefined',
`'android_bottomTabBarHeight' was provided but with wrong type ! expected type is a number.`
);
//#endregion

// animations
}, [index, snapPoints, topInset, bottomInset, enableDynamicSizing]);
}, [index, snapPoints, topInset, bottomInset, enableDynamicSizing, android_bottomTabBarHeight]);
};