UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

25 lines (19 loc) 823 B
import { NativeModules, Platform } from "react-native"; /** * Determines wether the given device is a tablet based on dimensions, orientation, and platform * @param {Object} dimensions - Dimensions object passed to the function * @param {String} orientation - Orientation enum passed to the function * @returns {Boolean} isTablet - returns whether the given device is a tablet */ export const isTablet = (dimensions, orientation) => { if (Platform?.OS === "ios") { return Platform?.isPad; } else if (Platform?.OS === "android") { const { initialProps } = NativeModules.QuickBrickCommunicationModule; return initialProps?.is_tablet; } const { width } = dimensions; if (width < 600) return false; if (width >= 600 && width < 840) return orientation === "portrait"; return width >= 840; };