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
5 changes: 5 additions & 0 deletions .changeset/twelve-rules-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-bottom-tabs': minor
---

feat!: remove ignoresTopSafeArea prop, safe area handling is now automatic
10 changes: 0 additions & 10 deletions apps/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ import NativeBottomTabsUnmounting from './Examples/NativeBottomTabsUnmounting';
import NativeBottomTabsCustomTabBar from './Examples/NativeBottomTabsCustomTabBar';
import NativeBottomTabsFreezeOnBlur from './Examples/NativeBottomTabsFreezeOnBlur';

const FourTabsIgnoreSafeArea = () => {
return <FourTabs ignoresTopSafeArea />;
};

const HiddenTab = () => {
return <FourTabs hideOneTab />;
};
Expand Down Expand Up @@ -89,12 +85,6 @@ const examples = [
name: 'Embedded stacks',
screenOptions: { headerShown: false },
},
{
component: FourTabsIgnoreSafeArea,
name: 'Four Tabs - No header',
platform: 'ios',
screenOptions: { headerShown: false },
},
{
component: FourTabsRippleColor,
name: 'Four Tabs with ripple Color',
Expand Down
3 changes: 0 additions & 3 deletions apps/example/src/Examples/FourTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Chat } from '../Screens/Chat';
import type { ColorValue } from 'react-native';

interface Props {
ignoresTopSafeArea?: boolean;
disablePageAnimations?: boolean;
scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent';
backgroundColor?: ColorValue;
Expand All @@ -18,7 +17,6 @@ interface Props {
}

export default function FourTabs({
ignoresTopSafeArea = false,
disablePageAnimations = false,
scrollEdgeAppearance = 'default',
backgroundColor,
Expand Down Expand Up @@ -64,7 +62,6 @@ export default function FourTabs({

return (
<TabView
ignoresTopSafeArea={ignoresTopSafeArea}
sidebarAdaptable
disablePageAnimations={disablePageAnimations}
scrollEdgeAppearance={scrollEdgeAppearance}
Expand Down
5 changes: 0 additions & 5 deletions docs/docs/docs/guides/standalone-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ A tab bar style that adapts to each platform:
- macOS/tvOS: Sidebar
- visionOS: Ornament with sidebar for secondary tabs

#### `ignoresTopSafeArea` <Badge text="iOS" type="info" />

Whether to ignore the top safe area.
- Type: `boolean`

#### `disablePageAnimations` <Badge text="iOS" type="info" />

Whether to disable animations between tabs.
Expand Down
4 changes: 0 additions & 4 deletions docs/docs/docs/guides/usage-with-react-navigation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ Optional unique ID for the navigator. This can be used with `navigation.getParen

The name of the route to render on first load of the navigator.

#### `ignoresTopSafeArea` <Badge text="iOS" type="info" />

Whether to ignore the top safe area. Defaults to `true`.

#### `screenOptions`

Default options to use for the screens in the navigator.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/docs/guides/usage-with-vector-icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Tabs = createNativeBottomTabNavigator();

function NativeBottomTabs() {
return (
<Tabs.Navigator ignoresTopSafeArea>
<Tabs.Navigator>
<Tabs.Screen
name="Home"
component={HomeScreen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ class RCTTabViewManager(context: ReactApplicationContext) : ViewGroupManager<Rea
fun setSidebarAdaptable(view: ReactBottomNavigationView, flag: Boolean) {
}

@ReactProp(name = "ignoresTopSafeArea")
fun setIgnoresTopSafeArea(view: ReactBottomNavigationView, flag: Boolean) {
}

@ReactProp(name = "hapticFeedbackEnabled")
fun setHapticFeedbackEnabled(view: ReactBottomNavigationView, value: Boolean) {
tabViewImpl.setHapticFeedbackEnabled(view, value)
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native-bottom-tabs/ios/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension PlatformImage {
}

extension View {

#if os(macOS)
@MainActor
@ViewBuilder
Expand All @@ -81,8 +81,8 @@ extension View {
#endif
}
#endif


@MainActor
@ViewBuilder
func measureView(onLayout: @escaping (_ size: CGSize) -> Void) -> some View {
Expand All @@ -97,7 +97,7 @@ extension View {
onLayout(geometry.size)
}
}
.ignoresSafeArea(.all, edges: .vertical)
.ignoresSafeArea(.all, edges: .all)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
_tabViewProvider.labeled = newViewProps.labeled;
}

if (oldViewProps.ignoresTopSafeArea != newViewProps.ignoresTopSafeArea) {
_tabViewProvider.ignoresTopSafeArea = newViewProps.ignoresTopSafeArea;
}

if (oldViewProps.selectedPage != newViewProps.selectedPage) {
_tabViewProvider.selectedPage = RCTNSStringFromString(newViewProps.selectedPage);
}
Expand Down Expand Up @@ -162,7 +158,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
if (oldViewProps.fontFamily != newViewProps.fontFamily) {
_tabViewProvider.fontFamily = RCTNSStringFromStringNilIfEmpty(newViewProps.fontFamily);
}

if (oldViewProps.tabBarHidden != newViewProps.tabBarHidden) {
_tabViewProvider.tabBarHidden = newViewProps.tabBarHidden;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ @implementation RCTTabView
RCT_EXPORT_VIEW_PROPERTY(icons, NSArray<RCTImageSource *>);
RCT_EXPORT_VIEW_PROPERTY(sidebarAdaptable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(labeled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(ignoresTopSafeArea, BOOL)
RCT_EXPORT_VIEW_PROPERTY(disablePageAnimations, BOOL)
RCT_EXPORT_VIEW_PROPERTY(scrollEdgeAppearance, NSString)
RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL)
Expand Down
21 changes: 3 additions & 18 deletions packages/react-native-bottom-tabs/ios/TabViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ struct TabViewImpl: View {
let icon = props.icons[index]

RepresentableView(view: child)
.ignoresTopSafeArea(
props.ignoresTopSafeArea
)
.ignoresSafeArea(.container, edges: .all)
.tabItem {
TabItem(
title: tabData?.title,
Expand Down Expand Up @@ -134,7 +132,7 @@ struct TabViewImpl: View {
#if !os(macOS)
private func updateTabBarAppearance(props: TabViewProps, tabBar: UITabBar?) {
guard let tabBar else { return }

tabBar.isHidden = props.tabBarHidden

if props.scrollEdgeAppearance == "transparent" {
Expand Down Expand Up @@ -290,19 +288,6 @@ extension View {
}
}

@ViewBuilder
func ignoresTopSafeArea(
_ flag: Bool
) -> some View {
if flag {
self
.ignoresSafeArea(.container, edges: .vertical)
} else {
self
.ignoresSafeArea(.container, edges: .bottom)
}
}

#if !os(macOS)
@ViewBuilder
func configureAppearance(props: TabViewProps, tabBar: UITabBar?) -> some View {
Expand Down Expand Up @@ -350,7 +335,7 @@ extension View {
self
}
}

@ViewBuilder
func hideTabBar(_ flag: Bool) -> some View {
#if !os(macOS)
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-bottom-tabs/ios/TabViewProps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class TabViewProps: ObservableObject {
@Published var activeTintColor: PlatformColor?
@Published var inactiveTintColor: PlatformColor?
@Published var translucent: Bool = true
@Published var ignoresTopSafeArea: Bool = true
@Published var disablePageAnimations: Bool = false
@Published var hapticFeedbackEnabled: Bool = false
@Published var fontSize: Int?
Expand Down
8 changes: 1 addition & 7 deletions packages/react-native-bottom-tabs/ios/TabViewProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public final class TabInfo: NSObject {
}
}

@objc public var ignoresTopSafeArea: Bool = true {
didSet {
props.ignoresTopSafeArea = ignoresTopSafeArea
}
}

@objc public var selectedPage: NSString? {
didSet {
props.selectedPage = selectedPage as? String
Expand Down Expand Up @@ -156,7 +150,7 @@ public final class TabInfo: NSObject {
props.fontSize = fontSize as? Int
}
}

@objc public var tabBarHidden: Bool = false {
didSet {
props.tabBarHidden = tabBarHidden
Expand Down
4 changes: 0 additions & 4 deletions packages/react-native-bottom-tabs/src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
* - visionOS shows an ornament and also shows a sidebar for secondary tabs within a `TabSection`.
*/
sidebarAdaptable?: boolean;
/**
* Whether to ignore the top safe area. (iOS only)
*/
ignoresTopSafeArea?: boolean;
/**
* Whether to disable page animations between tabs. (iOS only) Defaults to `false`.
*/
Expand Down Expand Up @@ -219,7 +215,7 @@

if (!loaded.includes(focusedKey)) {
// Set the current tab to be loaded if it was not loaded before
setLoaded((loaded) => [...loaded, focusedKey]);

Check warning on line 218 in packages/react-native-bottom-tabs/src/TabView.tsx

View workflow job for this annotation

GitHub Actions / lint

'loaded' is already declared in the upper scope on line 214 column 10
}

const icons = React.useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export interface TabViewProps extends ViewProps {
rippleColor?: ColorValue;
activeTintColor?: ColorValue;
inactiveTintColor?: ColorValue;
ignoresTopSafeArea?: WithDefault<boolean, true>;
disablePageAnimations?: boolean;
activeIndicatorColor?: ColorValue;
hapticFeedbackEnabled?: boolean;
Expand Down
Loading