mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(compat): add screen and device aliases (#9088)
* fix: Add old names to platform for compatibility * Simplify code * fix: apply changes to definitions Co-authored-by: Igor Randjelovic <rigor789@gmail.com>
This commit is contained in:

committed by
GitHub

parent
ea67422fcf
commit
4204ac8308
@ -57,6 +57,9 @@ export class Screen {
|
|||||||
static mainScreen = new MainScreen();
|
static mainScreen = new MainScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This retains compatibility with NS6
|
||||||
|
export const screen = Screen;
|
||||||
|
|
||||||
class DeviceRef {
|
class DeviceRef {
|
||||||
private _manufacturer: string;
|
private _manufacturer: string;
|
||||||
private _model: string;
|
private _model: string;
|
||||||
@ -145,5 +148,8 @@ class DeviceRef {
|
|||||||
|
|
||||||
export const Device = new DeviceRef();
|
export const Device = new DeviceRef();
|
||||||
|
|
||||||
|
// This retains compatibility with NS6
|
||||||
|
export const device = Device;
|
||||||
|
|
||||||
export const isAndroid = global.isAndroid;
|
export const isAndroid = global.isAndroid;
|
||||||
export const isIOS = global.isIOS;
|
export const isIOS = global.isIOS;
|
||||||
|
14
packages/core/platform/index.d.ts
vendored
14
packages/core/platform/index.d.ts
vendored
@ -121,7 +121,21 @@ export class Screen {
|
|||||||
static mainScreen: ScreenMetrics;
|
static mainScreen: ScreenMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object describing general information about a display.
|
||||||
|
*
|
||||||
|
* This retains compatibility with NS6
|
||||||
|
*/
|
||||||
|
export const screen = Screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current device information.
|
* Gets the current device information.
|
||||||
*/
|
*/
|
||||||
export const Device: IDevice;
|
export const Device: IDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current device information.
|
||||||
|
*
|
||||||
|
* This retains compatibility with NS6
|
||||||
|
*/
|
||||||
|
export const device = Device;
|
||||||
|
@ -119,9 +119,15 @@ class MainScreen {
|
|||||||
|
|
||||||
export const Device = new DeviceRef();
|
export const Device = new DeviceRef();
|
||||||
|
|
||||||
|
// This retains compatibility with NS6
|
||||||
|
export const device = Device;
|
||||||
|
|
||||||
export class Screen {
|
export class Screen {
|
||||||
static mainScreen = new MainScreen();
|
static mainScreen = new MainScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This retains compatibility with NS6
|
||||||
|
export const screen = Screen;
|
||||||
|
|
||||||
export const isAndroid = global.isAndroid;
|
export const isAndroid = global.isAndroid;
|
||||||
export const isIOS = global.isIOS;
|
export const isIOS = global.isIOS;
|
||||||
|
Reference in New Issue
Block a user