diff --git a/.gitignore b/.gitignore
index 960c8148..5e70f7e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
.gradle
.project
.settings
+.history
local.properties
diff --git a/packages/bottom-tabs/src/types.tsx b/packages/bottom-tabs/src/types.tsx
index 26b04454..35949878 100644
--- a/packages/bottom-tabs/src/types.tsx
+++ b/packages/bottom-tabs/src/types.tsx
@@ -184,6 +184,16 @@ export type BottomTabBarOptions = {
* Whether the label position should adapt to the orientation.
*/
adaptive?: boolean;
+ /**
+ * Safe area insets for the tab bar. This is used to avoid elements like the navigation bar on Android and bottom safe area on iOS.
+ * By default, the device's safe area insets are automatically detected. You can override the behavior with this option.
+ */
+ safeAreaInsets?: {
+ top?: number;
+ right?: number;
+ bottom?: number;
+ left?: number;
+ };
/**
* Style object for the tab bar container.
*/
diff --git a/packages/bottom-tabs/src/views/BottomTabBar.tsx b/packages/bottom-tabs/src/views/BottomTabBar.tsx
index 0766645f..4a2e8211 100644
--- a/packages/bottom-tabs/src/views/BottomTabBar.tsx
+++ b/packages/bottom-tabs/src/views/BottomTabBar.tsx
@@ -15,7 +15,7 @@ import {
CommonActions,
useTheme,
} from '@react-navigation/native';
-import { SafeAreaConsumer } from 'react-native-safe-area-context';
+import { useSafeArea } from 'react-native-safe-area-context';
import BottomTabItem from './BottomTabItem';
import { BottomTabBarProps } from '../types';
@@ -43,6 +43,7 @@ export default function BottomTabBar({
keyboardHidesTabBar = false,
labelPosition,
labelStyle,
+ safeAreaInsets,
showIcon,
showLabel,
style,
@@ -158,116 +159,122 @@ export default function BottomTabBar({
}
};
+ const defaultInsets = useSafeArea();
+
+ const insets = {
+ top: safeAreaInsets?.top ?? defaultInsets.top,
+ right: safeAreaInsets?.right ?? defaultInsets.right,
+ bottom: safeAreaInsets?.bottom ?? defaultInsets.bottom,
+ left: safeAreaInsets?.left ?? defaultInsets.left,
+ };
+
return (
-
- {insets => (
-
-
- {routes.map((route, index) => {
- const focused = index === state.index;
- const { options } = descriptors[route.key];
+
+
+ {routes.map((route, index) => {
+ const focused = index === state.index;
+ const { options } = descriptors[route.key];
- const onPress = () => {
- const event = navigation.emit({
- type: 'tabPress',
- target: route.key,
- canPreventDefault: true,
- });
+ const onPress = () => {
+ const event = navigation.emit({
+ type: 'tabPress',
+ target: route.key,
+ canPreventDefault: true,
+ });
- if (!focused && !event.defaultPrevented) {
- navigation.dispatch({
- ...CommonActions.navigate(route.name),
- target: state.key,
- });
- }
- };
+ if (!focused && !event.defaultPrevented) {
+ navigation.dispatch({
+ ...CommonActions.navigate(route.name),
+ target: state.key,
+ });
+ }
+ };
- const onLongPress = () => {
- navigation.emit({
- type: 'tabLongPress',
- target: route.key,
- });
- };
+ const onLongPress = () => {
+ navigation.emit({
+ type: 'tabLongPress',
+ target: route.key,
+ });
+ };
- const label =
- options.tabBarLabel !== undefined
- ? options.tabBarLabel
- : options.title !== undefined
- ? options.title
- : route.name;
+ const label =
+ options.tabBarLabel !== undefined
+ ? options.tabBarLabel
+ : options.title !== undefined
+ ? options.title
+ : route.name;
- const accessibilityLabel =
- options.tabBarAccessibilityLabel !== undefined
- ? options.tabBarAccessibilityLabel
- : typeof label === 'string'
- ? `${label}, tab, ${index + 1} of ${routes.length}`
- : undefined;
+ const accessibilityLabel =
+ options.tabBarAccessibilityLabel !== undefined
+ ? options.tabBarAccessibilityLabel
+ : typeof label === 'string'
+ ? `${label}, tab, ${index + 1} of ${routes.length}`
+ : undefined;
- return (
-
-
-
-
-
- );
- })}
-
-
- )}
-
+ return (
+
+
+
+
+
+ );
+ })}
+
+
);
}