feat(visionos): ui-mobile-base supporting xros plus improvements to window handling (#10478)

This commit is contained in:
Nathan Walker
2024-04-05 17:07:16 -07:00
committed by GitHub
parent 9ca490250e
commit 01d537bf15
242 changed files with 8658 additions and 2099 deletions

View File

@@ -10,3 +10,4 @@ export const platformNames = {
export const isAndroid = !!__ANDROID__;
export const isIOS = !!__IOS__ || !!__VISIONOS__;
export const isVisionOS = !!__VISIONOS__;
export const isApple = !!__APPLE__;

View File

@@ -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.
*/

View File

@@ -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;