import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, Image, TabBarIOS, NavigatorIOS, TouchableOpacity, } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; const styles = StyleSheet.create({ navigator: { flex: 1, }, container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, tabContent: { flex: 1, alignItems: 'center', justifyContent: 'center', }, tabText: { color: 'white', }, button: { marginTop: 20, padding: 8, backgroundColor: 'white', borderRadius: 4, }, }); class ColoredView extends Component { componentWillMount() { Icon.getImageSource('md-arrow-back', 30).then((source) => this.setState({ backIcon: source })); } _navigateToSubview() { this.props.navigator.push({ component: ColoredView, title: this.props.pageText, leftButtonIcon: this.state.backIcon, onLeftButtonPress: () => this.props.navigator.pop(), passProps: this.props, }); } render() { return ( {this.props.pageText} this._navigateToSubview()}> Tap Me ); } } class TabBarExample extends Component { constructor(props) { super(props); this.state = { selectedTab: 'home', }; } componentWillMount() { // https://github.com/facebook/react-native/issues/1403 prevents this to work for initial load Icon.getImageSource('ios-settings', 30).then((source) => this.setState({ gearIcon: source })); } _renderContent(color, pageText) { if (!this.state.gearIcon) { return false; } const props = { color, pageText }; return ( ); } render() { return ( { this.setState({ selectedTab: 'home', }); }}> {this._renderContent('#414A8C', 'Home')} { this.setState({ selectedTab: 'profile', }); }}> {this._renderContent('#090', 'Profile')} { this.setState({ selectedTab: 'starred', }); }}> {this._renderContent('#900', 'Starred')} { this.setState({ selectedTab: 'settings', }); }}> {this._renderContent('#009', 'Settings')} ); } } AppRegistry.registerComponent('TabBarExample', () => TabBarExample);