Commit 26a5615f authored by Diego Mello's avatar Diego Mello Committed by Mehdi Achour

feat: Add hasNotch() (#500)

parent e5abc1bf
......@@ -233,6 +233,7 @@ import DeviceInfo from 'react-native-device-info';
| [isEmulator()](#isemulator) | `boolean` | ✅ | ✅ | ✅ | ? |
| [isPinOrFingerprintSet()](#ispinorfingerprintset) | (callback)`boolean` | ✅ | ✅ | ✅ | 0.10.1 |
| [isTablet()](#istablet) | `boolean` | ✅ | ✅ | ✅ | ? |
| [hasNotch()](#hasNotch) | `boolean` | ✅ | ✅ | ✅ | ? |
---
......@@ -833,6 +834,18 @@ Tells if the device is a tablet.
const isTablet = DeviceInfo.isTablet(); // true
```
---
### hasNotch()
Tells if the device has a notch.
**Examples**
```js
const hasNotch = DeviceInfo.hasNotch(); // true
```
## Troubleshooting
When installing or using `react-native-device-info`, you may encounter the following problems:
......
......@@ -26,6 +26,7 @@ declare const _default: {
getFontScale: () => number;
is24Hour: () => boolean;
isPinOrFingerprintSet: (cb: (isPinOrFingerprintSet: boolean) => void) => void;
hasNotch: () => boolean;
getFirstInstallTime: () => number;
getLastUpdateTime: () => number;
getSerialNumber: () => string;
......
......@@ -9,6 +9,121 @@ if (!RNDeviceInfo && Platform.OS === 'web') {
RNDeviceInfo = require('./web');
}
const devicesWithNotch = [
{
brand: 'Apple',
model: 'iPhone X',
},
{
brand: 'Apple',
model: 'iPhone XS',
},
{
brand: 'Apple',
model: 'iPhone XS Max',
},
{
brand: 'Apple',
model: 'iPhone XR',
},
{
brand: 'Asus',
model: 'ZenFone 5',
},
{
brand: 'Asus',
model: 'ZenFone 5z',
},
{
brand: 'Huawei',
model: 'P20',
},
{
brand: 'Huawei',
model: 'P20 Plus',
},
{
brand: 'Huawei',
model: 'P20 Lite',
},
{
brand: 'Huawei',
model: 'Honor 10',
},
{
brand: 'Huawei',
model: 'Nova 3',
},
{
brand: 'Huawei',
model: 'Nova 3i',
},
{
brand: 'Oppo',
model: 'R15',
},
{
brand: 'Oppo',
model: 'R15 Pro',
},
{
brand: 'Oppo',
model: 'F7',
},
{
brand: 'Vivo',
model: 'V9',
},
{
brand: 'Vivo',
model: 'X21',
},
{
brand: 'Vivo',
model: 'X21 UD',
},
{
brand: 'OnePlus',
model: '6',
},
{
brand: 'OnePlus',
model: 'A6003',
},
{
brand: 'OnePlus',
model: 'OnePlus A6003',
},
{
brand: 'LG',
model: 'G7',
},
{
brand: 'LG',
model: 'G7 ThinQ',
},
{
brand: 'LG',
model: 'G7+ ThinQ',
},
{
brand: 'Leagoo',
model: 'S9',
},
{
brand: 'Oukitel',
model: 'U18',
},
{
brand: 'Sharp',
model: 'Aquos S3',
},
{
brand: 'Nokia',
model: '6.1 Plus',
},
];
export default {
getUniqueID: function() {
return RNDeviceInfo.uniqueId;
......@@ -91,6 +206,9 @@ export default {
isPinOrFingerprintSet: function() {
return RNDeviceInfo.isPinOrFingerprintSet;
},
hasNotch: function() {
return devicesWithNotch.findIndex(item => item.brand === RNDeviceInfo.brand && item.model === RNDeviceInfo.model) !== -1;
},
getFirstInstallTime: function() {
return RNDeviceInfo.firstInstallTime;
},
......
......@@ -27,6 +27,7 @@ declare module.exports: {
isPinOrFingerprintSet: () => (
cb: (isPinOrFingerprintSet: boolean) => void
) => void,
hasNotch: () => boolean,
getFirstInstallTime: () => number,
getLastUpdateTime: () => number,
getSerialNumber: () => string,
......
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