1.1.0 • Published 8 years ago

rn-simple-nav v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

I was bored and made a React-Navite Navigator....

  • It's straight up JavaScript using the React-Native Animated API
  • No Gestures...
  • It works as described below, It's working for me in production... 🤓 🤓 .... the stock Navigators are probably better because those BookFace Engineers are smart, but this allowed me to do something different and I have some unique scene changes.

  • has zoomIn spinIn zoomSpin fadeIn fromLeft fromRight fromBottom fromTop as scene transitions.

rn-simple-nav

npm install --save rn-simple-nav

  • Access the navigator as such

import { SimpleNav } from rn-simple-nav

PropTypeDescriptionRequired
screensarray of screen objects see below for structurethe screen for the navigator to renderYES
headerrenderable componentthe optional top header to persistno
footerrenderable componentoptional footer to persistno
onFocusfunctionfunction called when a screen is focused, called with screen nameno
onBlurfunctionfunction called when a screen's focus is removed, called with screen nameno
Screen object
  • must have a name and a screen
  • name is a string
  • screen is a renderable component
  • must supply at least one to start this sucker up.
{name:'ScreenOne', screen: <ScreenOne />}
Methods
  • What good is a Navigator if you can't navigate on it...
  • Access methods as such
you may notice there is no pop method, rather than "popping" a screen, just use the push function, specify the direction, and speed that sucker up.

import { Transitions } from 'rn-simple-nav'

methoddescriptionargumentsexample(s)
pushScreenpushes a new screen to the top of the navigator. If the Navigator already has the screen available you can call it by name. If the navigator has no reference, you must supply it with the screen object(direction required,screen required ,duration optional) direction can be one of fromRight fromLeft fromTop fromBottom spinIn fadeIn zoomIn zoomSpin screen can be just a string if the Navigator has it in the stack, or a screen object duration is in milliseconds and the default is 250Transitions.pushScreen('fromRight',{name:'ScreenTwo',screen:<ScreenTwo />}) Transitions.pushScreen('fromLeft','ScreenOne',50)
removeScreenremoves the screen from the stackscreen nameTransitions.removeScreen('ScreenOne')
removeAllButremoves all screens but the one passed inscreen nameTransitions.removeAllBut('ScreenOne')
getScreensreturn a list of screens the Navigator hasnoneTransitions.getScreens()
toggleHeadertoggles the display of the headernoneTransitions.toggleHeader()
toggleFootertoggles the display of the footernoneTransitions.toggleFooter()

Full example in the example folder

Example