chore: add example for pop to top on tab press

This commit is contained in:
satyajit.happy
2019-08-28 21:28:18 +02:00
parent f9e8c7e80f
commit d72a96d1ef
3 changed files with 26 additions and 8 deletions

View File

@@ -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}

View File

@@ -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}

View File

@@ -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}