react-native-navigationbar-obsever

1.0.3 • Public • Published

React Native navigationbar

Listen to device navigationbar changes in React Native applications on a per screen basis. Works on Android only.

Installing

npm install react-native-navigationbar-obsever --save

Linking Native Dependencies

Automatic Linking

react-native link react-native-navigationbar-obsever

Android

  1. In android/setting.gradle

    ...
    include ':react-native-navigationbar-obsever', ':app'
    project(':react-native-navigationbar-obsever').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigationbar-obsever/android')
    
  2. In android/app/build.gradle

    ...
    dependencies {
        ...
        compile project(':react-native-navigationbar-obsever')
    }
    

Usage

import NavigationbarObsever from 'react-native-navigationbar-obsever';
export default class AppScreen extends Component {
  // ...
 
    componentDidMount() {
      if (Platform.OS === 'android') {
        NavigationbarObsever.isNavigationbarShow((err, isShow) => {
          console.log(err, isShow, 'isShow');
        });
        //if you want to listener,you should bind first.
        NavigationbarObsever.bindListener((err,isOK) => {
          console.log(err, isOK, 'isOK');
        });
        //if you want to listener,you should addListener at second.
        DeviceEventEmitter.addListener('navigationbarDidShowChange', this._navigationDidShowChange);
      }
    }
  
    _navigationDidShowChange = (show) => {
      console.log(show.navigationbarSize, 'navigationbarSize',show.navigationbarShow, 'navigationbarShow');
    }
  
    componentWillUnmount() {
      if (Platform.OS === 'android') {
          //don't forget unbind and remove
        NavigationbarObsever.unbindListener();
        DeviceEventEmitter.removeListener(this._navigationDidShowChange);
        }
    }
 
  render() {
    // ...
 
    return (
      // ...
    )
  }
}

Package Sidebar

Install

npm i react-native-navigationbar-obsever

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

8.56 MB

Total Files

967

Last publish

Collaborators

  • wsong910