ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 415 forks source link

Add Implementation Example #1

Closed alejomendoza closed 9 years ago

alejomendoza commented 9 years ago

Hi James,

So I tried implementing the tab bar very similar to how it is explained on https://facebook.github.io/react-native/docs/tabbarios.html#content but I get errors. I enabled the babel options. An example of how to implement this component would be sweet. I tried the following code:

render(){
        return(
            <View style={styles.appContainer}>
                <TabBar selectedTab={this.state.selectedTab} barTintColor="rgba(74,74,74,0.8)" tintColor="white" >
                    <TabBar.Item
                        selected={this.state.selectedTab === 'home'}
                        icon={require('image!home-tab-icon-white')}
                        onPress={()=>{
                        this.setState({
                        selectedTab:'home'
                    });
                    }} style={styles.tab}>
                        <Home/>
                    </TabBar.Item>
                    <TabBar.Item
                        selected={this.state.selectedTab === 'search'}
                        icon={require('image!search-tab-icon-white')}
                        onPress={()=>{
                        this.setState({
                            selectedTab:'search'
                        });
                    }} style={styles.tab}>
                        <Search/>
                    </TabBar.Item>
                    <TabBar.Item
                        selected={this.state.selectedTab === 'lists'}
                        icon={require('image!profile-tab-icon-white')}
                        style={styles.tab}>
                        <Lists />
                    </TabBar.Item>
                    <TabBar.Item
                        selected={this.state.selectedTab === 'profile'}
                        icon={require('image!profile-tab-icon-white')}
                        onPress={()=>{
                        this.setState({
                            selectedTab:'profile'
                        });
                    }} style={styles.tab}>
                        <Profile/>
                    </TabBar.Item>
                    <TabBar.Item
                        selected={this.state.selectedTab === 'settings'}
                        icon={require('image!settings-tab-icon-white')}
                        onPress={()=>{
                        this.setState({
                            selectedTab:'settings'
                        });
                    }} style={styles.tab}>
                        <Settings/>
                    </TabBar.Item>
                </TabBar>
            </View>
        )
    }

screen shot 2015-09-09 at 8 23 24 pm

Thank you!

alejomendoza commented 9 years ago

Any news on this one? @ide @brentvatne

alejomendoza commented 9 years ago

Sweet!!!! :smiley: you are the best!