react-native-device-orientation

0.0.2 • Public • Published

react-native-device-orientation

Dispatch device orientation.

Usage

Add the BrewingDeviceOrientation to your Xcode like this

Example Usage React Native


'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  NativeModules,
  NativeAppEventEmitter
} = React;

var orientation = React.createClass({
  getInitialState() {

    return { orientation: 'No Orientation.' };
  },
  componentDidMount() {
    NativeModules.BrewingDeviceOrientation.getOrientation((orientation) => {
      NativeAppEventEmitter.addListener(
        'orientationOnChange',
        (response) => this.setState({orientation: response.orientation})
      );
      this.setState({orientation});
    });


  },
  render: function() {
    return (
      <Text style={{marginTop: 44}}>{this.state.orientation}</Text>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('orientation', () => orientation);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i react-native-device-orientation

      Weekly Downloads

      2

      Version

      0.0.2

      License

      MIT

      Last publish

      Collaborators

      • drmabuse