React Navigation + react-navigation-material-bottom-tabs - react-native

I am trying to create an app that has a bottom navigation tab with the four screen tab menu. I want to have another page for Admin but the menu option should not appear on the bottom tab. ( I have a to go to that page) I am using react-navigation-material-bottom-tabs to create the bottom tab bar.
I need a way to go to that page.
export default createMaterialBottomTabNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions: {
title: "Home",
tabBarLabel: <Text style={{ color: "white" }}>Home</Text>,
barStyle: { backgroundColor: "#281b39" },
tabBarIcon: <Icon size={24} name="home" style={{ color: "white" }} />
}
},
Announcement: {
screen: AnnouncementScreen,
navigationOptions: {
title: "Announcement",
tabBarLabel: <Text style={{ color: "white" }}>Announcements</Text>,
barStyle: { backgroundColor: "#0e141d" },
tabBarIcon: (
<Icon size={24} name="bullhorn" style={{ color: "white" }} />
)
}
},
Material: {
screen: MaterialScreen,
navigationOptions: {
title: "Materials",
tabBarLabel: <Text style={{ color: "white" }}>Materials</Text>,
barStyle: { backgroundColor: "#E64A19" },
tabBarIcon: (
<Icon size={24} name="calendar" style={{ color: "white" }} />
)
}
},
Contact: {
screen: ContactScreen,
navigationOptions: {
title: "Contact",
tabBarLabel: <Text style={{ color: "white" }}>Contact</Text>,
barStyle: { backgroundColor: "#524365" },
tabBarIcon: (
<Icon size={24} name="comments" style={{ color: "white" }} />
)
}
}, },
{
shifting: true,
labeled: true } );
Here is an updated version
import React, { Component } from "react";
import { AppRegistry, Text, View, StatusBar } from "react-native";
import Icon from "react-native-vector-icons/FontAwesome";
import { createStackNavigator, createAppContainer } from "react-navigation";
import { createMaterialBottomTabNavigator } from "react-navigation-material-bottom-tabs";
import Home from "./app/components/home.js";
import Announcements from "./app/components/announcements.js";
import Contact from "./app/components/contact.js";
import BackgroundImage from "./app/components/BackgroundImage.js";
class HomeScreen extends Component {
render() {
return (
<BackgroundImage>
<StatusBar hidden={true} />
<Home />
</BackgroundImage>
);
}
}
class AnnouncementScreen extends Component {
render() {
return (
<Announcements>
<StatusBar hidden={true} />
</Announcements>
);
}
}
class MaterialScreen extends Component {
render() {
return (
<View>
<Text style={{ textAlign: "center", top: 200 }}>
This is going to be the Materials Screen
</Text>
</View>
);
}
}
class ContactScreen extends Component {
render() {
return <Contact />;
}
}
class AdminPage extends Component {
render() {
return <Text>Hi</Text>;
}
}
const Admins = {
Admin: {
screen: AdminPage
}
};
const ContactStack = createStackNavigator({
Contact: {
screen: ContactScreen
},
...Admins
});
const AppNavigator = createMaterialBottomTabNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions: {
title: "Home",
tabBarLabel: <Text style={{ color: "white" }}>Home</Text>,
barStyle: { backgroundColor: "#281b39" },
tabBarIcon: <Icon size={24} name="home" style={{ color: "white" }} />
}
},
Announcement: {
screen: AnnouncementScreen,
navigationOptions: {
title: "Announcement",
tabBarLabel: <Text style={{ color: "white" }}>Announcements</Text>,
barStyle: { backgroundColor: "#0e141d" },
tabBarIcon: (
<Icon size={24} name="bullhorn" style={{ color: "white" }} />
)
}
},
Material: {
screen: MaterialScreen,
navigationOptions: {
title: "Materials",
tabBarLabel: <Text style={{ color: "white" }}>Materials</Text>,
barStyle: { backgroundColor: "#E64A19" },
tabBarIcon: (
<Icon size={24} name="calendar" style={{ color: "white" }} />
)
}
},
Contact: {
screen: ContactStack,
navigationOptions: {
title: "Contact",
tabBarLabel: <Text style={{ color: "white" }}>Contact</Text>,
barStyle: { backgroundColor: "#524365" },
tabBarIcon: (
<Icon size={24} name="comments" style={{ color: "white" }} />
)
}
}
},
{
shifting: true,
labeled: true
}
);
const App = createAppContainer(AppNavigator);
export default App;

You can make use of a StackNavigator to go to a new screen.
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
import { createMaterialBottomTabNavigator } from "react-navigation-material-bottom-tabs";
class Home extends React.Component {
render() {
const { navigation } = this.props;
return (
<View style={styles.container}>
<Text onPress={() => navigation.navigate("Admin")}>Home</Text>
</View>
);
}
}
class Announcement extends React.Component {
render() {
const { navigation } = this.props;
return (
<View style={styles.container}>
<Text onPress={() => navigation.navigate("Admin")}>Announcement</Text>
</View>
);
}
}
class Material extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Material</Text>
</View>
);
}
}
class Contact extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Contact</Text>
</View>
);
}
}
class Admin extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Admin</Text>
</View>
);
}
}
const commonScreens = {
Admin: {
screen: Admin
}
};
const HomeStack = createStackNavigator({
Home: {
screen: Home
},
...commonScreens
});
const AnnouncementStack = createStackNavigator({
Announcement: {
screen: Announcement
},
...commonScreens
});
const AppNavigator = createMaterialBottomTabNavigator(
{
Home: { screen: HomeStack },
Announcement: { screen: AnnouncementStack },
Material: { screen: Material },
Contact: { screen: Contact }
},
{
initialRouteName: "Home",
activeColor: "#f0edf6",
barStyle: { backgroundColor: "#694fad" },
labeled: true
}
);
export default createAppContainer(AppNavigator);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
There are options for removing the header as well.
For more information please have a look at the docs https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig

Related

React Native -- Even after imports and exports are correct getting error "The component for route 'Menu' must be a react component"

I have encountered the mentioned error. I searched for this through different links as. I changed import and export according to the answer to this question but the same error is still there. I have done imports and exports correctly.*
This is
MainComponent.js file where the Menu component is imported.
import React, { Component } from 'react';
import Menu from './MenuComponent';
import Dishdetail from './DishDetailComponent';
import Contact from './ContactComponent';
import About from './AboutComponent';
import Home from './HomeComponent';
import { View, Platform, Image, StyleSheet, ScrollView, Text } from 'react-native';
import { createStackNavigator, createDrawerNavigator, DrawerItems, SafeAreaView, SrollView } from 'react-navigation';
import { Icon } from 'react-native-elements';
import { connect } from 'react-redux';
import { fetchDishes, fetchComments, fetchPromos, fetchLeaders } from '../redux/ActionCreators';
const mapStateToProps = (state) => {
return {
dishes: state.dishes,
promotions: state.promotions,
leaders: state.leaders,
};
};
const mapDispatchToProps = (dispatch) => ({
fetchDishes: () => dispatch(fetchDishes()),
fetchComments: () => dispatch(fetchComments()),
fetchPromos: () => dispatch(fetchPromos()),
fetchLeaders: () => dispatch(fetchLeaders()),
});
const MenuNavigator = createStackNavigator(
{
Menu: {
screen: Menu,
navigationOptions: ({ navigation }) => ({
headerLeft: <Icon name="menu" size={24} color="#fff" onPress={() => navigation.toggleDrawer()} />,
}),
},
Dishdetail: { screen: Dishdetail },
},
{
initialRouteName: 'Menu',
navigationOptions: {
headerStyle: {
backgroundColor: '#512DA8',
},
headerTintColor: '#fff',
headerTitleStyle: {
color: '#fff',
},
},
}
);
const HomeNavigator = createStackNavigator(
{
Home: { screen: Home },
},
{
navigationOptions: ({ navigation }) => ({
headerStyle: {
backgroundColor: '#512DA8',
},
headerTintColor: '#fff',
headerTitleStyle: {
color: '#fff',
},
headerLeft: <Icon name="menu" size={24} color="#fff" onPress={() => navigation.toggleDrawer()} />,
}),
}
);
const ContactNavigator = createStackNavigator(
{
Contact: { screen: Contact },
},
{
navigationOptions: ({ navigation }) => ({
headerStyle: {
backgroundColor: '#512DA8',
},
headerTintColor: '#fff',
headerTitleStyle: {
color: '#fff',
},
headerLeft: <Icon name="menu" size={24} color="#fff" onPress={() => navigation.toggleDrawer()} />,
}),
}
);
const AboutNavigator = createStackNavigator(
{
About: { screen: About },
},
{
navigationOptions: ({ navigation }) => ({
headerStyle: {
backgroundColor: '#512DA8',
},
headerTintColor: '#fff',
headerTitleStyle: {
color: '#fff',
},
headerLeft: <Icon name="menu" size={24} color="#fff" onPress={() => navigation.toggleDrawer()} />,
}),
}
);
const CustomDrawerContentComponent = (props) => (
<ScrollView>
<SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<View style={styles.drawerHeader}>
<View style={{ flex: 1 }}>
<Image source={require('./images/logo.png')} style={styles.drawerImage} />
</View>
<View style={{ flex: 2 }}>
<Text style={styles.drawerHeaderText}>VangooApp</Text>
</View>
</View>
<DrawerItems {...props} />
</SafeAreaView>
</ScrollView>
);
const MainNavigator = createDrawerNavigator(
{
Home: {
screen: HomeNavigator,
navigationOptions: {
title: 'Home',
drawerLabel: 'Home',
drawerIcon: ({ tintColor }) => <Icon name="home" type="font-awesome" size={24} color={tintColor} />,
},
},
About: {
screen: AboutNavigator,
navigationOptions: {
title: 'About',
drawerLabel: 'About Us',
drawerIcon: ({ tintColor }) => (
<Icon name="info-circle" type="font-awesome" size={24} color={tintColor} />
),
},
},
Menu: {
screen: MenuNavigator,
navigationOptions: {
title: 'Menu',
drawerLabel: 'Menu',
drawerIcon: ({ tintColor }) => <Icon name="list" type="font-awesome" size={24} color={tintColor} />,
},
},
Contact: {
screen: ContactNavigator,
navigationOptions: {
title: 'Contact',
drawerLabel: 'Contact Us',
drawerIcon: ({ tintColor }) => (
<Icon name="address-card" type="font-awesome" size={22} color={tintColor} />
),
},
},
},
{
drawerBackgroundColor: '#D1C4E9',
contentComponent: CustomDrawerContentComponent,
}
);
class MainComponent extends Component {
componentDidMount() {
this.props.fetchDishes();
this.props.fetchComments();
this.props.fetchPromos();
this.props.fetchLeaders();
}
render() {
return (
<View style={{ flex: 1, paddingTop: Platform.OS === 'ios' ? 0 : Expo.Constants.statusBarHeight }}>
<MainNavigator />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
drawerHeader: {
backgroundColor: '#512DA8',
height: 140,
alignItems: 'center',
justifyContent: 'center',
flex: 1,
flexDirection: 'row',
},
drawerHeaderText: {
color: '#fff',
fontSize: 24,
fontWeight: 'bold',
},
drawerImage: {
margin: 10,
width: 80,
height: 60,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(MainComponent);
MenuComponent.js
import React, { Component } from 'react';
import { FlatList } from 'react-native';
import { Tile } from 'react-native-elements';
import { connect } from 'react-redux';
import { baseUrl } from '../shared/baseURL';
const mapStateToProps = (state) => {
return {
dishes: state.dishes,
};
};
class Menu extends Component {
static navigationOptions = {
title: 'Menu',
};
render() {
const renderMenuItem = ({ item, index }) => {
return (
<Tile
key={index}
title={item.name}
caption={item.description}
featured
onPress={() => navigate('Dishdetail', { dishId: item.id })}
imageSrc={{ uri: baseUrl + item.image }}
/>
);
};
const { navigate } = this.props.navigation;
return (
<FlatList
data={this.props.dishes.dishes}
renderItem={renderMenuItem}
keyExtractor={(item) => item.id.toString()}
/>
);
}
}
export default connect(mapStateToProps)(Menu);
[![Error][1]][1]

How do I solve this: 'TypeError: undefined is not an object (evaluating '_this.props.navigationProps.toggleDrawer')'

A few days into React-Native, I am trying to implement a navigation drawer in my app.
However, I am not able to solve the error TypeError: undefined is not an object (evaluating '_this.props.navigationProps.toggleDrawer') when I tap the TouchableOpacity component that should trigger the drawer.
Following is the code I have used:
Header.js
import React, { Component } from 'react';
import { View, StyleSheet, Image, TouchableOpacity, Platform } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createDrawerNavigator } from 'react-navigation-drawer';
import { createStackNavigator } from 'react-navigation-stack';
import Screen1 from '../pages/screen1';
import Screen2 from '../pages/screen2';
import Screen3 from '../pages/screen3';
import logo from '../assets/logo.png';
import profileView from '../assets/profileIcon.png';
import menuDots from '../assets/3DotsMenu.png';
import { StatusBarHeight } from '../components/StatusBarHeight';
const statusBarHeight = StatusBarHeight
class Header extends Component {
toggleDrawer = () => {
this.props.navigationProps.toggleDrawer();
};
render() {
return (
<View>
<CreateDrawer />
<View style={styles.header} />
<View style={styles.headerContainer}>
<View style={styles.imageHolder}>
<TouchableOpacity
activeOpacity={0.6}
onPress={this.toggleDrawer.bind(this)}
>
<View>
<Image style={styles.menu} source={menuDots} />
</View>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.6}>
<View>
<Image style={styles.logo} source={logo} />
</View>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.6}>
<View>
<Image style={styles.profile} source={profileView} />
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
};
}
const FirstActivity_StackNavigator = createStackNavigator({
First: {
screen: Screen1,
navigationOptions: ({ navigation }) => ({
title: 'Demo Screen 1',
headerLeft: () => <Header navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#FF9800',
},
headerTintColor: '#fff',
}),
},
}
,
{
headerMode: "none"
}
);
const Screen2_StackNavigator = createStackNavigator({
Second: {
screen: Screen2,
navigationOptions: ({ navigation }) => ({
title: 'Demo Screen 2',
headerLeft: () => <Header navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#FF9800',
},
headerTintColor: '#fff',
}),
},
},
{
headerMode: "none"
}
);
const Screen3_StackNavigator = createStackNavigator({
Third: {
screen: Screen3,
navigationOptions: ({ navigation }) => ({
title: 'Demo Screen 3',
headerLeft: () => <Header navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#FF9800',
},
headerTintColor: '#fff',
}),
},
});
const DrawerNavigator = createDrawerNavigator({
Screen1: {
screen: FirstActivity_StackNavigator,
navigationOptions: {
drawerLabel: 'Demo Screen 1',
},
},
Screen2: {
screen: Screen2_StackNavigator,
navigationOptions: {
drawerLabel: 'Demo Screen 2',
},
},
Screen3: {
screen: Screen3_StackNavigator,
navigationOptions: {
drawerLabel: 'Demo Screen 3',
},
},
});
const styles = StyleSheet.create({
header: {
width: '100%',
height: statusBarHeight,
backgroundColor: '#E6E3E2',
flexDirection: 'row',
},
headerContainer: {
height: 60,
backgroundColor: '#E6E3E2',
justifyContent: 'center',
alignItems: 'center'
},
imageHolder: {
flexDirection: "row",
justifyContent: 'space-between',
width: '95%'
},
menu: {
marginTop: 15,
width: 27,
height: 19,
resizeMode: "stretch"
},
logo: {
width: 140,
height: Platform.OS === 'ios' ? 50 : 50,
},
profile: {
marginTop: 3,
height: 38,
width: 35
}
});
const CreateDrawer = createAppContainer(DrawerNavigator);
export default Header;
App.js
import React, { Component } from "react";
import { StyleSheet, Text, View } from "react-native";
import Header from './components/Header';
export default class App extends Component {
render() {
return (
<View style={{flex:1}} >
<View style={{backgroundColor: 'blue'}}>
<Header />
</View>
</View>
);
}
}
Use export default withNavigation(Header); while exporting for a stack of navigations.

How to show footer in full screen

I have a footer that contains several buttons that I want to show in full screen. I'm using below code:
**//App.js**
export default class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={{flex: 1, backgroundColor: '#6ED4C8'}}>
<AppNavigator />
<View style={{flexDirection: 'row'}}>
<Footer />
</View>
</View>
);
}
}
**//AppNavigator.js**
const AppNavigator = createStackNavigator(
{
Home: {screen: Home},
Friends: {screen: Friends},
Login: {screen: Login},
PostDatiles: {screen: PostDatiles},
Aboutus: {screen: Aboutus},
Footer: {screen: Footer},
},
{
headerMode: 'none',
navigationOptions: {
headerVisible: false,
},
// ,initialRouteName: ''
},
);
export default AppNavigator;
**//Footer.js**
export default class Footer extends React.Component {
constructor(props) {
super(props);
}
render() {
const {navigation} = this.props;
return (
<View style={styles.container}>
<View>
<Button
title="About us"
color="#39F80F"
accessibilityLabel="Tap on Me"
onPress={() => navigation.navigate('Login')}
/>
</View>
<View>
<Button
title="Login"
color="#F8380F"
accessibilityLabel="Tap on Me"
/>
</View>
<View>
<Button
title="Search"
color="#B80FF8"
accessibilityLabel="Tap on Me"
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
},
});
When I click on one of the buttons, I get this error:
enter image description here
In the app.js file I use a footer tag because I want show it on all of the screen.
I searched a lot but couldn't find any similar problem!
To do what you want to do, you must use the createBottomTabNavigator instead of the StackNavigator.
Example
import React from 'react';
import { Text, View } from 'react-native';
import { Ionicons } from '#expo/vector-icons'; // 6.2.2
import { createBottomTabNavigator, createAppContainer } from 'react-navigation';
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Home!</Text>
</View>
);
}
}
class SettingsScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings!</Text>
</View>
);
}
}
class IconWithBadge extends React.Component {
render() {
const { name, badgeCount, color, size } = this.props;
return (
<View style={{ width: 24, height: 24, margin: 5 }}>
<Ionicons name={name} size={size} color={color} />
{badgeCount > 0 && (
<View
style={{
// /If you're using react-native < 0.57 overflow outside of the parent
// will not work on Android, see https://git.io/fhLJ8
position: 'absolute',
right: -6,
top: -3,
backgroundColor: 'red',
borderRadius: 6,
width: 12,
height: 12,
justifyContent: 'center',
alignItems: 'center',
}}>
<Text style={{ color: 'white', fontSize: 10, fontWeight: 'bold' }}>
{badgeCount}
</Text>
</View>
)}
</View>
);
}
}
const HomeIconWithBadge = props => {
// You should pass down the badgeCount in some other ways like context, redux, mobx or event emitters.
return <IconWithBadge {...props} badgeCount={3} />;
};
const getTabBarIcon = (navigation, focused, tintColor) => {
const { routeName } = navigation.state;
let IconComponent = Ionicons;
let iconName;
if (routeName === 'Home') {
iconName = `ios-information-circle${focused ? '' : '-outline'}`;
// We want to add badges to home tab icon
IconComponent = HomeIconWithBadge;
} else if (routeName === 'Settings') {
iconName = `ios-options${focused ? '' : '-outline'}`;
}
// You can return any component that you like here!
return <IconComponent name={iconName} size={25} color={tintColor} />;
};
export default createAppContainer(
createBottomTabNavigator(
{
Home: { screen: HomeScreen },
Settings: { screen: SettingsScreen },
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) =>
getTabBarIcon(navigation, focused, tintColor),
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
},
}
)
);

How to display both Bottom Navigator and Drawer Navigator in React Native

I am new to React Native. I want to build Bottom Navigator and Drawer Navigation. I used the below code, I am unable to navigate to the page from Drawer Menu. I am able to navigate to the page from Tab Navigator.
In the code both Drawer Navigator and Tab Navigator Screens are different.
import React, { Component } from "react";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import Icon from "#expo/vector-icons/Ionicons";
import {
createAppContainer,
createDrawerNavigator,
createBottomTabNavigator,
createStackNavigator
} from "react-navigation";
import { Constants } from "expo";
const DrawerMenuItems = [
{
title: "Login",
icon: "ios-home",
navigateTo: "Login"
},
{
title: "Feedback",
icon: "ios-home",
navigateTo: "Feedback"
},
{
title: "Help",
icon: "ios-help",
navigateTo: "Help"
}
];
export default class App extends React.Component {
render() {
return <AppContainer />;
}
}
class HomeScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>HomeScreen</Text>
</View>
);
}
}
class ContactScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>ContactScreen</Text>
</View>
);
}
}
class AboutScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>AboutScreen</Text>
</View>
);
}
}
class LoginScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>LoginScreen</Text>
</View>
);
}
}
class FeedbackScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>FeedbackScreen</Text>
</View>
);
}
}
class HelpScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>HelpScreen</Text>
</View>
);
}
}
class HamburgerMenu extends Component {
constructor(props) {
super(props);
}
renderMenu(menuItems) {
{
return menuItems.map((item, index) => {
return (
<View style={{ width: "100%" }} key={index}>
<View style={styles.sideMenuItem}>
<TouchableOpacity
style={styles.sideMenuIcon}
onPress={() => {
this.props.navigation.navigate(item.navigateTo);
}}
>
<Icon name={item.icon} size={30} />
</TouchableOpacity>
<Text
style={styles.menuText}
onPress={() => {
this.props.navigation.navigate(item.navigateTo);
}}
>
{item.title}
</Text>
</View>
</View>
);
});
}
}
render() {
return (
<View style={styles.sideMenuContainer}>
{this.renderMenu(DrawerMenuItems)}
</View>
);
}
}
const DrawerButton = ({ navigation }) => (
<TouchableOpacity onPress={() => navigation.openDrawer()}>
<Icon style={styles.menuIcon} name="md-menu" size={30} />
</TouchableOpacity>
);
const BottomTabsNavigator = createBottomTabNavigator(
{
Home: HomeScreen,
Contact: ContactScreen,
About: AboutScreen
},
{
tabBarOptions: {
activeTintColor: "#000",
inactiveTintColor: "gray",
style: {
backgroundColor: "#fff"
},
indicatorStyle: {
backgroundColor: "#000"
}
}
}
);
const AppDrawNavigator = createDrawerNavigator(
{
Main: { screen: BottomTabsNavigator }
},
{
contentComponent: HamburgerMenu,
drawerPosition: "right"
}
);
const AppStackNavigator = createStackNavigator(
{
MainDrawNavigator: {
screen: AppDrawNavigator
}
},
{
defaultNavigationOptions: ({ navigation }) => {
return {
header: (
<View style={styles.header}>
<DrawerButton navigation={navigation} />
</View>
),
headerStyle: {
height: 60
}
};
}
}
);
const AppContainer = createAppContainer(AppStackNavigator);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
sideMenuContainer: {
width: "100%",
height: "100%",
backgroundColor: "#fff",
alignItems: "center",
paddingTop: 20
},
sideMenuProfileIcon: {
resizeMode: "center",
width: 150,
height: 150,
borderRadius: 150 / 2
},
sideMenuIcon: {
resizeMode: "center",
width: 28,
height: 28,
marginRight: 10,
marginLeft: 20
},
menuIcon: {
left: 10
},
menuText: {
fontSize: 15,
color: "#222222"
},
header: {
paddingTop: Constants.statusBarHeight,
backgroundColor: "#e1e8ee",
flexDirection: "row"
}
});
Kindly help on this.

showing navigation bottom bar in screens which are not part of bottom tabs in react native

I have three tabs and 8 screens in react native app. I have created bottom tab navigator as follows and I have 5 more screens which i dont want in tabs but on those screens the normal three tabs bottom bar navigator is required. Exact help is appreciated.
const TabNavigation = createBottomTabNavigator(
{
Scan: {
screen: ScanScreen,
navigationOptions: {
tabBarLabel: 'Scan',
tabBarIcon: () => <Ionicons name="ios-qr-scanner-outline" size={32} color="blue" />
,
},
},
Patient: {
screen: PatientStack,
navigationOptions: {
tabBarLabel: 'Patients',
tabBarIcon: () => <Ionicons name="ios-people" size={32} color="blue" />
,
},
},
Setting: {
screen: SettingScreen,
navigationOptions: {
tabBarLabel: 'Setting',
tabBarIcon: () => <Ionicons name="ios-settings" size={32} color="blue" />
,
},
},
},
{
lazyLoad: true,
animationEnabled: false,
tabBarPosition: 'bottom',
tabBarOptions: {
showIcon: true,
showLabel: true,
activeTintColor: '#7117ea',
inactiveTintColor: '#7117ea',
style: {
backgroundColor: '#eff0f1'
},
iconStyle: {
width: 40
},
tabStyle: {
height: 60
}
},
},
);
This is an Example code which will solve your problem (Hope so)
In this there are three scenes and in bottom bar two screens are rendered and the third scenes is rendered after clicking a link but the bottom bar will be there.
import React from 'react';
import { Button, Text, View } from 'react-native';
import { Ionicons } from '#expo/vector-icons';
import { createStackNavigator, createBottomTabNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Home!</Text>
<Button
title="Go to Settings"
onPress={() => this.props.navigation.navigate('Settings')}
/>
<Button
title="Go to Details"
onPress={() => this.props.navigation.navigate('Details')}
/>
</View>
);
}
}
class SettingsScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress={() => this.props.navigation.navigate('Home')}
/>
<Button
title="Go to Details"
onPress={() => this.props.navigation.navigate('Details')}
/>
</View>
);
}
}
class DetailsScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Details!</Text>
</View>
);
}
}
const HomeStack = createStackNavigator({
Home: { screen: HomeScreen },
Details: { screen: DetailsScreen },
});
const SettingsStack = createStackNavigator({
Settings: { screen: SettingsScreen },
Details: { screen: DetailsScreen },
});
export default createBottomTabNavigator(
{
Home: { screen: HomeStack },
Settings: { screen: SettingsStack },
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Home') {
iconName = `ios-information-circle${focused ? '' : '-outline'}`;
} else if (routeName === 'Settings') {
iconName = `ios-options${focused ? '' : '-outline'}`;
}
// You can return any component that you like here! We usually use an
// icon component from react-native-vector-icons
return <Ionicons name={iconName} size={25} color={tintColor} />;
},
}),
tabBarOptions: {
activeTintColor: 'red',
inactiveTintColor: 'gray',
},
}
);