import { Platform, Dimensions } from "react-native"; export interface DeviceInfo { platform: "ios" | "android" | "web" | "windows" | "macos"; osVersion: string; screenWidth: number; screenHeight: number; windowWidth: number; windowHeight: number; scale: number; fontScale: number; deviceType?: "tablet" | "phone"; model: string; } const isTablet = (): boolean => { const { width, height } = Dimensions.get("screen"); const aspectRatio = height / width; return Math.min(width, height) >= 600 && aspectRatio < 1.6; }; const getDeviceModel = (): string => { try { const DeviceInfo = require('react-native-device-info'); if (DeviceInfo?.default?.getModel) { return DeviceInfo.default.getModel(); } if (DeviceInfo?.getModel) { return DeviceInfo.getModel(); } } catch (error) { // react-native-device-info não disponível } try { const constants = Platform.constants as any; if (constants?.Model) { return constants.Model; } if (constants?.model) { return constants.model; } } catch (error) { // Nada disponível } return 'unknown'; }; export const getDeviceInfo = (): DeviceInfo => { const screen = Dimensions.get("screen"); const window = Dimensions.get("window"); return { platform: Platform.OS, osVersion: Platform.Version.toString(), screenWidth: screen.width, screenHeight: screen.height, windowWidth: window.width, windowHeight: window.height, scale: screen.scale, fontScale: screen.fontScale, deviceType: isTablet() ? "tablet" : "phone", model: getDeviceModel(), }; };