GithubHelp home page GithubHelp logo

morenoh149 / react-native-navbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kureev/react-native-navbar

0.0 3.0 0.0 325 KB

Simple customizable navbar component for react-native

License: MIT License

JavaScript 100.00%

react-native-navbar's Introduction

Customizable navbar for react-native

Attention: this component has been designed for usage with Navigator.

Image of Yaktocat

Content

Installation

npm install react-native-navbar

Warning! From version 0.7.1 this package require react-native version 0.8 or higher!

Usage example

var NavigationBar = require('react-native-navbar');

var ExampleProject = React.createClass({

  renderScene: function(route, navigator) {
    var Component = route.component;
    var navBar = route.navigationBar;

    if (navBar) {
      navBar = React.addons.cloneWithProps(navBar, {
        navigator: navigator,
        route: route
      });
    }

    return (
      <View style={styles.navigator}>
        {navBar}
        <Component navigator={navigator} route={route} />
      </View>
    );
  },

  render: function() {
    return (
      <Navigator
        style={styles.navigator}
        renderScene={this.renderScene}
        initialRoute={{
          component: InitialView,
          navigationBar: <NavigationBar title="Initial View"/>
        }}
      />
    );
  }
});

Also, you can take a look on examples folder

Custom elements

In the cases when you need some extra customization (like replacing title by image, adding extra buttons, etc), you can use custom components. Every custom component will receive navigator and route property from renderScene method.

Custom buttons

There are some cases when you need to use custom buttons and it's not hard at all:

var CustomPrevButton = require('./CustomPrevButton');
var CustomNextButton = require('./CustomNextButton');

var navigationBar = (
  <NavigationBar
    title="Custom buttons"
    customPrev={<CustomPrevButton/>}
    customNext={<CustomNextButton/>}
  />
);

In every button you'll receive a navigator property.

Custom title

If for some reason you want to customize a title (add image or whatever), you can use customTitle prop:

var CustomTitle = require('./CustomTitle');

var navigationBar = <NavigationBar customTitle={<CustomTitle />} />;

Component props

  • title (String) - Title of the navbar
  • titleColor (String) - Color of the navbar title (hex/rgb(a))
  • backgroundStyle (Object) - Style that would be applied to navbar background component. Navbar container is wrapped by background container to allow customize those layers separately. In case you need to make this view transparent or change background color - this option for you
  • style (Object) - Style that would be applied to navbar container. That property is only about real container that wraps buttons and title
  • buttonsColor (String) - Color of the buttons
  • onPrev (Function (navigator, route)) - Callback on left navbar button click
  • onNext (Function (navigator, route)) - Callback on right navbar button click
  • hidePrev (Boolean) - Should prev button be hidden or not
  • prevTitle (String) - Caption of the "back" button
  • nextTitle (String) - Caption of the "next" button
  • customPrev (React.Element) - React element to use instead of standart prev button
  • customNext (React.Element) - React element to use instead of standart next button
  • customTitle (React.Element) - React element to use instead of standart title
  • statusBar (String) - Color of the status bar (lightContent/default)

Questions?

Feel free to contact me in twitter or create an issue

react-native-navbar's People

Contributors

agmcleod avatar alinz avatar chirag04 avatar jonasjonny avatar kujohn avatar mwilc0x avatar skevy avatar voronianski avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.