Skip to content

Commit 156d957

Browse files
kkafarclaude
andauthored
refactor(example): rename leftover symbols mentioning "bottom tabs" (#3756)
## Description This PR renames leftover `BottomTabs` references to `Tabs`. ## Changes * Rename the `BottomTabsContainer` example implementation to `TabsContainer`. * **Leave tests cases such as `TestBottomTabs` unmodified**. [Explanation](c6eb0f6) * Rename appropriate directories in example apps.] * Rename many components. Closes <software-mansion/react-native-screens-labs#783> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
1 parent 4fc6f97 commit 156d957

44 files changed

Lines changed: 497 additions & 398 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FabricExample/e2e/example-tests/nativeBottomTabs.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { device, expect, element, by } from 'detox';
22
import { selectIssueTestScreen } from '../e2e-utils';
33

4-
describe('Native BottomTabs', () => {
4+
describe('Native tabs', () => {
55
beforeAll(async () => {
66
await device.reloadReactNative();
77
});

apps/src/shared/gamma/containers/bottom-tabs/ConfigWrapperContext.tsx renamed to apps/src/shared/gamma/containers/tabs/ConfigWrapperContext.tsx

File renamed without changes.

apps/src/shared/gamma/containers/bottom-tabs/BottomTabsContainer.tsx renamed to apps/src/shared/gamma/containers/tabs/TabsContainer.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ import ConfigWrapperContext from './ConfigWrapperContext';
1212
import { RNSLog } from 'react-native-screens/private';
1313

1414
export interface TabConfiguration {
15-
tabScreenProps: TabsScreenProps;
15+
options: TabsScreenProps;
1616
component: React.ComponentType;
1717
safeAreaConfiguration?: SafeAreaViewProps;
1818
}
1919

20-
export type BottomTabsContainerProps = TabsHostProps & {
20+
export type TabsContainerProps = TabsHostProps & {
2121
tabConfigs: TabConfiguration[];
2222
};
2323

24-
export function BottomTabsContainer(props: BottomTabsContainerProps) {
25-
RNSLog.info('BottomTabsContainer render');
24+
export function TabsContainer(props: TabsContainerProps) {
25+
RNSLog.info('TabsContainer render');
2626

2727
const { tabConfigs, ...restProps } = props;
2828

2929
const [focusedScreenKey, setFocusedScreenKey] = React.useState<string>(() => {
30-
RNSLog.log('BottomTabsContainer focusedStateKey initial state computed');
30+
RNSLog.log('TabsContainer focusedStateKey initial state computed');
3131

3232
if (props.tabConfigs.length === 0) {
3333
throw new Error('There must be at least one tab defined');
3434
}
3535

3636
const maybeUserRequestedFocusedTab = tabConfigs.find(
37-
tabConfig => tabConfig.tabScreenProps.isFocused === true,
38-
)?.tabScreenProps.screenKey;
37+
tabConfig => tabConfig.options.isFocused === true,
38+
)?.options.screenKey;
3939

4040
if (maybeUserRequestedFocusedTab != null) {
4141
return maybeUserRequestedFocusedTab;
4242
}
4343

4444
// Default to first tab
45-
return tabConfigs[0].tabScreenProps.screenKey;
45+
return tabConfigs[0].options.screenKey;
4646
});
4747

4848
const configWrapper = React.useContext(ConfigWrapperContext);
@@ -77,27 +77,26 @@ export function BottomTabsContainer(props: BottomTabsContainerProps) {
7777

7878
return (
7979
<Tabs.Host
80-
// Use controlled bottom tabs by default, but allow to overwrite if user wants to
80+
// Use controlled tabs by default, but allow to overwrite if user wants to
8181
onNativeFocusChange={onNativeFocusChangeCallback}
8282
experimentalControlNavigationStateInJS={
8383
configWrapper.config.controlledBottomTabs
8484
}
8585
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
8686
{...restProps}>
8787
{tabConfigs.map(tabConfig => {
88-
const screenKey = tabConfig.tabScreenProps.screenKey;
89-
const isFocused =
90-
tabConfig.tabScreenProps.screenKey === focusedScreenKey;
88+
const screenKey = tabConfig.options.screenKey;
89+
const isFocused = tabConfig.options.screenKey === focusedScreenKey;
9190
RNSLog.info(
92-
`BottomTabsContainer map to component -> ${screenKey} ${
91+
`TabsContainer map to component -> ${screenKey} ${
9392
isFocused ? '(focused)' : ''
9493
}`,
9594
);
9695

9796
return (
9897
<Tabs.Screen
9998
key={screenKey}
100-
{...tabConfig.tabScreenProps}
99+
{...tabConfig.options}
101100
isFocused={isFocused} // notice that the value passed by user is overriden here!
102101
>
103102
{getContent(tabConfig)}

apps/src/tests/component-integration-tests/orientation/orientation-stack-in-tabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ function ConfigScreen() {
4545
label="Tab Screen orientation"
4646
items={['portrait', 'landscape', 'undefined']}
4747
value={
48-
findTabScreenOptions(tabsConfig, 'Tab1')?.tabScreenProps
49-
.orientation ?? 'undefined'
48+
findTabScreenOptions(tabsConfig, 'Tab1')?.options.orientation ??
49+
'undefined'
5050
}
5151
onValueChange={value =>
5252
tabsDispatch({
5353
type: 'tabScreen',
5454
screenKey: 'Tab1',
5555
config: {
56-
tabScreenProps: {
56+
options: {
5757
orientation: value === 'undefined' ? undefined : value,
5858
},
5959
},

apps/src/tests/component-integration-tests/orientation/orientation-tabs-in-stack.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ function ConfigScreen() {
5959
label="Tab Screen orientation"
6060
items={['portrait', 'landscape', 'undefined']}
6161
value={
62-
findTabScreenOptions(tabsConfig, 'Tab1')?.tabScreenProps
63-
.orientation ?? 'undefined'
62+
findTabScreenOptions(tabsConfig, 'Tab1')?.options.orientation ??
63+
'undefined'
6464
}
6565
onValueChange={value =>
6666
tabsDispatch({
6767
type: 'tabScreen',
6868
screenKey: 'Tab1',
6969
config: {
70-
tabScreenProps: {
70+
options: {
7171
orientation: value === 'undefined' ? undefined : value,
7272
},
7373
},

apps/src/tests/issue-tests/Test3168.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import { SearchBarPlacement, SearchBarProps } from 'react-native-screens';
1919
import { ListItem, SettingsPicker, SettingsSwitch } from '../../shared';
2020
import { CenteredLayoutView } from '../../shared/CenteredLayoutView';
2121
import {
22-
BottomTabsContainer,
22+
TabsContainer,
2323
TabConfiguration,
24-
} from '../../shared/gamma/containers/bottom-tabs/BottomTabsContainer';
24+
} from '../../shared/gamma/containers/tabs/TabsContainer';
2525
import ConfigWrapperContext, {
2626
Configuration,
2727
DEFAULT_GLOBAL_CONFIGURATION,
28-
} from '../../shared/gamma/containers/bottom-tabs/ConfigWrapperContext';
28+
} from '../../shared/gamma/containers/tabs/ConfigWrapperContext';
2929

3030
type NavigationProp<ParamList extends ParamListBase> = {
3131
navigation: NativeStackNavigationProp<ParamList>;
@@ -89,7 +89,7 @@ function Home({ navigation }: MainStackNavigationProp) {
8989
<Text>Test Search Bar placement</Text>
9090
<Button title="Stack only" onPress={() => navigation.push('Stack')} />
9191
<Button
92-
title="Bottom Tabs and Stack"
92+
title="Tabs and Stack"
9393
onPress={() => navigation.push('StackAndTabs')}
9494
/>
9595
</View>
@@ -201,7 +201,7 @@ function TabsStackComponent() {
201201

202202
const TAB_CONFIGS: TabConfiguration[] = [
203203
{
204-
tabScreenProps: {
204+
options: {
205205
screenKey: 'main',
206206
title: 'Main',
207207
ios: {
@@ -214,7 +214,7 @@ function TabsStackComponent() {
214214
component: () => Menu({ tabsMode: true }),
215215
},
216216
{
217-
tabScreenProps: {
217+
options: {
218218
screenKey: 'another',
219219
title: 'Another',
220220
ios: {
@@ -227,7 +227,7 @@ function TabsStackComponent() {
227227
component: AnotherTab,
228228
},
229229
{
230-
tabScreenProps: {
230+
options: {
231231
screenKey: 'examples',
232232
title: 'Search',
233233
ios: {
@@ -248,7 +248,7 @@ function TabsStackComponent() {
248248
config,
249249
setConfig,
250250
}}>
251-
<BottomTabsContainer tabConfigs={TAB_CONFIGS} />
251+
<TabsContainer tabConfigs={TAB_CONFIGS} />
252252
</ConfigWrapperContext.Provider>
253253
);
254254
}

apps/src/tests/issue-tests/Test3212/BottomTabsInStackScenario.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

apps/src/tests/issue-tests/Test3212/StackInBottomTabsScenario.tsx renamed to apps/src/tests/issue-tests/Test3212/StackInTabsScenario.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import {
55
ScrollEdgeEffectsConfigContext,
66
} from './context';
77
import { NavigationContainer } from '@react-navigation/native';
8-
import { BottomTabsContainer } from '../../../shared/gamma/containers/bottom-tabs/BottomTabsContainer';
8+
import { TabsContainer } from '../../../shared/gamma/containers/tabs/TabsContainer';
99
import { Config } from './Config';
1010
import { StackScenario } from './StackScenario';
1111
import { ScrollView } from 'react-native';
1212

13-
export function StackInBottomTabsScenario() {
13+
export function StackInTabsScenario() {
1414
const [config, setConfig] = useState<ScrollEdgeEffects>({
1515
...SCROLL_EDGE_EFFECT_DEFAULTS,
1616
});
1717

18-
// Add ScrollView for automatic insets which are missing in BottomTabsScreen
18+
// Add ScrollView for automatic insets which are missing in TabsScreen
1919
const ConfigComponent = useCallback(
2020
() => (
2121
<ScrollView>
22-
<Config title="Outer BottomTabs / scrollEdgeEffects:" />
22+
<Config title="Outer Tabs / scrollEdgeEffects:" />
2323
</ScrollView>
2424
),
2525
[],
@@ -28,20 +28,20 @@ export function StackInBottomTabsScenario() {
2828
return (
2929
<ScrollEdgeEffectsConfigContext.Provider value={{ config, setConfig }}>
3030
<NavigationContainer>
31-
<BottomTabsContainer
31+
<TabsContainer
3232
tabConfigs={[
3333
{
3434
component: ConfigComponent,
35-
tabScreenProps: { screenKey: 'config', title: 'Config' },
35+
options: { screenKey: 'config', title: 'Config' },
3636
},
3737
{
3838
component: StackScenario,
39-
tabScreenProps: {
39+
options: {
4040
screenKey: 'stack',
4141
title: 'Stack',
4242
ios: {
4343
scrollEdgeEffects: config,
44-
}
44+
},
4545
},
4646
},
4747
]}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
2+
import React, { useCallback, useState } from 'react';
3+
import {
4+
SCROLL_EDGE_EFFECT_DEFAULTS,
5+
ScrollEdgeEffects,
6+
ScrollEdgeEffectsConfigContext,
7+
} from './context';
8+
import { NavigationContainer } from '@react-navigation/native';
9+
import { ConfigWithNavigation } from './Config';
10+
import { TabsScenario } from './TabsScenario';
11+
12+
export function TabsInStackScenario() {
13+
const Stack = createNativeStackNavigator();
14+
const [config, setConfig] = useState<ScrollEdgeEffects>({
15+
...SCROLL_EDGE_EFFECT_DEFAULTS,
16+
});
17+
18+
const ConfigComponent = useCallback(
19+
() => <ConfigWithNavigation title="Outer Stack / scrollEdgeEffects:" />,
20+
[],
21+
);
22+
23+
return (
24+
<ScrollEdgeEffectsConfigContext.Provider value={{ config, setConfig }}>
25+
<NavigationContainer>
26+
<Stack.Navigator
27+
screenOptions={{
28+
autoHideHomeIndicator: true,
29+
}}>
30+
<Stack.Screen name="Config" component={ConfigComponent} />
31+
<Stack.Screen
32+
name="Test"
33+
component={TabsScenario}
34+
options={{
35+
scrollEdgeEffects: config,
36+
headerSearchBarOptions: {},
37+
headerTransparent: true,
38+
}}
39+
/>
40+
</Stack.Navigator>
41+
</NavigationContainer>
42+
</ScrollEdgeEffectsConfigContext.Provider>
43+
);
44+
}

apps/src/tests/issue-tests/Test3212/BottomTabsScenario.tsx renamed to apps/src/tests/issue-tests/Test3212/TabsScenario.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ import {
88
NavigationContainer,
99
NavigationIndependentTree,
1010
} from '@react-navigation/native';
11-
import { BottomTabsContainer } from '../../../shared/gamma/containers/bottom-tabs/BottomTabsContainer';
11+
import { TabsContainer } from '../../../shared/gamma/containers/tabs/TabsContainer';
1212
import { Config } from './Config';
1313
import { ScrollViewTemplate } from './ScrollViewTemplate';
1414
import { ScrollView } from 'react-native';
1515

1616
function ConfigComponent() {
17-
// Add ScrollView for automatic insets which are missing in BottomTabsScreen
17+
// Add ScrollView for automatic insets which are missing in TabsScreen
1818
return (
1919
<ScrollView>
2020
<Config title="Stack / scrollEdgeEffects:" />
2121
</ScrollView>
2222
);
2323
}
2424

25-
export function BottomTabsScenario() {
25+
export function TabsScenario() {
2626
const [config, setConfig] = useState<ScrollEdgeEffects>({
2727
...SCROLL_EDGE_EFFECT_DEFAULTS,
2828
});
@@ -31,20 +31,20 @@ export function BottomTabsScenario() {
3131
<NavigationIndependentTree>
3232
<ScrollEdgeEffectsConfigContext.Provider value={{ config, setConfig }}>
3333
<NavigationContainer>
34-
<BottomTabsContainer
34+
<TabsContainer
3535
tabConfigs={[
3636
{
3737
component: ConfigComponent,
38-
tabScreenProps: { screenKey: 'config', title: 'Config' },
38+
options: { screenKey: 'config', title: 'Config' },
3939
},
4040
{
4141
component: ScrollViewTemplate,
42-
tabScreenProps: {
42+
options: {
4343
screenKey: 'stack',
4444
title: 'Scroll',
4545
ios: {
4646
scrollEdgeEffects: config,
47-
}
47+
},
4848
},
4949
},
5050
]}

0 commit comments

Comments
 (0)