UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

28 lines (22 loc) 880 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?: { width: number; height: number }, orientation?: string ) => { 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; };