Commit fb11b25c authored by Diego Barros's avatar Diego Barros Committed by Mehdi Achour

feat: Added isLandscape() (#504)

* Added isLandscape data.

* Updated docs with isLandscape addition.

* Updated docs.
parent efa87300
## Release Notes
### next
* Added isLandscape()
### 0.23.0
* Add `hasNotch()` (https://github.com/rebeccahughes/react-native-device-info/pull/500)
......
......@@ -233,7 +233,8 @@ import DeviceInfo from 'react-native-device-info';
| [isEmulator()](#isemulator) | `boolean` | ✅ | ✅ | ✅ | ? |
| [isPinOrFingerprintSet()](#ispinorfingerprintset) | (callback)`boolean` | ✅ | ✅ | ✅ | 0.10.1 |
| [isTablet()](#istablet) | `boolean` | ✅ | ✅ | ✅ | ? |
| [hasNotch()](#hasNotch) | `boolean` | ✅ | ✅ | ✅ | ? |
| [hasNotch()](#hasNotch) | `boolean` | ✅ | ✅ | ✅ | 0.23.0 |
| [isLandscape()](#isLandscape) | `boolean` | ✅ | ✅ | ✅ | 0.24.0 |
---
......@@ -836,6 +837,16 @@ const isTablet = DeviceInfo.isTablet(); // true
---
### isLandscape()
Tells if the device is currently in landscape mode.
**Examples**
```js
const isLandscape = DeviceInfo.isLandscape(); // true
```
### hasNotch()
Tells if the device has a notch.
......
......@@ -39,7 +39,8 @@ declare const _default: {
getMaxMemory: () => number;
getTotalDiskCapacity: () => number;
getFreeDiskStorage: () => number;
getBatteryLevel: () => Promise<number>
getBatteryLevel: () => Promise<number>;
isLandscape: () => boolean;
};
export default _default;
/**
* @providesModule react-native-device-info
*/
import { Platform, NativeModules } from 'react-native';
import { Platform, NativeModules, Dimensions } from 'react-native';
var RNDeviceInfo = NativeModules.RNDeviceInfo;
......@@ -239,4 +239,8 @@ export default {
getBatteryLevel: function() {
return RNDeviceInfo.getBatteryLevel();
},
isLandscape: function() {
const { height, width } = Dimensions.get('window');
return width >= height;
}
};
......@@ -41,4 +41,5 @@ declare module.exports: {
getTotalDiskCapacity: () => number,
getFreeDiskStorage: () => number,
getBatteryLevel: () => Promise<number>,
isLandscape: () => boolean,
};
......@@ -38,5 +38,6 @@ module.exports = {
maxMemory: 0,
totalDiskCapacity: 0,
freeDiskStorage: 0,
getBatteryLevel: () => Promise.resolve(0)
getBatteryLevel: () => Promise.resolve(0),
isLandscape: false
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment