forked from react-navigation/react-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add tabview examples to main example app
- Loading branch information
Showing
70 changed files
with
401 additions
and
23,361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import type { ParamListBase } from '@react-navigation/native'; | ||
import { | ||
createStackNavigator, | ||
StackScreenProps, | ||
} from '@react-navigation/stack'; | ||
import * as React from 'react'; | ||
import { ScrollView } from 'react-native'; | ||
import { List } from 'react-native-paper'; | ||
|
||
import AutoWidthTabBar from './TabView/AutoWidthTabBar'; | ||
import Coverflow from './TabView/Coverflow'; | ||
import CustomIndicator from './TabView/CustomIndicator'; | ||
import CustomTabBar from './TabView/CustomTabBar'; | ||
import ScrollableTabBar from './TabView/ScrollableTabBar'; | ||
import TabBarIcon from './TabView/TabBarIcon'; | ||
|
||
const EXAMPLE_SCREENS = { | ||
ScrollableTabBar, | ||
AutoWidthTabBar, | ||
TabBarIcon, | ||
CustomIndicator, | ||
CustomTabBar, | ||
Coverflow, | ||
} as const; | ||
|
||
const EXAMPLE_SCREEN_NAMES = Object.keys( | ||
EXAMPLE_SCREENS | ||
) as (keyof typeof EXAMPLE_SCREENS)[]; | ||
|
||
export type TabViewStackParams = { | ||
[Key in keyof typeof EXAMPLE_SCREENS]: undefined; | ||
} & { | ||
ExampleList: undefined; | ||
}; | ||
|
||
const TabViewStack = createStackNavigator<TabViewStackParams>(); | ||
|
||
const ExampleListScreen = ({ | ||
navigation, | ||
}: StackScreenProps<TabViewStackParams, 'ExampleList'>) => { | ||
return ( | ||
<ScrollView> | ||
{EXAMPLE_SCREEN_NAMES.map((name) => ( | ||
<List.Item | ||
key={name} | ||
testID={name} | ||
title={EXAMPLE_SCREENS[name].options.title} | ||
onPress={() => { | ||
navigation.navigate(name); | ||
}} | ||
/> | ||
))} | ||
</ScrollView> | ||
); | ||
}; | ||
|
||
export default function TabViewStackScreen({ | ||
navigation, | ||
}: StackScreenProps<ParamListBase>) { | ||
React.useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
headerShown: false, | ||
}); | ||
}, [navigation]); | ||
|
||
return ( | ||
<TabViewStack.Navigator | ||
screenOptions={{ headerMode: 'screen', cardStyle: { flex: 1 } }} | ||
> | ||
<TabViewStack.Screen | ||
name="ExampleList" | ||
component={ExampleListScreen} | ||
options={{ | ||
title: 'TabView Examples', | ||
}} | ||
/> | ||
{EXAMPLE_SCREEN_NAMES.map((name) => { | ||
return ( | ||
<TabViewStack.Screen | ||
key={name} | ||
name={name} | ||
component={EXAMPLE_SCREENS[name]} | ||
options={EXAMPLE_SCREENS[name].options} | ||
/> | ||
); | ||
})} | ||
</TabViewStack.Navigator> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.