import React from 'react-native';

var device = React.NativeModules.Device;

class Device {
	constructor() {
		this.onSuspend = this.onSuspend.bind(this);
		this.onResume = this.onResume.bind(this);
		this.onOrientationChange = this.onOrientationChange.bind(this);
		React.NativeAppEventEmitter.addListener('suspend', this.onSuspend);
		React.NativeAppEventEmitter.addListener('resume', this.onResume);
		React.NativeAppEventEmitter.addListener('orientationchange', this.onOrientationChange);
		this.getInfo(() => React.DeviceEventEmitter.emit('deviceready'));
	}

	onSuspend() {
		React.DeviceEventEmitter.emit('suspend');
	}

	onResume() {
		React.DeviceEventEmitter.emit('resume');
	}

	getInfo(callback) {
		device.info((info) => {
			Object.assign(this, info);
			callback();
		});
	}

	onOrientationChange() {
		this.getInfo(() => React.DeviceEventEmitter.emit('orientationchange'));
	}

	lockOrientation(orientation) {
		device.lockOrientation(orientation)
	}

	unlockOrientation() {
		device.unlockOrientation()
	}
}

export default new Device()

@@ -85,16 +85,30 @@
 evice %7B%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09constru
@@ -112,24 +112,24 @@
 tructor() %7B%0A
-
 %09%09this.onSus
@@ -572,16 +572,30 @@
 ));%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09onSuspe
@@ -649,16 +649,30 @@
 ');%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09onResum
@@ -724,16 +724,30 @@
 ');%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09getInfo
@@ -840,16 +840,30 @@
 %7D);%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09onOrien
@@ -957,16 +957,30 @@
 ));%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09lockOri
@@ -1045,16 +1045,30 @@
 on)%0A%09%7D%0A%0A
+%09/**%0A%09 *%0A%09 */%0A
 %09unlockO

add comments