Skip to content

Instantly share code, notes, and snippets.

@rturk
Last active December 26, 2020 18:50
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rturk/858c1afaee170a3a141adc7da652883e to your computer and use it in GitHub Desktop.
Save rturk/858c1afaee170a3a141adc7da652883e to your computer and use it in GitHub Desktop.
React Native Router Flux - Tab Bar with Icon
//This is a Redacted version to be used as a benchmark/example for React Native Router Flux
import React, {
Component,
StatusBar,
Text,
View,
StyleSheet,
PixelRatio,
} from 'react-native';
import { Router, Scene } from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/FontAwesome';
//Create a dedicated class that will manage the tabBar icon
class TabIcon extends Component {
render() {
var color = this.props.selected ? '#00f240' : '#301c2a';
return (
<View style={{flex:1, flexDirection:'column', alignItems:'center', alignSelf:'center', justifyContent: 'center'}}>
<Icon style={{color: color}} name={this.props.iconName || "circle"} size={18}/>
<Text style={{color: color, fontSize: 12}}>{this.props.title}</Text>
</View>
);
}
}
//MyApp Main Class
class MySupperApp extends Component {
return (
<View style={styles.container}>
<Router>
<Scene key="root">
<Scene key="tabbar" component={DrawerMenu} type="reset" duration={1} initial={true} >
<Scene key="main" tabs={true} tabBarStyle={styles.tabBar} default="tab1">
<Scene key="tab1"
title="MyTab"
iconName="tags"
icon={TabIcon}
hideNavBar={true}
component={Tags}
initial={true}
/>
<Scene key="NewsFeed"
title="MainNewssFed"
iconName="newspaper-o"
icon={TabIcon}
hideNavBar={true}
component={NewsFeed}
/>
<Scene key="settings"
iconName="gear"
icon={TabIcon}
hideNavBar={true}
title={Local.settings}
component={Settings} />
</Scene>
</Scene>
</Scene>
</Router>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
tabBar: {
borderTopColor: 'darkgrey',
borderTopWidth: 1 / PixelRatio.get(),
backgroundColor: 'ghostwhite',
opacity: 0.98
},
navigationBarStyle: {
backgroundColor: 'red',
},
navigationBarTitleStyle: {
color:'white',
},
});
@ignatiusbill
Copy link

Hi rturk, where does the DrawerMenu component come from?

@sadi304
Copy link

sadi304 commented Nov 22, 2017

where did you find selected prop? shouldn't it be the focused?

@hugoh59
Copy link

hugoh59 commented Dec 21, 2017

Anyone active on this gist? DrawerMenu seems to be coming from nowhere

@Abilandou
Copy link

Thanks a lot this really got me started.

@Aleksandar1231
Copy link

thank you!

@MohammadHosseinBagheri
Copy link

thank you ;)

@benndip
Copy link

benndip commented Oct 23, 2019

Please where does DrawerMenu come from???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment