Skip to content

Instantly share code, notes, and snippets.

@anastely
Last active February 18, 2020 20:04
Show Gist options
  • Select an option

  • Save anastely/f6a9933349c6e7872da17c2235e93980 to your computer and use it in GitHub Desktop.

Select an option

Save anastely/f6a9933349c6e7872da17c2235e93980 to your computer and use it in GitHub Desktop.
import {createAppContainer} from 'react-navigation';
import {createBottomTabNavigator} from 'react-navigation-tabs';
{/*
..
Screens
..*/}
const LoginTabs = createBottomTabNavigator(
{
Home: {
screen: Home,
navigationOptions: {
tabBarLabel: 'Home',
},
},
Browse: {
screen: Browse,
navigationOptions: {
tabBarLabel: 'Browse',
},
},
Search: {
screen: Search,
navigationOptions: {
tabBarLabel: 'Search',
headerShown: false,
},
},
Radio: {
screen: Radio,
navigationOptions: {
tabBarLabel: 'Radio',
},
},
Library: {
screen: YourLibrary,
navigationOptions: {
tabBarLabel: 'Library',
},
},
},
{
swipeEnabled: true,
lazy: false,
defaultNavigationOptions: ({navigation}) => ({
headerLeft: (
<View>
<Button transparent onPress={() => navigation.navigate('DrawerOpen')}>
<Icon name="menu" style={styles.styles} />
</Button>
</View>
),
tabBarIcon: ({focused, tintColor}) => {
const {routeName} = navigation.state;
let iconName;
if (routeName === 'Home') {
iconName = 'ios-home';
} else if (routeName === 'Browse') {
iconName = 'ios-globe';
} else if (routeName === 'Radio') {
iconName = 'ios-radio';
} else if (routeName === 'Library') {
iconName = 'ios-albums';
} else if (routeName === 'Search') {
iconName = 'ios-search';
}
return <Ionicons name={iconName} size={25} color={tintColor} />;
},
}),
tabBarOptions: {
style: {
backgroundColor: '#fff',
flexDirection: `${I18nManager.isRTL ? 'row' : 'row-reverse'}`,
},
activeTintColor: '#ff4865',
},
},
);
export default createAppContainer(LoginTabs);
import TabNavigation from './screens/TabNavigation';
const LoginTabs = TabNavigation;
const AppNavigator = createStackNavigator(
{
Register: {
screen: Register,
navigationOptions: () => ({
drawerLockMode: 'locked-closed',
}),
},
googleAuth: {
screen: googleAuth,
navigationOptions: () => ({
drawerLockMode: 'locked-closed',
}),
},
Login: {
screen: Login,
navigationOptions: () => ({
drawerLockMode: 'locked-closed',
}),
},
TabHome: {
screen: LoginTabs,
navigationOptions: ({navigation}) => {
let {routeName} = navigation.state.routes[navigation.state.index];
let title;
if (routeName === 'Home') {
title = 'Home';
} else if (routeName === 'Browse') {
title = 'Browse';
} else if (routeName === 'Search') {
title = 'Search';
} else if (routeName === 'Radio') {
title = 'Radio';
} else if (routeName === 'Library') {
title = 'Library';
}
return {
title,
};
},
},
);
.. Drawer here ..
const Navigations = createSwitchNavigator({
App: Drawer, // the App stack,
});
export default createAppContainer(Navigations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment