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/dirty-kids-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-bottom-tabs': patch
---

fix: properly handle labeled={false} on iOS
7 changes: 6 additions & 1 deletion apps/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const FourTabsActiveIndicatorColor = () => {
return <FourTabs activeIndicatorColor={'#87CEEB'} />;
};

const UnlabeledTabs = () => {
return <LabeledTabs showLabels={false} />;
};

const examples = [
{
component: ThreeTabs,
Expand All @@ -77,7 +81,8 @@ const examples = [
name: 'SF Symbols',
screenOptions: { headerShown: false },
},
{ component: LabeledTabs, name: 'Labeled Tabs', platform: 'android' },
{ component: LabeledTabs, name: 'Labeled Tabs' },
{ component: UnlabeledTabs, name: 'Unlabeled Tabs' },
{
component: NativeBottomTabsEmbeddedStacks,
name: 'Embedded stacks',
Expand Down
8 changes: 6 additions & 2 deletions apps/example/src/Examples/Labeled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Albums } from '../Screens/Albums';
import { Contacts } from '../Screens/Contacts';
import { Chat } from '../Screens/Chat';

export default function LabeledTabs() {
export default function LabeledTabs({
showLabels = true,
}: {
showLabels: boolean;
}) {
const [index, setIndex] = useState(0);
const [routes] = useState([
{
Expand Down Expand Up @@ -41,7 +45,7 @@ export default function LabeledTabs() {

return (
<TabView
labeled
labeled={showLabels}
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-bottom-tabs/ios/TabViewProps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TabViewProps: ObservableObject {
@Published var selectedPage: String?
@Published var icons: [Int: PlatformImage] = [:]
@Published var sidebarAdaptable: Bool?
@Published var labeled: Bool?
@Published var labeled: Bool = false
@Published var scrollEdgeAppearance: String?
@Published var barTintColor: PlatformColor?
@Published var activeTintColor: PlatformColor?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final class TabInfo: NSObject {
}
}

@objc public var labeled: Bool = true {
@objc public var labeled: Bool = false {
didSet {
props.labeled = labeled
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-bottom-tabs/src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
getActiveTintColor = ({ route }: { route: Route }) => route.activeTintColor,
getTestID = ({ route }: { route: Route }) => route.testID,
hapticFeedbackEnabled = false,
// Android's native behavior is to show labels when there are less than 4 tabs. We leave it as undefined to use the platform default behavior.
labeled = Platform.OS !== 'android' ? true : undefined,
tabBar: renderCustomTabBar,
tabBarStyle,
tabLabelStyle,
Expand Down Expand Up @@ -207,7 +209,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 212 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 208 column 10
}

const icons = React.useMemo(
Expand Down Expand Up @@ -300,6 +302,7 @@
inactiveTintColor={inactiveTintColor}
barTintColor={tabBarStyle?.backgroundColor}
rippleColor={rippleColor}
labeled={labeled}
>
{trimmedRoutes.map((route) => {
if (getLazy({ route }) !== false && !loaded.includes(route.key)) {
Expand All @@ -324,7 +327,7 @@
importantForAccessibility={
focused ? 'auto' : 'no-hide-descendants'
}
style={[{ position: 'absolute' }, measuredDimensions]}

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

View workflow job for this annotation

GitHub Actions / lint

Inline style: { position: 'absolute' }
>
{renderScene({
route,
Expand Down
Loading