0.4.3 • Published 7 years ago

react-native-tabbar-navigator v0.4.3

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

React Native TabBar Navigator (iOS only)

npm version MIT

A component which builds excellent Navigator(NavigationController) + TabBar(TabBarController) based application, have a good solution for implementing hidesBottomBarWhenPushed in iOS.

PREVIEW

SPECIAL NOTE FOR 0.4.0

Please don't update to 0.4.0 if you are using previous version of this plugin, because the way to use it is completely different.

UPDATEs

0.4.0 Supports React Native 0.40, optimized usages.

0.3.0 Test with several projects, and no obviously bug, so 0.3.0 will be a stable version.

0.2.8 Added a shadow style, make it more native, preview

0.2.7 Remove the hack on last commit, reason

0.2.6 Disabling the wired Y scale when pushing the view, which make it more similar to NavigatorIOS

0.2.4 Fixed a logical bug which caused a re-render issue.

0.2.3 New feature by @aerofs, title component can be customize now.

0.2 Stable Version

0.1 Project First Commit

Installation

cd to your React Native project directory and run

npm i --save react-native-tabbar-navigator

Usage

import { TabNavigator } from 'react-native-tabbar-navigator';

The basic usages:

function RootView() {
  let navItems = [
    {
      leftItem: {
        component: (<NavItemText/>),
        onPress: (isRoot, pop) => {
          ActionSheetIOS.showActionSheetWithOptions({
            options: ['View Account Info', 'My Orders', 'Sign Out'],
            destructiveButtonIndex: 2
          }, () => {});
        }
      },
      rightItem: {
        component: (<NavItemIcon/>),
        onPress: (isRoot, pop) => {
          ActionSheetIOS.showActionSheetWithOptions({
            options: ['Share', 'Scan QR Code', 'Cancel'],
            destructiveButtonIndex: 2
          }, () => {});
        }
      }
    },
    {
      title: {
        component: (<NavItemSegmentCtrl/>)
      },
      rightItem: {
        component: (<NavItemIconSettings/>),
        onPress: (isRoot, pop) => {
          ActionSheetIOS.showActionSheetWithOptions({
            options: ['Account Settings', 'App Settings', 'Cancel'],
            destructiveButtonIndex: 2
          }, () => {});
        }
      }
    }
  ];
  return (
    <TabNavigator tintColor='#FF2D55'>
      <TabNavigator.Item title='Tab One' icon={{uri: tabOneIcon, scale: 3}} navItems={navItems[0]} defaultTab>
        <TabOneIndex/>
      </TabNavigator.Item>
      <TabNavigator.Item title='Tab Two' icon={{uri: tabTwoIcon, scale: 3}} navItems={navItems[1]} badge='999+'>
        <TabTwoIndex/>
      </TabNavigator.Item>
    </TabNavigator>
  );
}

API

NOTE Be sure to know the basic usage of <Navigator/> and <TabBarIOS/>

For this plugin, there are 2 components that you need to know.

<TabNavigator/>

PropertyDescriptionTypeDefault
navBarTintColorDefault font color of navigation bar.string'#FFFFFF'
navTintColorDefault background color of navigation bar.string'#FF2D55'
childrenONLY accepts <TabNavigator.Item/>s as children components.Array\<React.Component>[]
...propsThe other props that passed to this Component is directly passed to the corresponding <Navigator/> and override any default props in this plugin. Be sure to read the source code first, or you should not override the props below: style, initialRoute, renderScene, navigationBar, sceneStyle.

<TabNavigator.Item/>

PropertyDescriptionTypeDefault
titleTitle of the corresponding Tab and Navigation Title. You can customize Navigation Title by navItems property.string
defaultTabSet this Item as default selcted tab.boolfalse
navItemsDetailed API below.Array\<NavItemConfig>REQUIRED
childrenONLY accepts single child element.React.ComponentREQUIRED
...propsThe other props that passed to this Component is directly passed to the corresponding <TabBarIOS.Item/>.

NavItemConfig

PropertyDescriptionTypeDefault
leftItemComponent settings for TopLeft navigation item.NavigationItem
rightItemComponent settings for TopRight navigation item.NavigationItem
titleNavigation title for corresponding Tab.string | NavigationItemTabNavigator.Item.props.title

NavigationItem

PropertyDescriptionTypeDefaultExample
componentReact Component for corresponding position.React.Componentnull<Text>More</Text>
onPressThis function is passed to the component onPress prop, make sure to receive onPress in component and handle it.NavigationItemEvent() => {}(isRoot, pop) => { if (isRoot) pop() }

NavigationItemEvent

This is actually a function type. When this function is called, it will pass 3 arguments.

OrderArgumentDescriptionType
1isRootIs root route or not, if it is root route, you should not call the 2nd popHandler argument.bool
2popHandlerA shortcut to navigator.pop, calling this can pop the current navigator.function
3navigatorThe current navigator.

Advanced usage

For more advanced examples, please check out the example app.

How to run the example App?

Xcode.

Questions

If something is undocumented here, and it is not clear with you, feel free to create an issue here, I will tried my best to answer you.

Anything else

Open a new issue to report bugs or request new features. Feel free to create Pull Request, I will be happy to merge if it is a good PR.

My email me@idickyt.com

Facebook Dicky Tsang

Sina Weibo @桐乃

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago