npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-scenes

v0.4.6

Published

Standalone React native component scene stack control and support modal it.

Downloads

88

Readme

react-native-scenes

Pure Javascript to standalone scene statck control in React Native like react-navigation or navigator.

react-native-scenes makes dynamic routing each scene.

Version History

  • 0.4.5 Replace GLOBAL keyword.
  • 0.4.3 Bug Fix Scene Container does not relative global bar shadow option.
  • 0.4.2 Remove console.log when dimensions change event called
  • 0.4.1 Improve Dimension change event can customization
  • 0.4.0 Add Dimensions Change receive event implementable
  • 0.3.0 Add Route Change event props on each Component and Scenes owner
  • 0.2.0 Add BackHandler Event on Modal and SceneContainer
  • 0.1.5 Add setGlobalBarShadow(boolean) to control bar shadow appearence.

Supported OS

  • iOS
  • Android
  • Windows

Installation

npm install --save react-native-scenes

How to use

Basic Use

Start Entry point.

import Scenes from 'react-native-scenes';

export default class EntryPoint extends React.Component {
  render(){
    return (
      <Scenes
        route={{
          component:Main, 
        }}
      />
    )
  }
}

Dynamically and programmatically route to another sceen

class Main extends React.Component {
  _onPressSomeEvent(){
    this.props.push({
      component:SecondScene,
      passProps:{
        testValue:'test' // can pass value using passProps and next scene receive with there props.
      }
    })
  }
}

Scene Component Properties

pop

Pop current scene from current scene stack

this.props.pop(void);

push

Push new component to current stack

this.props.push( Route )

popToTop

clear all scene stack with out main route scene.

this.props.popToTop( void )

popTo

pop to specific index to current scene stack

this.props.popTo( index )

setBarStyle

customization bar style

this.props.setBarStyle

setBarOverlay

this.props.setBarOverlay

setTitle

this.props.setTitle

setTitleStyle

this.props.setTitleStyle

setLeftItem

this.props.setLeftItem

setRightItem

this.props.setRightItem()

Route

Route options

  • title
  • titleStyle
  • barHidden
  • barStyle
  • barShadow
  • leftItem
  • rightItem
  • avoidBackHandler

Static Method

  • static setGlobalBarStyle(View Style StyleSheet)
  • static setGlobalBarShadow(Boolean)
  • static setGlobalTitleStyle(Text Style StyleSheet)

Scene

props

  • transitionType
    • Configure appearence method
    • (default)TransitionType.Slide
    • TransitionType.None
    • TransitionType.Fade,
  • backButton
    • Default left item for back ( pop ) button
    • default : BarButtonBack
  • animationDuration (default : 500)
  • style
  • routeWillChange( toIndex : Number )
  • routeDidChange( toIndex : Number )

methods

  • push
  • pop
  • popTo
  • popToTop
  • hideModal

Modal

options ...Route options ...Scene props animationDuration, closeButton=BarButtonClose,

Modal.show()

BackHandler event ( v0.2.0 )

  • The avoidBackHandler rounter options can determine BackHandler work or not work. But you should make sure implement BackHandler event as you want. See react-native BackHandler event sample BackHandler
this.props.push({
  component:SomeScene,
  avoidBackHandler:true,
})

// ... 

class SomeScene extend Component{
  componentDidMount(){
    this._backHandlerSubscription = BackHandler.addEventListener('hardwareBackPress', ()=>{
      Popup.show({
        message:'Are you sure?',
        buttons:['Ok','Cance'],
      })
      .then(({answer})=>{
        if( answer == 0 ) this.props.pop();
      })
      return true;
    })
  }

  componentWillUnmount(){
    this._backHandlerSubscription.remove();
  }
}

Implement Route life cycle functions ( above v 0.3 )

  • routeWillAppear()

    after scene did mount and before the transition push or other component will push out with came current route

  • routeDidAppear()

    after transition with current route push over other scene or other comopnent did push out and re appear curent route

  • routeWillDisappear()

    before scene unmount or other scene route will show push over current scene with transition

  • routeDidDisappear()

    after scene unmount or other scene route did push over current scene after transition

class SomeScene extends Component {
  componentDidMount(){
  }

  componentWillUnmount(){
  }

  routeWillAppear(){
  }

  routeDidAppear(){

  }

  routeWillDisappear(){

  }

  reouteDidDisappear(){

  }

  someActionToPushSomeRoute(){
    this.props.push({
      component:SomeOtherScene,
    })
  }
}

Implement Dimensions Change event

For improve performance should reduce render event called that each route are contained SceneContainer implements shouldCompnentUpdate funciton. So need to update navigation bar and scene update via dimension change event.

  • routeWillChangeDimensions
  • routeDidChangeDimensions

Dimensions Change Event Customization

Sometimes each Scene Container dimension change event need to delay call after other funcitons. ex) change global naviation bar style for related dimensions but Each scenes not effected

  this._scenesDimensionEventListeners = new Map();

  // hack : Eacn Scenes`s router update delay after dimensions change event cause global Navigation bar style has chagne need first;

  // replace DimensionsChange Event emitter ( default is Dimensions`s event management methods )
  Scenes.DimensionsChangeEventEmitter = {
    addEventListener:(event, listener)=>{
      // makes delay 50 ms
      let listenerWrapper = ()=>setTimeout(listener, 50);
      // add event listener to linstener wrapper
      Dimensions.addEventListener( 'change', listenerWrapper );
      // store using Map to relative listener with listenerWrapper;
      this._scenesDimensionEventListeners.set( listener, listenerWrapper );
    },
    removeEventListener:(event, listener)=>{
      // find listenerWrapper via listener
      let listenerWrapper = this._scenesDimensionEventListeners.get(listener);
      // remove event listener via listenerWrapper
      Dimensions.removeEventListener( 'change', listenerWrapper );
      // remove stored relation listener
      this._scenesDimensionEventListeners.delete( listener );
    },
  };