Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ @implementation RCTTabView
RCT_EXPORT_VIEW_PROPERTY(sidebarAdaptable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(labeled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(ignoresTopSafeArea, BOOL)
RCT_EXPORT_VIEW_PROPERTY(ignoresBottomSafeArea, BOOL)
RCT_EXPORT_VIEW_PROPERTY(disablePageAnimations, BOOL)
RCT_EXPORT_VIEW_PROPERTY(scrollEdgeAppearance, NSString)
RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL)
Expand Down
19 changes: 19 additions & 0 deletions packages/react-native-bottom-tabs/ios/TabViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct TabViewImpl: View {
.measureView(onLayout: { size in
onLayout(size)
})
.ignoresKeyboardSafeArea(props.ignoresKeyboardSafeArea)
}
#if !os(tvOS) && !os(macOS) && !os(visionOS)
.onTabItemEvent({ index, isLongPress in
Expand Down Expand Up @@ -357,4 +358,22 @@ extension View {
self
}
}

@ViewBuilder
func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
if condition {
transform(self)
} else {
self
}
}

@ViewBuilder
func ignoresKeyboardSafeArea(_ flag: Bool) -> some View {
if flag {
self.ignoresSafeArea(.keyboard, edges: .bottom)
} else {
self
}
}
}
1 change: 1 addition & 0 deletions packages/react-native-bottom-tabs/ios/TabViewProps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TabViewProps: ObservableObject {
@Published var inactiveTintColor: PlatformColor?
@Published var translucent: Bool = true
@Published var ignoresTopSafeArea: Bool = true
@Published var ignoresKeyboardSafeArea: Bool = false
@Published var disablePageAnimations: Bool = false
@Published var hapticFeedbackEnabled: Bool = false
@Published var fontSize: Int?
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native-bottom-tabs/ios/TabViewProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public final class TabInfo: NSObject {
props.fontSize = fontSize as? Int
}
}

@objc public var ignoresKeyboardSafeArea: Bool = false {
didSet {
props.ignoresKeyboardSafeArea = ignoresKeyboardSafeArea
}
}

// New arch specific properties

Expand Down
5 changes: 5 additions & 0 deletions packages/react-native-bottom-tabs/src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ interface Props<Route extends BaseRoute> {
*/
fontSize?: number;
};
/**
* Whether to ignore the bottom safe area when keyboard is shown. (iOS only) Defaults to `false`.
*/
ignoresKeyboardSafeArea?: boolean;
}

const ANDROID_MAX_TABS = 6;
Expand Down Expand Up @@ -268,6 +272,7 @@ const TabView = <Route extends BaseRoute>({
onIndexChange(index);
});

console.log('TabView.tsx: ignoresTopSafeArea', JSON.stringify(props));
return (
<BottomTabBarHeightContext.Provider value={tabBarHeight}>
<NativeTabView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface TabViewProps extends ViewProps {
activeTintColor?: ColorValue;
inactiveTintColor?: ColorValue;
ignoresTopSafeArea?: WithDefault<boolean, true>;
ignoresKeyboardSafeArea?: WithDefault<boolean, false>;
disablePageAnimations?: boolean;
activeIndicatorColor?: ColorValue;
hapticFeedbackEnabled?: boolean;
Expand Down