feat: apple view filtering (#10681)

[skip ci]
This commit is contained in:
Nathan Walker
2025-01-29 16:56:54 -08:00
committed by GitHub
parent f9e7088d07
commit 20fc1cc1d4
7 changed files with 14 additions and 8 deletions

View File

@ -10,7 +10,7 @@
<Button text="Pick and Save Image" tap="{{ pickImage }}" />
<ios>
<apple>
<!-- SF Symbols with Effects -->
<ContentView height="1" width="100%" backgroundColor="#efefef" margin="10"></ContentView>
<GridLayout rows="auto,auto,auto,auto,auto" columns="*,*">
@ -31,7 +31,7 @@
<Image row="4" col="1" src="sys://steeringwheel.and.hands" width="100" tintColor="black" iosSymbolEffect="{{symbolWiggleEffect}}" iosSymbolScale="large" padding="8" />
</GridLayout>
</ios>
</apple>
</StackLayout>

View File

@ -42,7 +42,7 @@ export type { ImageAssetOptions } from './image-asset';
export { ImageSource } from './image-source';
export { ModuleNameResolver, _setResolver } from './module-name-resolver';
export type { ModuleListProvider, PlatformContext } from './module-name-resolver';
export { isAndroid, isIOS, Screen, Device, platformNames } from './platform';
export { isAndroid, isIOS, isVisionOS, isApple, Screen, Device, platformNames } from './platform';
export type { IDevice } from './platform';
export { profile, enable as profilingEnable, disable as profilingDisable, time as profilingTime, uptime as profilingUptime, start as profilingStart, stop as profilingStop, isRunning as profilingIsRunning, dumpProfiles as profilingDumpProfiles, resetProfiles as profilingResetProfiles, startCPUProfile as profilingStartCPU, stopCPUProfile as profilingStopCPU } from './profiling';
export type { InstrumentationMode, TimerInfo } from './profiling';

View File

@ -33,7 +33,7 @@ export type { ImageAssetOptions } from './image-asset';
export { ImageSource } from './image-source';
export { ModuleNameResolver, _setResolver } from './module-name-resolver';
export type { ModuleListProvider, PlatformContext } from './module-name-resolver';
export { isAndroid, isIOS, Screen, Device, platformNames } from './platform';
export { isAndroid, isIOS, isVisionOS, isApple, Screen, Device, platformNames } from './platform';
export type { IDevice } from './platform';
// Profiling

View File

@ -5,6 +5,7 @@ export const platformNames = {
android: 'Android',
ios: 'iOS',
visionos: 'visionOS',
apple: 'apple',
};
export const isAndroid = !!__ANDROID__;

View File

@ -17,6 +17,7 @@ import { xml2ui } from './xml2ui';
export const ios = platformNames.ios.toLowerCase();
export const android = platformNames.android.toLowerCase();
export const visionos = platformNames.visionos.toLowerCase();
export const apple = platformNames.apple.toLowerCase();
export const defaultNameSpaceMatcher = /tns\.xsd$/i;
export interface LoadOptions {

View File

@ -6,7 +6,7 @@ import { getComponentModule } from './component-builder';
import type { ComponentModule } from './component-builder';
import { Device } from '../../platform';
import { profile } from '../../profiling';
import { android, ios, visionos, loadCustomComponent, defaultNameSpaceMatcher, getExports, Builder } from './index';
import { android, ios, visionos, apple, loadCustomComponent, defaultNameSpaceMatcher, getExports, Builder } from './index';
export namespace xml2ui {
/**
@ -135,14 +135,15 @@ export namespace xml2ui {
if (value) {
const toLower = value.toLowerCase();
return toLower === android || toLower === ios || toLower === visionos;
return toLower === android || toLower === ios || toLower === visionos || toLower === apple;
}
return false;
}
private static isCurentPlatform(value: string): boolean {
return value && value.toLowerCase() === Device.os.toLowerCase();
value = value && value.toLowerCase();
return value === apple ? __APPLE__ : value === Device.os.toLowerCase();
}
}

View File

@ -44,9 +44,12 @@ async function parseXML(content: string): Promise<ParseResult> {
const saxParser = parser(true, { xmlns: true });
// // Register ios and android prefixes as namespaces to avoid "unbound xml namespace" errors
// // Register platform prefixes as namespaces to avoid "unbound xml namespace" errors
(saxParser as any).ns['ios'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['visionos'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['apple'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['macos'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['win'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['android'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['desktop'] = 'http://schemas.nativescript.org/tns.xsd';
(saxParser as any).ns['web'] = 'http://schemas.nativescript.org/tns.xsd';