diff --git a/demo/src/screens/componentScreens/TabControllerScreen/index.tsx b/demo/src/screens/componentScreens/TabControllerScreen/index.tsx
index b302337202..b9d73dd31c 100644
--- a/demo/src/screens/componentScreens/TabControllerScreen/index.tsx
+++ b/demo/src/screens/componentScreens/TabControllerScreen/index.tsx
@@ -1,6 +1,7 @@
import _ from 'lodash';
import React, {Component} from 'react';
import {ActivityIndicator, StyleSheet} from 'react-native';
+import {SafeAreaProvider} from 'react-native-safe-area-context';
import {
Assets,
TabController,
@@ -162,63 +163,65 @@ class TabControllerScreen extends Component<{}, State> {
render() {
const {key, initialIndex, asCarousel, centerSelected, fewItems, items} = this.state;
return (
-
-
-
+
+
- {this.renderTabPages()}
-
-
-
-
-
-
-
+
);
}
}
diff --git a/docs/getting-started/setup.md b/docs/getting-started/setup.md
index ba839655b5..540fd638eb 100644
--- a/docs/getting-started/setup.md
+++ b/docs/getting-started/setup.md
@@ -42,7 +42,7 @@ UILib supports additional features through optional dependencies. These packages
| @react-native-community/blur | Card component's blur effects |
| @react-native-community/datetimepicker | Date/time picker components |
| @react-native-community/netinfo | Network connectivity features |
-| react-native-safe-area-context | support useSafeAreaInsets inside and usages of Modal |
+| react-native-safe-area-context | support useSafeAreaInsets inside Modal, usages of Modal and TabController |
| react-native-haptic-feedback | Haptic feedback functionality |
| react-native-svg | SVG-based components |
| react-native-shimmer-placeholder | Shimmer loading effects |
diff --git a/packages/react-native-ui-lib/src/components/tabController/index.tsx b/packages/react-native-ui-lib/src/components/tabController/index.tsx
index acd2b06ffb..0197f3900e 100644
--- a/packages/react-native-ui-lib/src/components/tabController/index.tsx
+++ b/packages/react-native-ui-lib/src/components/tabController/index.tsx
@@ -2,6 +2,7 @@
import _ from 'lodash';
import React, {PropsWithChildren, useMemo, useEffect, useState, useCallback} from 'react';
import {useAnimatedReaction, useSharedValue, withTiming, runOnJS} from 'react-native-reanimated';
+import {SafeAreaContextPackage} from '../../optionalDependencies';
import {useOrientation, useThemeProps} from '../../hooks';
import {Constants} from '../../commons/new';
import TabBarContext from './TabBarContext';
@@ -52,9 +53,11 @@ export interface TabControllerProps {
children?: React.ReactNode;
}
-const getScreenWidth = (useSafeArea: boolean) => {
- const {left, right} = Constants.getSafeAreaInsets();
- return Constants.windowWidth - (useSafeArea && Constants.isIphoneX ? left + right : 0);
+const useSafeAreaInsets = SafeAreaContextPackage?.useSafeAreaInsets ?? (() => Constants.getSafeAreaInsets());
+
+
+const getScreenWidth = (useSafeArea: boolean, left: number, right: number) => {
+ return Constants.windowWidth - (useSafeArea ? left + right : 0);
};
/**
@@ -75,7 +78,8 @@ const TabController = React.forwardRef((props: PropsWithChildren(getScreenWidth(useSafeArea));
+ const {left, right} = useSafeAreaInsets();
+ const [screenWidth, setScreenWidth] = useState(getScreenWidth(useSafeArea, left, right));
if (items?.length < 2) {
console.warn('TabController component expect a minimum of 2 items');
@@ -83,7 +87,7 @@ const TabController = React.forwardRef((props: PropsWithChildren {
- setScreenWidth(getScreenWidth(useSafeArea));
+ setScreenWidth(getScreenWidth(useSafeArea, left, right));
}
});