Skip to content

feat: apple view filtering #10681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/toolbox/src/pages/image-handling.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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="*,*">
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/core/platform/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const platformNames = {
android: 'Android',
ios: 'iOS',
visionos: 'visionOS',
apple: 'apple',
};

export const isAndroid = !!__ANDROID__;
Expand Down
1 change: 1 addition & 0 deletions packages/core/ui/builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions packages/core/ui/builder/xml2ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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();
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/webpack5/src/loaders/xml-namespace-loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading