2019-01-29 19:52:56 +00:00
|
|
|
import { Platform } from 'react-native';
|
2018-09-19 14:18:32 +00:00
|
|
|
import DeviceInfo from 'react-native-device-info';
|
|
|
|
|
2019-11-25 20:01:17 +00:00
|
|
|
import { MIN_WIDTH_SPLIT_LAYOUT } from '../constants/tablet';
|
|
|
|
|
2018-09-26 13:56:36 +00:00
|
|
|
const NOTCH_DEVICES = ['iPhone X', 'iPhone XS', 'iPhone XS Max', 'iPhone XR'];
|
|
|
|
|
2019-01-29 19:52:56 +00:00
|
|
|
export const isNotch = NOTCH_DEVICES.includes(DeviceInfo.getModel());
|
|
|
|
export const isIOS = Platform.OS === 'ios';
|
|
|
|
export const isAndroid = !isIOS;
|
|
|
|
export const getReadableVersion = DeviceInfo.getReadableVersion();
|
2019-02-07 15:48:10 +00:00
|
|
|
export const getBundleId = DeviceInfo.getBundleId();
|
2019-06-11 14:01:40 +00:00
|
|
|
export const getDeviceModel = DeviceInfo.getModel();
|
2019-11-25 20:01:17 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
// Theme is supported by system on iOS 13+ or Android 10+
|
|
|
|
export const supportSystemTheme = () => {
|
|
|
|
const systemVersion = parseInt(DeviceInfo.getSystemVersion(), 10);
|
|
|
|
return systemVersion >= (isIOS ? 13 : 10);
|
|
|
|
};
|
|
|
|
|
2019-11-25 20:01:17 +00:00
|
|
|
// Tablet info
|
|
|
|
export const isTablet = DeviceInfo.isTablet();
|
|
|
|
|
|
|
|
// We need to use this when app is used on splitview with another app
|
|
|
|
// to handle cases on app view not-larger sufficient to show splited views (room list/room)
|
|
|
|
// https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/1300#discussion_r341405245
|
|
|
|
let _width = null;
|
|
|
|
export const setWidth = width => _width = width;
|
|
|
|
export const isSplited = () => isTablet && _width > MIN_WIDTH_SPLIT_LAYOUT;
|