mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(visionos): ui-mobile-base supporting xros plus improvements to window handling (#10478)
This commit is contained in:
@@ -10,3 +10,4 @@ export const platformNames = {
|
||||
export const isAndroid = !!__ANDROID__;
|
||||
export const isIOS = !!__IOS__ || !!__VISIONOS__;
|
||||
export const isVisionOS = !!__VISIONOS__;
|
||||
export const isApple = !!__APPLE__;
|
||||
|
||||
5
packages/core/platform/index.d.ts
vendored
5
packages/core/platform/index.d.ts
vendored
@@ -14,6 +14,11 @@ export const isAndroid: boolean;
|
||||
*/
|
||||
export const isIOS: boolean;
|
||||
|
||||
/**
|
||||
* Gets a value indicating if the app is running on an Apple platform.
|
||||
*/
|
||||
export const isApple: boolean;
|
||||
|
||||
/**
|
||||
* Gets a value indicating if the app is running on the iOS platform.
|
||||
*/
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
/* tslint:disable:class-name */
|
||||
|
||||
import { platformNames } from './common';
|
||||
|
||||
import { ios } from '../utils';
|
||||
export * from './common';
|
||||
|
||||
type DeviceType = 'Phone' | 'Tablet' | 'Vision';
|
||||
|
||||
class DeviceRef {
|
||||
private _model: string;
|
||||
private _osVersion: string;
|
||||
private _sdkVersion: string;
|
||||
private _deviceType: 'Phone' | 'Tablet';
|
||||
private _deviceType: DeviceType;
|
||||
|
||||
get manufacturer(): string {
|
||||
return 'Apple';
|
||||
}
|
||||
|
||||
get os(): string {
|
||||
return platformNames.ios;
|
||||
if (__VISIONOS__) {
|
||||
return platformNames.visionos;
|
||||
} else {
|
||||
return platformNames.ios;
|
||||
}
|
||||
}
|
||||
|
||||
get osVersion(): string {
|
||||
@@ -42,10 +48,14 @@ class DeviceRef {
|
||||
return this._sdkVersion;
|
||||
}
|
||||
|
||||
get deviceType(): 'Phone' | 'Tablet' {
|
||||
get deviceType(): DeviceType {
|
||||
if (!this._deviceType) {
|
||||
if (UIDevice.currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
|
||||
this._deviceType = 'Phone';
|
||||
} else if (UIDevice.currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Vision) {
|
||||
this._deviceType = 'Tablet';
|
||||
// TODO: could add conditions throughout core for this
|
||||
// this._deviceType = 'Vision';
|
||||
} else {
|
||||
this._deviceType = 'Tablet';
|
||||
}
|
||||
@@ -82,7 +92,9 @@ class MainScreen {
|
||||
|
||||
private get screen(): UIScreen {
|
||||
if (!this._screen) {
|
||||
this._screen = UIScreen.mainScreen;
|
||||
// NOTE: may not want to cache this value with SwiftUI app lifecycle based apps (using NativeScriptViewFactory) given the potential of multiple scenes
|
||||
const window = ios.getWindow();
|
||||
this._screen = window ? window.screen : UIScreen.mainScreen;
|
||||
}
|
||||
|
||||
return this._screen;
|
||||
|
||||
Reference in New Issue
Block a user