Skip to content

Commit 9886f0b

Browse files
committed
fix: add to legacy tabview
1 parent 430a8cc commit 9886f0b

6 files changed

Lines changed: 19 additions & 9 deletions

File tree

apps/example/src/Examples/FourTabsRTL.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Albums } from '../Screens/Albums';
55
import { Contacts } from '../Screens/Contacts';
66
import { Chat } from '../Screens/Chat';
77
import { I18nManager, type ColorValue } from 'react-native';
8-
import type { LayoutDirection } from 'react-native-bottom-tabs/src/types';
8+
import type { LayoutDirection } from 'react-native-bottom-tabs';
99

1010
interface Props {
1111
disablePageAnimations?: boolean;

apps/example/src/Examples/MaterialBottomTabs.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { createMaterialBottomTabNavigator } from 'react-native-paper/react-navigation';
32
import { Article } from '../Screens/Article';
43
import { Albums } from '../Screens/Albums';

apps/example/src/Examples/NativeBottomTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function NativeBottomTabs() {
1515
initialRouteName="Chat"
1616
labeled={true}
1717
hapticFeedbackEnabled={false}
18-
layoutDirection="leftToRight"
18+
layoutDirection="ltr"
1919
tabBarInactiveTintColor="#C57B57"
2020
tabBarActiveTintColor="#F7DBA7"
2121
tabBarStyle={{

packages/react-native-bottom-tabs/ios/TabView/LegacyTabView.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ struct LegacyTabView: AnyTabView {
77
var onSelect: (String) -> Void
88
var updateTabBarAppearance: () -> Void
99

10+
private var effectiveLayoutDirection: LayoutDirection {
11+
let dir = props.layoutDirection ?? "locale"
12+
if let mapped = ["rtl": LayoutDirection.rightToLeft,
13+
"ltr": LayoutDirection.leftToRight][dir] {
14+
return mapped
15+
}
16+
let system = UIView.userInterfaceLayoutDirection(for: .unspecified)
17+
return system == .rightToLeft ? .rightToLeft : .leftToRight
18+
}
19+
1020
@ViewBuilder
1121
var body: some View {
1222
TabView(selection: $props.selectedPage) {
@@ -19,6 +29,7 @@ struct LegacyTabView: AnyTabView {
1929
onLayout(size)
2030
}
2131
}
32+
.environment(\.layoutDirection, effectiveLayoutDirection)
2233
.hideTabBar(props.tabBarHidden)
2334
}
2435

packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ struct NewTabView: AnyTabView {
99
var onSelect: (String) -> Void
1010
var updateTabBarAppearance: () -> Void
1111

12-
@ViewBuilder
13-
var body: some View {
14-
var effectiveLayoutDirection: LayoutDirection {
12+
private var effectiveLayoutDirection: LayoutDirection {
1513
let dir = props.layoutDirection ?? "locale"
1614
if let mapped = ["rtl": LayoutDirection.rightToLeft,
1715
"ltr": LayoutDirection.leftToRight][dir] {
18-
return mapped
16+
return mapped
1917
}
2018
let system = UIView.userInterfaceLayoutDirection(for: .unspecified)
2119
return system == .rightToLeft ? .rightToLeft : .leftToRight
22-
}
20+
}
2321

22+
@ViewBuilder
23+
var body: some View {
2424
TabView(selection: $props.selectedPage) {
2525
ForEach(props.children) { child in
2626
if let index = props.children.firstIndex(of: child),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
1515
/**
1616
* Types
1717
*/
18-
export type { AppleIcon, TabRole } from './types';
18+
export type { AppleIcon, LayoutDirection, TabRole } from './types';

0 commit comments

Comments
 (0)