mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
chore: add example for pop to top on tab press
This commit is contained in:
@@ -8,6 +8,7 @@ import TouchableBounce from 'react-native/Libraries/Components/Touchable/Touchab
|
||||
import Albums from '../Shared/Albums';
|
||||
import Contacts from '../Shared/Contacts';
|
||||
import Chat from '../Shared/Chat';
|
||||
import SimpleStackScreen from './SimpleStack';
|
||||
|
||||
const getTabBarIcon = (name: string) => ({
|
||||
tintColor,
|
||||
@@ -20,6 +21,7 @@ const getTabBarIcon = (name: string) => ({
|
||||
);
|
||||
|
||||
type BottomTabParams = {
|
||||
article: undefined;
|
||||
albums: undefined;
|
||||
contacts: undefined;
|
||||
chat: undefined;
|
||||
@@ -30,6 +32,18 @@ const BottomTabs = createBottomTabNavigator<BottomTabParams>();
|
||||
export default function BottomTabsScreen() {
|
||||
return (
|
||||
<BottomTabs.Navigator>
|
||||
<BottomTabs.Screen
|
||||
name="article"
|
||||
options={{
|
||||
title: 'Article',
|
||||
tabBarIcon: 'chrome-reader-mode',
|
||||
tabBarButtonComponent: TouchableBounce,
|
||||
}}
|
||||
>
|
||||
{props => (
|
||||
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
|
||||
)}
|
||||
</BottomTabs.Screen>
|
||||
<BottomTabs.Screen
|
||||
name="chat"
|
||||
component={Chat}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
|
||||
import Article from '../Shared/Article';
|
||||
import Albums from '../Shared/Albums';
|
||||
import Contacts from '../Shared/Contacts';
|
||||
import Chat from '../Shared/Chat';
|
||||
import SimpleStackScreen from './SimpleStack';
|
||||
|
||||
type MaterialBottomTabParams = {
|
||||
article: undefined;
|
||||
@@ -22,13 +22,16 @@ export default function MaterialBottomTabsScreen() {
|
||||
<MaterialBottomTabs.Navigator barStyle={styles.tabBar}>
|
||||
<MaterialBottomTabs.Screen
|
||||
name="article"
|
||||
component={Article}
|
||||
options={{
|
||||
tabBarLabel: 'Article',
|
||||
tabBarIcon: 'chrome-reader-mode',
|
||||
tabBarColor: '#C9E7F8',
|
||||
}}
|
||||
/>
|
||||
>
|
||||
{props => (
|
||||
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
|
||||
)}
|
||||
</MaterialBottomTabs.Screen>
|
||||
<MaterialBottomTabs.Screen
|
||||
name="chat"
|
||||
component={Chat}
|
||||
|
||||
@@ -72,17 +72,18 @@ const AlbumsScreen = ({
|
||||
|
||||
const SimpleStack = createStackNavigator<SimpleStackParams>();
|
||||
|
||||
export default function SimpleStackScreen({
|
||||
navigation,
|
||||
}: {
|
||||
type Props = {
|
||||
options?: React.ComponentProps<typeof SimpleStack.Navigator>;
|
||||
navigation: StackNavigationProp<ParamListBase>;
|
||||
}) {
|
||||
};
|
||||
|
||||
export default function SimpleStackScreen({ navigation, options }: Props) {
|
||||
navigation.setOptions({
|
||||
header: null,
|
||||
});
|
||||
|
||||
return (
|
||||
<SimpleStack.Navigator>
|
||||
<SimpleStack.Navigator {...options}>
|
||||
<SimpleStack.Screen
|
||||
name="article"
|
||||
component={ArticleScreen}
|
||||
|
||||
Reference in New Issue
Block a user