1.0.4 • Published 7 years ago

react-native-tabbar-bottom v1.0.4

Weekly downloads
59
License
MIT
Repository
github
Last release
7 years ago

react-native-tabbar-bottom

Support: Android / iOS

This package provides a bottom tabbar for your react native app.

Install

1) Make sure that you have NativeBase installed 2) npm install react-native-tabbar-bottom --save

Demo

Demo1:
Demo1

Demo2:
Demo2

Props

PropTypeOptionsDefaultInfo
typePropTypes.string"button", "ripple""button"
rippleEffectPropTypes.booltrueonly for type === "ripple"
rippleColorPropTypes.string"green"only for type === "ripple"
rippleDurationPropTypes.number280only for type === "ripple"
tabbarBgColorPropTypes.string"#16394f"
tabbarBorderTopColorPropTypes.stringnull
iconColorPropTypes.string"#ccc"
selectedIconColorPropTypes.string"#fff"
labelSizePropTypes.number12
labelColorPropTypes.string"#ccc"
selectedLabelColorPropTypes.string"#fff"
badgeColorPropTypes.string"#dd463b"
badgeLabelColorPropTypes.string"#fff"
badgeLabelSizePropTypes.number11
badgeColorPropTypes.string"#dd463b"
stateFuncPropTypes.func.isRequiredRequired. Pass in function to update state. Format: (tab) => {..}
activePagePropTypes.string.isRequiredRequired. Pass in active page.
tabsPropTypes.arrayOfRequired. Pass in tab data

Props of tabs prop

PropTypeInfo
pagePropTypes.stringPage name, e.g. "HomeScreen"
titlePropTypes.stringCan e.g. be shown in navbar
iconPropTypes.stringIcon name of the Icon (Ionicons names)
iconTextPropTypes.stringText of the icon (shown below the icon)
badgeColorPropTypes.stringOther badge color for tab
badgeLabelColorPropTypes.stringOther badge label color for tab
badgeNumberPropTypes.numberBadge number (number shown in badge)

Example code

You can also find this example in the example folder.

[...]
import Tabbar from 'react-native-tabbar-bottom'

export default class exampleTabs extends Component {
  constructor() {
    super()
    this.state = {
      page: "HomeScreen",
    }
  }

  render() {
    return (
      <View style={styles.container}>
        {
          // if you are using react-navigation just pass the navigation object in your components like this:
          // {this.state.page === "HomeScreen" && <MyComp navigation={this.props.navigation}>Screen1</MyComp>}
        }
        {this.state.page === "HomeScreen" && <Text>Screen1</Text>}
        {this.state.page === "NotificationScreen" && <Text>Screen2</Text>}
        {this.state.page === "ProfileScreen" && <Text>Screen3</Text>}
        {this.state.page === "ChatScreen" && <Text>Screen4</Text>}
        {this.state.page === "SearchScreen" && <Text>Screen5</Text>}

        <Tabbar
          stateFunc={(tab) => {
            this.setState({page: tab.page})
            //this.props.navigation.setParams({tabTitle: tab.title})
          }}
          activePage={this.state.page}
          tabs={[
            {
              page: "HomeScreen",
              icon: "home",
            },
            {
              page: "NotificationScreen",
              icon: "notifications",
              badgeNumber: 11,
            },
            {
              page: "ProfileScreen",
              icon: "person",
            },
            {
              page: "ChatScreen",
              icon: "chatbubbles",
              badgeNumber: 7,
            },
            {
              page: "SearchScreen",
              icon: "search",
            },
          ]}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  }
});