Last active
June 18, 2016 05:13
-
-
Save dabit3/2a4271192e4ed762340ff57f3b779bad to your computer and use it in GitHub Desktop.
React Native Navigator Experimental Part 3 - app/components/TabsRoot.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { TabBarIOS } from 'react-native' | |
import Recipes from '../components/Recipes' | |
import Samples from '../components/Samples' | |
import Home from '../containers/navRootContainer' | |
class Tabs extends Component { | |
_changeTab (i) { | |
const { changeTab } = this.props | |
changeTab(i) | |
} | |
_renderTabContent (key) { | |
switch (key) { | |
case 'home': | |
return <Home /> | |
case 'recipes': | |
return <Recipes /> | |
case 'samples': | |
return <Samples /> | |
} | |
} | |
render () { | |
const tabs = this.props.tabs.tabs.map((tab, i) => { | |
return ( | |
<TabBarIOS.Item key={tab.key} | |
icon={tab.icon} | |
selectedIcon={tab.selectedIcon} | |
title={tab.title} | |
onPress={() => this._changeTab(i)} | |
selected={this.props.tabs.index === i}> | |
{this._renderTabContent(tab.key)} | |
</TabBarIOS.Item> | |
) | |
}) | |
return ( | |
<TabBarIOS tintColor='black'> | |
{tabs} | |
</TabBarIOS> | |
) | |
} | |
} | |
export default Tabs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment