Skip to content

Commit 3b17061

Browse files
committed
feat: implement iOS 26 minimize behavior
1 parent 110527c commit 3b17061

File tree

9 files changed

+56
-2
lines changed

9 files changed

+56
-2
lines changed

apps/example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ PODS:
11801180
- React-jsiexecutor
11811181
- React-RCTFBReactNativeSpec
11821182
- ReactCommon/turbomodule/core
1183-
- react-native-bottom-tabs (0.9.1):
1183+
- react-native-bottom-tabs (0.9.2):
11841184
- DoubleConversion
11851185
- glog
11861186
- RCT-Folly (= 2024.11.18.00)
@@ -1931,7 +1931,7 @@ SPEC CHECKSUMS:
19311931
React-logger: 1935d6e6461e9c8be4c87af56c56a4876021171e
19321932
React-Mapbuffer: 212171f037e3b22e6c2df839aa826806da480b85
19331933
React-microtasksnativemodule: a0ffd165c39251512d8cf51e9e8f5719dabc38b6
1934-
react-native-bottom-tabs: 7c7ee94435e518759b414e89068956096a1adec7
1934+
react-native-bottom-tabs: 6ee03990297f7e37f5c1dd6f5259cee851733d4f
19351935
react-native-safe-area-context: e54b360402f089600c2fb0d825d1d3d918b99e15
19361936
React-nativeconfig: cb207ebba7cafce30657c7ad9f1587a8f32e4564
19371937
React-NativeModulesApple: 76a5d35322908fbc88871e6dd20433bea2b8b2db

apps/example/src/Examples/SFSymbols.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default function SFSymbols() {
4747
return (
4848
<TabView
4949
sidebarAdaptable
50+
minimizeBehavior="onScrollDown"
5051
navigationState={{ index, routes }}
5152
onIndexChange={setIndex}
5253
renderScene={renderScene}

packages/react-native-bottom-tabs/ios/Fabric/RCTTabViewComponentView.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
130130
if (oldViewProps.sidebarAdaptable != newViewProps.sidebarAdaptable) {
131131
_tabViewProvider.sidebarAdaptable = newViewProps.sidebarAdaptable;
132132
}
133+
134+
if (oldViewProps.minimizeBehavior != newViewProps.minimizeBehavior) {
135+
_tabViewProvider.minimizeBehavior = RCTNSStringFromString(newViewProps.minimizeBehavior);
136+
}
133137

134138
if (oldViewProps.disablePageAnimations != newViewProps.disablePageAnimations) {
135139
_tabViewProvider.disablePageAnimations = newViewProps.disablePageAnimations;

packages/react-native-bottom-tabs/ios/RCTTabViewViewManager.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ @implementation RCTTabView
2929
RCT_EXPORT_VIEW_PROPERTY(onNativeLayout, RCTDirectEventBlock)
3030
RCT_EXPORT_VIEW_PROPERTY(selectedPage, NSString)
3131
RCT_EXPORT_VIEW_PROPERTY(tabViewStyle, NSString)
32+
RCT_EXPORT_VIEW_PROPERTY(minimizeBehavior, NSString)
3233
RCT_EXPORT_VIEW_PROPERTY(icons, NSArray<RCTImageSource *>);
3334
RCT_EXPORT_VIEW_PROPERTY(sidebarAdaptable, BOOL)
3435
RCT_EXPORT_VIEW_PROPERTY(labeled, BOOL)

packages/react-native-bottom-tabs/ios/TabViewImpl.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct TabViewImpl: View {
2828
onLayout(size)
2929
}
3030
}
31+
.tabBarMinimizeBehavior(props.minimizeBehavior)
3132
#if !os(tvOS) && !os(macOS) && !os(visionOS)
3233
.onTabItemEvent { index, isLongPress in
3334
let item = props.filteredItems[safe: index]
@@ -333,6 +334,19 @@ extension View {
333334
}
334335
}
335336

337+
@ViewBuilder
338+
func tabBarMinimizeBehavior(_ behavior: MinimizeBehavior?) -> some View {
339+
if #available(iOS 26.0, *) {
340+
if let behavior {
341+
self.tabBarMinimizeBehavior(behavior.convert())
342+
} else {
343+
self
344+
}
345+
} else {
346+
self
347+
}
348+
}
349+
336350
@ViewBuilder
337351
func hideTabBar(_ flag: Bool) -> some View {
338352
#if !os(macOS)

packages/react-native-bottom-tabs/ios/TabViewProps.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
import SwiftUI
22

3+
internal enum MinimizeBehavior: String {
4+
case automatic
5+
case never
6+
case onScrollUp
7+
case onScrollDown
8+
9+
@available(iOS 26.0, *)
10+
func convert() -> TabBarMinimizeBehavior {
11+
switch self {
12+
case .automatic:
13+
return .automatic
14+
case .never:
15+
return .never
16+
case .onScrollUp:
17+
return .onScrollUp
18+
case .onScrollDown:
19+
return .onScrollDown
20+
}
21+
}
22+
}
23+
324
/**
425
Props that component accepts. SwiftUI view gets re-rendered when ObservableObject changes.
526
*/
@@ -10,6 +31,7 @@ class TabViewProps: ObservableObject {
1031
@Published var icons: [Int: PlatformImage] = [:]
1132
@Published var sidebarAdaptable: Bool?
1233
@Published var labeled: Bool = false
34+
@Published var minimizeBehavior: MinimizeBehavior?
1335
@Published var scrollEdgeAppearance: String?
1436
@Published var barTintColor: PlatformColor?
1537
@Published var activeTintColor: PlatformColor?

packages/react-native-bottom-tabs/ios/TabViewProvider.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public final class TabInfo: NSObject {
102102
}
103103
}
104104

105+
@objc public var minimizeBehavior: NSString? {
106+
didSet {
107+
props.minimizeBehavior = MinimizeBehavior(rawValue: minimizeBehavior as? String ?? "")
108+
}
109+
}
110+
105111
@objc public var translucent: Bool = true {
106112
didSet {
107113
props.translucent = translucent

packages/react-native-bottom-tabs/src/TabView.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ interface Props<Route extends BaseRoute> {
5454
* Describes the appearance attributes for the tabBar to use when an observable scroll view is scrolled to the bottom. (iOS only)
5555
*/
5656
scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent';
57+
58+
/**
59+
* Behavior for minimizing the tab bar. (iOS 26+)
60+
*/
61+
minimizeBehavior?: 'automatic' | 'onScrollDown' | 'onScrollUp' | 'never';
5762
/**
5863
* Active tab color.
5964
*/

packages/react-native-bottom-tabs/src/TabViewNativeComponent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface TabViewProps extends ViewProps {
5252
disablePageAnimations?: boolean;
5353
activeIndicatorColor?: ColorValue;
5454
hapticFeedbackEnabled?: boolean;
55+
minimizeBehavior?: string;
5556
fontFamily?: string;
5657
fontWeight?: string;
5758
fontSize?: Int32;

0 commit comments

Comments
 (0)