refactor: improved core barrel exports and Application class (#10286)

BREAKING CHANGES:

`Application.orientation` is no longer a function.

Migration: Remove `()` from the `Application.orientation()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.orientation());
+console.log(Application.orientation);
```


`Application.systemAppearance` is no longer a function.

Migration: Remove `()` from the `Application.systemAppearance()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);
```
This commit is contained in:
Igor Randjelovic
2023-05-17 21:02:06 +02:00
committed by Nathan Walker
parent 963d0243de
commit f64355ba7a
67 changed files with 3536 additions and 3678 deletions

View File

@@ -1,5 +1,5 @@
/* tslint:disable:class-name */
import { getNativeApplication, on, orientationChangedEvent, android as AndroidApplication } from '../application';
import { Application } from '../application';
import { SDK_VERSION } from '../utils/constants';
const MIN_TABLET_PIXELS = 600;
@@ -20,15 +20,15 @@ class MainScreen {
}
private initMetrics(): void {
const nativeApp = <android.app.Application>getNativeApplication();
const nativeApp = Application.android.getNativeApplication();
nativeApp.getSystemService(android.content.Context.WINDOW_SERVICE).getDefaultDisplay().getRealMetrics(this._metrics);
}
private get metrics(): android.util.DisplayMetrics {
if (!this._metrics) {
// NOTE: This will be memory leak but we MainScreen is singleton
on('cssChanged', this.reinitMetrics, this);
on(orientationChangedEvent, this.reinitMetrics, this);
Application.on('cssChanged', this.reinitMetrics, this);
Application.on(Application.orientationChangedEvent, this.reinitMetrics, this);
this._metrics = new android.util.DisplayMetrics();
this.initMetrics();
@@ -121,7 +121,7 @@ class DeviceRef {
get uuid(): string {
if (!this._uuid) {
const nativeApp = <android.app.Application>AndroidApplication.nativeApp;
const nativeApp = Application.android.getNativeApplication();
this._uuid = android.provider.Settings.Secure.getString(nativeApp.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
}