Skip to content

Instantly share code, notes, and snippets.

@VivekNayyar
Last active May 21, 2018 11:53
Show Gist options
  • Save VivekNayyar/73117561440a1c528ccb591a4618e364 to your computer and use it in GitHub Desktop.
Save VivekNayyar/73117561440a1c528ccb591a4618e364 to your computer and use it in GitHub Desktop.
import React from "react";
import { View } from "react-native";
import {
TabNavigator,
TabBarBottom,
createStackNavigator
} from "react-navigation";
import Icon from "../../components/Icon";
import Tab1Screen from "./Tabs/Tab1Screen";
import Tab1Details from "./Tabs/Tab1Details";
import Tab2Screen from "./Tabs/Tab2Screen";
import CustomHeader from "../../components/CustomHeader";
let headerDefaultNavigationConfig = {
header: props => <CustomHeader {...props} />,
headerStyle: {
backgroundColor: "transparent"
},
headerTitleStyle: {
fontWeight: "bold",
color: "#fff",
zIndex: 1,
fontSize: 18,
lineHeight: 23
},
headerTintColor: "#fff"
};
const Tab1 = createStackNavigator(
{
Tab1: {
screen: Tab1Screen,
navigationOptions: {
headerLeft: null,
headerTitle: "Tab 1 Screen"
}
},
Tab1Details: {
screen: Tab1Details,
navigationOptions: {
headerTitle: "Tab 1 Details"
}
}
},
{
navigationOptions: {
...headerDefaultNavigationConfig
}
}
);
const Tab2 = createStackNavigator(
{
Tab2: {
screen: Tab2Screen,
navigationOptions: {
headerLeft: null,
headerTitle: "Tab 2 Screen"
}
}
},
{
navigationOptions: {
...headerDefaultNavigationConfig
}
}
);
const DashboardTabRoutes = TabNavigator(
{
Tab1: Tab1,
Tab2: Tab2
},
{
initialRouteName: "Tab1",
navigationOptions: ({ navigation }) => {
const { routeName, routes } = navigation.state;
let params = routes && routes[1] && routes[1].params;
return {
tabBarIcon: ({ focused, tintColor }) => {
// You can return any component that you like here! We usually use an
// icon component from react-native-vector-icons
return <Icon type={routeName} focused={focused} />;
},
tabBarVisible:
params && params.hideTabBar != null ? !params.hideTabBar : true,
swipeEnabled:
params && params.hideTabBar != null ? !params.hideTabBar : true
};
},
tabBarOptions: {
activeTintColor: "#6200EE",
inactiveTintColor: "#858585",
style: {
height: 60,
paddingVertical: 5,
backgroundColor: "#fff"
},
labelStyle: {
fontSize: 12,
lineHeight: 20,
fontFamily: "CircularStd-Book"
}
},
tabBarComponent: TabBarBottom,
tabBarPosition: "bottom",
animationEnabled: true,
swipeEnabled: true
}
);
export default DashboardTabRoutes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment