UNPKG

@nativescript/core

Version:

A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.

41 lines 1.21 kB
import { Application } from '../../application'; class MainScreen { initMetrics() { const nativeApp = Application.android.getNativeApplication(); nativeApp.getSystemService(android.content.Context.WINDOW_SERVICE).getDefaultDisplay().getRealMetrics(this._metrics); } get metrics() { if (!this._metrics) { this._metrics = new android.util.DisplayMetrics(); this.initMetrics(); } return this._metrics; } get widthPixels() { return this.metrics.widthPixels; } get heightPixels() { return this.metrics.heightPixels; } get scale() { return this.metrics.density; } get widthDIPs() { return this.metrics.widthPixels / this.metrics.density; } get heightDIPs() { return this.metrics.heightPixels / this.metrics.density; } _updateMetrics() { if (!this._metrics) { this._metrics = new android.util.DisplayMetrics(); } this.initMetrics(); } } export class Screen { } Screen.mainScreen = new MainScreen(); // This retains compatibility with NS6 export const screen = Screen; //# sourceMappingURL=index.android.js.map