Pass Props from the react-redux to React Native Bottom Tab Navigation - react-native

I am struggling with the
import { createBottomTabNavigator } from 'react-navigation-tabs';
I want to pass the value of my cartItems from react redux to Bottom Navigation Icon but from no where I am able to pass the props.
Here is my code,
import React from 'react';
import { View, Text } from 'react-native';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import Icon from 'src/containers/IconTabbar';
import Home from 'src/screens/home/home';
import Cart from 'src/screens/cart/cart';
import { connect } from 'react-redux';
const Tabs = createBottomTabNavigator(
{
home: {
screen: Home,
navigationOptions: () => ({
title: 'Home',
tabBarIcon: ({ tintColor }) => <Icon name="home" color={tintColor} />,
}),
},
cart: {
screen: Cart,
navigationOptions: () => ({
title: 'Cart',
tabBarIcon: ({ tintColor }) => <View>
<View style={{ position: 'absolute', height: 20, width: 20, borderRadius: 15, backgroundColor: 'rgba(95,197,123,0.8)', right: 10, bottom: 15, alignItems: 'center', justifyContent: 'center', zIndex: 2000, }}>
//Here I want add props instead of 4 like this.props.cartItems
<Text style={{ color: 'white', fontWeight: 'bold' }}>4</Text>
</View>
<Icon name="shopping-cart" color={tintColor} />
</View>,
}),
},
},
{
defaultNavigationOptions: props => {
return {
tabBarOptions: {
style: {
height: 60,
elevation: 0,
borderTopWidth: 1,
},
activeTintColor: 'green',
inactiveTintColor: 'grey',
},
};
},
}
);
const mapStateToProps = (state) => {
return {
cartItems: state.carts.carts
}
}
export default connect(mapStateToProps)(Tabs);
Image of Static 4 Value displaying in BottomTabNavigation

You can create a separate component for the tab icon and connect it to redux.
Here is an untested example.
const TabIcon = (props) => {
return (
<View>
<View style={{
position: 'absolute', height: 20, width: 20, borderRadius: 15,
backgroundColor: 'rgba(95,197,123,0.8)', right: 10, bottom: 15, alignItems: 'center', justifyContent: 'center', zIndex: 2000,
}}>
<Text style={{ color: 'white', fontWeight: 'bold' }}>{props.cartItems}</Text>
</View>
<Icon name="shopping-cart" color={props.tintColor} />
</View >
)
}
const mapStateToProps = state => {
return {
cartItems: state.carts.carts
}
}
export default connect(mapStateToProps, null)(TabIcon)
You can then try something like:
tabBarIcon: ({ tintColor }) => (
<TabIcon tintColor={tintColor}/>
)

Related

React Native - How to set the drawer navigation content on the particular tab based on drawer item selection?

What i want to achieve is there are 2 tabs in my app
1) Home => On press it shows a simple screen
2) Menu => On press it opens and close drawer based on whether drawer is opened or not.
Drawer has custom content.
It has 4 buttons
1) Accounts
2) Reports
3) Graph
4) List
Selecting on any of the drawer item it should open a respective page in the "Menu" tab navigator space.
So how to manage this kind of navigation?
import React from 'react';
import { View, Text } from 'react-native'
import { createAppContainer, createSwitchNavigator } from 'react-navigation'
import { createStackNavigator } from 'react-navigation-stack'
import ShipmentScreen from '../containers/Shipment/ShipmentScreen';
import LoginScreen from '../containers/Login/LoginScreen';
import ShipmentDetailScreen from '../containers/Shipment/ShipmentDetailScreen';
import AuthLoadingScreen from '../containers/AuthLoadingScreen';
import BarcodeScreen from '../containers/Barcode/BarcodeScreen';
import { createBottomTabNavigator } from 'react-navigation-tabs'
import { createDrawerNavigator } from 'react-navigation-drawer';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import Colors from "../utils/Colors";
import Sidebar from '../components/Sidebar';
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Home Screen</Text>
</View>
);
}
}
class Data extends React.Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Menu Screen</Text>
</View>
);
}
}
const defaultStackNavOptions = {
headerStyle: {
backgroundColor: Platform.OS === 'android' ? Colors.primaryColor : ''
},
headerTitleStyle: {
fontWeight: 'bold',
},
headerBackTitleStyle: {
fontWeight: 'bold',
},
headerTintColor: Platform.OS === 'android' ? Colors.lightColor : Colors.primaryColor,
headerTitle: 'SFL'
};
const TabNavigator = createBottomTabNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor }) => (
<View>
<MaterialCommunityIcons style={{ color: tintColor }} size={25} name={'home'} />
</View>),
},
},
Menu: {
screen: sideDrawer,
navigationOptions: {
tabBarLabel: 'Menu',
tabBarIcon: ({ tintColor }) => (
<View>
<MaterialCommunityIcons style={{ color: tintColor, }} size={25} name={'menu'} />
</View>),
},
},
},
{
initialRouteName: "Home",
activeColor: Colors.activeTabColor,
inactiveColor: Colors.inactiveTabColor,
barStyle: {
backgroundColor: Colors.grayColor
},
tabBarOptions: {
style: {
borderTopColor: 'transparent',
shadowColor: Colors.darkColor,
shadowOpacity: 1,
shadowRadius: 30,
shadowOffset: {
height: 10,
width: 10
},
elevation: 5
},
labelStyle: {
fontSize: 12,
fontWeight: 'bold'
},
tabStyle: {
paddingVertical: 5
}
}
},
);
const sideDrawer = createDrawerNavigator(
{
ScreenA: { screen: Data },
ScreenB: { screen: Data },
ScreenC: { screen: Data }
},
{
drawerPosition: 'right',
contentComponent: Sidebar,
}
)
export default AppContainer = createAppContainer(TabNavigator)
How can i will be able to achieve this?
can anyone suggest a workaround solution?
Thanks.

React Navigation 4.x version issue when navigating to other screen

When Using react-navigation version 4.1.1
When navigating from one screen to another screen it is fluctuating and i am using ImageBackground there ,so first white blank screen appears after that imagebackground is loading which is very slow and i can easily see the transition over there .
I dont know what's the exact issue is there.
And for this new version i have to install libraries also for react navigation i.e.react-native screens,animated and maskedView ,safeareacontext.
So please any one know about this please let me know ..
Thanks in advance .
Here is a video for my app where i am getting image loading issue...
https://drive.google.com/open?id=16bdmxOC342uCQl3UL_hB8K0wznpbedge
Here is my APP.js File where i have created stack navigator..
import React, { Component } from 'react';
import { createAppContainer } from "react-navigation"
import { createStackNavigator } from 'react-navigation-stack';
import WelcomeScreen from './Screens/WelcomeScreen';
import Walkthorugh from './Screens/Walkthrough';
import Login from './Screens/Login';
import Signup from './Screens/Signup';
import Profile from './Screens/Profile';
import Wishlist from './Screens/Wishlish';
import Home from './Screens/Home';
import Cart from './Screens/Cart';
const notificationsel = require('./Screens/icons/notificationsel.png');
import { createBottomTabNavigator } from 'react-navigation-tabs';
import { enableScreens } from 'react-native-screens';
import { useScreens } from 'react-native-screens';
import {
StyleSheet,
Easing,
View, Animated, FlatList,
Text, Image, Alert, YellowBox, Button, ImageBackground,
TouchableWithoutFeedback, TouchableOpacity
} from 'react-native';
const welcomeStack = createStackNavigator({
Welcome:{screen:WelcomeScreen
},
});
const homeStack = createStackNavigator({
Home:{screen:Home
},
});
const profileStack = createStackNavigator({
Profile:{screen:Profile,
navigationOptions:{header:null}},
});
const cartStack = createStackNavigator({
Cart:{screen:Cart,
navigationOptions:{header:null}},
});
const wishlistStack = createStackNavigator({
Wishlist:{screen:Wishlist,
navigationOptions:{header:null}},
});
const HomeTabNavigator = createBottomTabNavigator({
Home : homeStack,
Profile : profileStack,
Cart : cartStack,
Wishlist : wishlistStack,
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarOnPress: ({ navigation, defaultHandler }) => {
console.log('onPress:', navigation.state.routeName);
// if(navigation.state.routeName=='CallNow'){
// Linking.openURL(`tel:${'9414036555'}`)
// console.log("CallNow")
// }
defaultHandler()
},
tabBarIcon: ({ focused, horizontal, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Home') {
iconName = focused ? notificationsel : notificationsel;
}
else if (routeName === 'Profile') {
iconName = focused ? notificationsel : notificationsel;
}
else if (routeName === 'Cart') {
iconName = focused ? notificationsel : notificationsel;
}
else if (routeName === 'Wishlist') {
iconName = focused ? notificationsel : notificationsel;
}
// You can return any component that you like here!
return <Image source={iconName} style={{width:22,height:22}}/>
;
},
}),
tabBarOptions:{
activeTintColor: 'blue',
inactiveTintColor: '#000',
showLabel:true,
style:{backgroundColor:'#fff',padding:5}
},
}
);
const AppNavigator = createStackNavigator(
{
Home: {
screen: HomeTabNavigator,
// navigationOptions:{header:null}
},
Walkthorugh:{
screen:Walkthorugh,
// navigationOptions:{header:null}
},
Welcome:{
screen:WelcomeScreen,
// navigationOptions:{header:null}
},
Login:{
screen:Login,
},
Signup:{
screen:Signup,
// navigationOptions:{header:null}
},
},
{
headerMode:'none',
initialRouteName: "Walkthorugh",
cardStyle: {backgroundColor: "transparent", opacity: 1 },
defaultNavigationOptions: {
gesturesEnabled: false,
cardStyle: {backgroundColor: "transparent", opacity: 1 },
swipeEnabled: false,
animationEnabled: false,
},
}
);
const AppContainer = createAppContainer(AppNavigator);
export default class App extends Component {
render() {
return (
<AppContainer />
)
}
}
And this is my Login.js ..
import React, { Component } from 'react';
import {
StyleSheet,
Platform,
View, ActivityIndicator, FlatList,
Text, Image, Dimensions, Keyboard, TextInput, ImageBackground,
StatusBar, TouchableOpacity
} from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
const { width, height } = Dimensions.get('window');
const app_icon = require('./icons/app_icon.png')
const loginbg = require('./icons/loginbg.jpg')
const fashionbot = require('./icons/fashionbot.png')
import { Api_const, App_colors } from './Const/Const.js';
import { ScrollView } from 'react-native-gesture-handler';
import LinearGradient from 'react-native-linear-gradient';
export default class Login extends Component {
static navigationOptions = {
headerTitle: 'Login',
// headerLeft: (
// <View style={{ flexDirection: "row", marginLeft: 20, marginRight: 20 }}>
// <TouchableWithoutFeedback>
// <Image source={require('../assets/Hamburger.png')} >
// </Image>
// </TouchableWithoutFeedback>
// </View>
// ),
headerStyle: { borderBottomWidth: 0, marginTop: (Platform.OS === 'ios') ? 0 : 0 },
headerBackTitle: " "
};
constructor(props) {
super(props);
this.state = {
isLoading: false,
email: '',
password: '',
}
}
onClick_Login = () => {
var action = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Home',params:{test:'test'} })]
});
this.props.navigation.dispatch(action);
// setTimeout(()=>{
// this.props.navigation.dispatch(action);
// },
// 400);
}
render() {
if (this.state.isLoading) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" />
</View>
);
}
return (
<LinearGradient colors={[App_colors.purple, App_colors.pink, App_colors.pink]} style={{flex:1}}>
<ScrollView ref="scrollView" style={{ flex:1 }} bounces={false}>
<StatusBar hidden={true} backgroundColor={App_colors.purple} barStyle="dark-content" />
<View style={{ flex:1,height}}>
<ImageBackground source={loginbg} style={{height }}>
<View style={{height }}>
<View style={{ flexDirection: 'row', margin: 15 }}>
<Image style={{ flex: 0.3, height: 90, alignItems: 'center', justifyContent: 'center', alignSelf: 'center' }} resizeMode={"contain"} source={app_icon} />
<Image style={{ flex: 1, alignItems: 'center', justifyContent: 'center', alignSelf: 'center' }} resizeMode={"contain"} source={fashionbot} />
</View>
<View style={{flex:1, justifyContent: 'center', marginLeft: 25, marginRight: 25 }}>
<Text style={{ fontSize: 22, color: '#fff', alignItems: 'center', alignSelf: 'center' }}>{'Login'}</Text>
<Text style={{ fontSize: 16, color: '#fff', marginTop: 15 }}>{'Email'}</Text>
<TextInput style={{ fontSize: 14, height: 40, marginLeft: 0, marginRight: 0, color: 'white' }}
value={this.state.email}
onChangeText={(text) => this.setState({ email: text })}
placeholder={'Your Email'}
placeholderTextColor={App_colors.white}
underlineColorAndroid={'white'}
textContentType={'username'}
keyboardType='email-address'
caretHidden={false}
onSubmitEditing={() => { Keyboard.dismiss() }}
/>
{/* PASSWORD */}
<Text style={{ fontSize: 16, color: '#fff', marginTop: 15 }}>{'Password'}</Text>
<TextInput style={{ fontSize: 14, height: 40, marginLeft: 0, marginRight: 0, color: 'white' }}
value={this.state.password}
onChangeText={(text) => this.setState({ password: text })}
placeholder={'*********'}
placeholderTextColor={App_colors.white}
underlineColorAndroid={'white'}
secureTextEntry={true}
caretHidden={false}
onSubmitEditing={() => { Keyboard.dismiss() }}
/>
<Text style={{ fontSize: 16, color: '#fff', marginTop: 5 }}>{'Forgot Password?'}</Text>
<TouchableOpacity style={{ justifyContent: 'center',alignSelf:'center', marginBottom: 10, marginTop: 30, width: width - 100, marginLeft: 0, marginRight: 0, alignItems: 'center', borderRadius: 25, borderWidth: 0, paddingTop: 15, paddingBottom: 15, backgroundColor: 'white' }}
onPress={this.onClick_Login}>
<Text style={{ fontSize: 16, color: App_colors.purple }}>{'Log in'}</Text>
</TouchableOpacity>
</View>
</View>
</ImageBackground>
</View>
</ScrollView>
</LinearGradient>
);
}
}
in development mode react-native will show white screen. But in production, it won't so don't worry. it is normal.
about navigation I can't be sure but share the code or demo(image/video).

react-native-autocomplete result list not touchable

I have this implementation of a screen
import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import { Icon, View, Text, ListItem } from 'native-base';
import { createMaterialTopTabNavigator } from 'react-navigation';
import { connect } from 'react-redux';
import Autocomplete from 'native-base-autocomplete';
import EventsResults from './EventsResults';
import VehiclesResults from './VehiclesResults';
import { performSearch } from '../actions/search';
import Colors from '../../../util/Colors';
import GlobalStyle from '../../../util/GlobalStyle';
const styles = StyleSheet.create({
autocompleteContainer: {
zIndex: 800
}
});
const mapStateToProps = ({ searchResults }) => ({
searchResults
});
const SearchTabNavigatorStack = createMaterialTopTabNavigator(
{
EventsTab: {
screen: EventsResults,
navigationOptions: { tabBarLabel: 'Events' }
},
VehiclesTab: {
screen: VehiclesResults,
navigationOptions: { tabBarLabel: 'Vehicles' }
}
},
{
initialRouteName: 'EventsTab',
navigationOptions: () => ({
tabBarVisible: true
}),
swipeEnabled: true,
tabBarOptions: {
upperCaseLabel: false,
activeTintColor: Colors.defaultPrimaryColor,
inactiveTintColor: Colors.defaultPrimaryColor,
indicatorStyle: {
backgroundColor: Colors.defaultPrimaryColor,
},
tabStyle: {
height: 48,
alignItems: 'center',
justifyContent: 'center',
},
style: {
backgroundColor: Colors.primaryBackgroundColor,
},
statusBarStyle: 'light-content',
},
}
);
const filterData = (query) => {
const cars = [];
cars.push({ text: 'Chevrolet Trailblazer 2011' });
cars.push({ text: 'Chevrolet Spark 2011' });
cars.push({ text: 'Chevrolet Silverado 2011' });
cars.push({ text: 'Ford Explorer 2010' });
cars.push({ text: 'Ford Escape 2012' });
cars.push({ text: 'Ford Ecosport 2014' });
const result = (query === null || query.trim() === '') ? [] : cars.filter(car => car.text.indexOf(query) !== -1);
return result;
};
class HeaderComponent extends Component {
constructor(props) {
super(props);
this.state = { text: null };
}
render() {
const data = filterData(this.state.text);
return (
<View
style={{
flex: 0,
flexDirection: 'column',
justifyContent: 'space-between',
backgroundColor: Colors.primaryBackgroundColor
}}
>
<View
style={{
flex: 0,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center'
}}
>
<Text style={[GlobalStyle.textTitleStyle, { marginLeft: 10 }]}>search</Text>
<Icon active style={{ color: Colors.defaultPrimaryColor, margin: 10 }} name='ios-close' />
</View>
<View
style={{
flex: 0,
flexDirection: 'row',
justifyContent: 'space-evenly',
alignItems: 'center',
backgroundColor: Colors.defaultPrimaryColor,
marginLeft: 10,
marginRight: 10
}}
>
<Autocomplete
data={data}
containerStyle={styles.autocompleteContainer}
style={{ color: Colors.searchTextInput, backgroundColor: 'white' }}
onChangeText={(text) => this.setState({ text })}
renderItem={item => (
<ListItem style={{ zIndex: 900 }} onPress={() => this.setState({ text: item.text })}>
<Text>{item.text}</Text>
</ListItem>
)}
/>
</View>
</View>
);
}
}
const HeaderContainer = connect(mapStateToProps, { performSearch })(HeaderComponent);
class SearchScreen extends Component {
static router = SearchTabNavigatorStack.router;
static navigationOptions = ({ navigation }) => ({
header: <HeaderContainer />
});
render() {
return (
<SearchTabNavigatorStack navigation={this.props.navigation} />
);
}
}
export default connect(mapStateToProps, null)(SearchScreen);
It had to be this way to provide the ui visual representation that was designed (not my idea); the autocomplete component is working, the result list is displayed but the items in the list are not clickable
I supossed the zIndex property should fix this, but to no avail, and i am out of ideas
Any help or suggestions ?

React-navigation: how to style a big middle button in tab navigation?

So I have this requirement. To make tab navigation with this exact appearance:
I had no problem styling the tab bar with the gradient and the buttons. I created my own custom one with this code:
export default createBottomTabNavigator({
(... routes here)
}, {
initialRouteName: "Inspiration",
tabBarComponent: props => <BottomTabBar {...props} />
})
But now I'm having trouble with the middle button. My bar looks like this:
If I remove the custom tab bar removing this line:
tabBarComponent: props => <BottomTabBar {...props} />
Then now my middle button looks how it should, but of course, all of the other styles are missing:
This is how my BottomTabBar component looks right now:
import React from "react";
import { Image, StyleSheet, Text, TouchableOpacity } from "react-native";
import { TabBarBottomProps, NavigationRoute } from "react-navigation";
import LinearGradient from "react-native-linear-gradient";
const iconBag = require("./images/bag.png");
export default function BottomTabBar(props: TabBarBottomProps) {
const {
renderIcon,
getLabelText,
activeTintColor,
inactiveTintColor,
onTabPress,
onTabLongPress,
getAccessibilityLabel,
navigation
} = props;
const { routes, index: activeRouteIndex } = navigation.state;
function renderTabBarButton(routeIndex, route) {
const isRouteActive = routeIndex === activeRouteIndex;
const tintColor = isRouteActive ? activeTintColor : inactiveTintColor;
if (route.key == "Bag")
return <Image style={{ width: 100, height: 100 }} source={iconBag} />;
return (
<TouchableOpacity
key={routeIndex}
style={styles.tabButton}
onPress={() => onTabPress({ route })}
onLongPress={() => onTabLongPress({ route })}
accessibilityLabel={getAccessibilityLabel({ route })}
>
{renderIcon({ route, focused: isRouteActive, tintColor })}
<Text style={styles.tabText}>{getLabelText({ route })}</Text>
</TouchableOpacity>
);
}
return (
<LinearGradient colors={["#FFFFFF", "#DEDEDE"]} style={styles.container}>
{routes.map((route, routeIndex) => renderTabBarButton(routeIndex, route))}
</LinearGradient>
);
}
const styles = StyleSheet.create({
container: {
height: 60,
flexDirection: "row",
alignItems: "center",
borderWidth: 1,
borderColor: "#C4C4C4"
},
tabButton: {
flex: 1,
justifyContent: "center",
alignItems: "center"
},
tabText: {
fontFamily: "Source Sans Pro",
fontSize: 11,
color: "#454545",
marginTop: 1
}
});
What can I do? Any help will be really much appreciated!
You can try my solution
const TabNavigator = createBottomTabNavigator(
{
Top: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Image
source={require('./src/assets/ic_list.png')}
style={{width: 24, height: 24, tintColor: tintColor}}
/>
),
},
},
New: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Image
source={require('./src/assets/ic_clock.png')}
style={{width: 24, height: 24, tintColor: tintColor}}
/>
),
},
},
Ask: { // big plus icon in the middle
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<View
style={{
position: 'absolute',
bottom: 20, // space from bottombar
height: 58,
width: 58,
borderRadius: 58,
backgroundColor: '#5a95ff',
justifyContent: 'center',
alignItems: 'center',
}}>
<Image
source={require('./src/assets/ic_add_24.png')}
style={{
width: 40,
height: 40,
tintColor: '#f1f6f9',
alignContent: 'center',
}}
/>
</View>
),
},
},
Show: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Image
source={require('./src/assets/ic_notification.png')}
style={{width: 24, height: 24, tintColor: tintColor}}
/>
),
},
},
Jobs: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Image
source={require('./src/assets/ic_person.png')}
style={{width: 24, height: 24, tintColor: tintColor}}
/>
),
},
},
},
{
tabBarOptions: {
activeTintColor: '#FF6F00',
inactiveTintColor: '#8997B0',
showIcon: true,
showLabel: false,
style: {
backgroundColor: '#f1f6f9',
},
},
},
);
I made this bottom tab with react native. I think your design is very simple. My code sample will help you I think.
import React from 'react';
import { createBottomTabNavigator, createStackNavigator } from 'react-navigation';
import { View, Image } from 'react-native'
import { Text } from 'native-base';
import Featured from './featured';
import AboutUs from './about_us';
import Shop from './shop';
import Booking from './booking';
import Settings from './settings';
import styles from './styles';
import star from './../../assets/images/icons/star.png';
import star_check from './../../assets/images/icons/star_check.png';
import about from './../../assets/images/icons/about.png';
import about_check from './../../assets/images/icons/about_check.png';
import book from './../../assets/images/icons/book.png';
import check from './../../assets/images/icons/check.png';
import shop from './../../assets/images/icons/shop.png';
import shop_check from './../../assets/images/icons/shop_check.png';
import more from './../../assets/images/icons/more.png';
import more_check from './../../assets/images/icons/more_check.png';
const Tabs = createBottomTabNavigator(
{
Featured: {
screen: Featured,
navigationOptions: {
title: 'Featured',
tabBarIcon: ({ tintColor, focused }) => (
<View style={styles.tab}>
<Image source={focused? star_check : star} style={styles.icon} />
<Text style={[styles.name, {color: tintColor}]}>Kampanjer</Text>
</View>
)
}
},
AboutUs: {
screen: AboutUs,
navigationOptions: {
title: 'About Us',
tabBarIcon: ({ tintColor, focused }) => (
<View style={styles.tab}>
<Image source={focused? about_check : about} style={styles.icon} />
<Text style={[styles.name, {color: tintColor}]}>Om oss</Text>
</View>
)
}
},
Booking: {
screen: Booking,
navigationOptions: {
title: 'MIN SALONG',
tabBarIcon: ({ tintColor, focused }) => (
<View style={styles.book}>
<Image source={focused? check : book} style={styles.book_icon} />
</View>
)
}
},
Shop: {
screen: Shop,
navigationOptions: {
title: 'Shop',
tabBarIcon: ({ tintColor, focused }) => (
<View style={styles.tab}>
<Image source={focused? shop_check : shop} style={styles.icon} />
<Text style={[styles.name, {color: tintColor}]}>Shop</Text>
</View>
)
}
},
Settings: {
screen: Settings,
navigationOptions: {
title: 'More',
tabBarIcon: ({ tintColor, focused }) => (
<View style={styles.tab}>
<Image source={focused? more_check : more} style={styles.icon} />
<Text style={[styles.name, {color: tintColor}]}>Inställningar</Text>
</View>
)
}
},
},
{
initialRouteName: 'Featured',
tabBarOptions: {
activeTintColor: '#80A0AB',
inactiveTintColor: '#fff',
showLabel: false,
style: {
height: 60,
backgroundColor: '#485155'
},
labelStyle: {
fontSize: 12,
fontFamily: 'Abel-Regular'
}
}
}
);
export default createStackNavigator({Tabs}, {headerMode: "none"});
Try this
<Tab.Navigator
tabBarOptions={{
activeTintColor: 'red',
// activeBackgroundColor:'#000',
//inactiveBackgroundColor:'red',
labelStyle: {
position: 'absolute',
top: constants.vh(35),
fontSize:constants.vh(18),
}
}}
>
<Tab.Screen name='Home' //bottom tab for Home
options={{
tabBarIcon: ({ focused }) => {
let iconName;
iconName = focused ? constants.images.bottomHome : constants.images.bottomHome //for icon or image
return (
<View>
<Image source={iconName} style={{ width: constants.vw(40), height: constants.vh(25) ,position:'absolute',right:constants.vw(-20),bottom:constants.vh(-5)}} resizeMode="contain" />
</View>
)
}
}}
component={HomeScreen} />
</Tab.Navigator>

How to build a nested navigation In react native

I Have navigation system of createMaterialTopTabNavigator and createDrawerNavigator I try to get a menu bar icon in the top left side of the createMaterialTopTabNavigator but till this moment I can't figure out how to add this element at the particular place , is there any react native property that may correspond to that situation , could you please help
import React, { Component } from "react";
import {.. } from "react-native";
import Icon from 'react-native-vector-icons/MaterialIcons'
import { createSwitchNavigator, createDrawerNavigator ,DrawerItems,createMaterialTopTabNavigator,createStackNavigator} from 'react-navigation'
import screens ...
console.disableYellowBox = true;
const TabBarNavig = createMaterialTopTabNavigator({
Places : {
screen :Players,
navigationOptions: ({ navigation }) => ({
title: 'Placements'
}
)
},
GetPlaces : Teams,
New : Matchs
},
{
tabBarOptions: {
scrollEnabled: true,
labelStyle: {
fontSize: 10,
paddingTop:10
},
tabStyle: {
width: Dimensions.get('window').width / 3,
},
style: {
backgroundColor: '#38A1F3',
height: 80
},
indicatorStyle: {
backgroundColor: '#fff',
},
activeTintColor : 'white',
inactiveTintColor : '#ddd',
showIcon : true,
showLabel: true
}
}
);
const DrawerContent = (props) => (
<ScrollView contentContainerStyle={{flexGrow: 1 }}>
<View
style={{
paddingTop: 35,
paddingBottom : 35,
backgroundColor: '#38A1F3',
alignItems: 'center',
justifyContent: 'center',
color: '#FFF'
}}
>
<Image
source={require('./assets/logo.png')}
style={{width:110,height:110 , marginBottom: 10,borderColor:'#FFF',borderWidth:0}}
/>
</View>
<View style={{ backgroundColor: '#FFF',alignItems: 'flex-start',justifyContent: 'center',marginTop:40,marginLeft:20}}>
<DrawerItems {...props}
getLabel = {(scene) => (
<View style={styles.button}>
<Image source={arry[props.getLabel(scene)]} style={{marginRight:20,width:24,height:24}} />
<Text style={styles.buttonText}>{props.getLabel(scene)}</Text>
</View>
)}
/>
</View>
</ScrollView>
)
const arry = {Home:require('./assets/home.png'),Days:require('./assets/icon.png')};
const AppDrawerNavigator = createDrawerNavigator({
Home: TabBarNavig,
Days: Dating
},
{
contentComponent: DrawerContent,
}
)
const Routes = createSwitchNavigator({
App: AppDrawerNavigator
})
export default Routes;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
buttonText:{
color:'#000',
fontStyle: 'italic',
fontSize: 16,
},
button:{
flexDirection: 'row',
paddingBottom : 20
}
});
As my knowledge, in createBottomTopNavigator according to docs there is no option to add menu left or right docs
you can set left icon through navigationOptions of your component like this
static navigationOptions = ({navigation}) => ({
headerLeft: <Icon name='....' ....../>,
headerRight: <Icon name='....' ....../>
})