8000 feat: apple view filtering (#10681) · NativeScript/NativeScript@20fc1cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 20fc1cc

Browse files
authored
feat: apple view filtering (#10681)
[skip ci]
1 parent f9e7088 commit 20fc1cc

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

apps/toolbox/src/pages/image-handling.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<Button text="Pick and Save Image" tap="{{ pickImage }}" />
1212

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

3333
</GridLayout>
34-
</ios>
34+
</apple>
3535

3636

3737
</StackLayout>

packages/core/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type { ImageAssetOptions } from './image-asset';
4242
export { ImageSource } from './image-source';
4343
export { ModuleNameResolver, _setResolver } from './module-name-resolver';
4444
export type { ModuleListProvider, PlatformContext } from './module-name-resolver';
45-
export { isAndroid, isIOS, Screen, Device, platformNames } from './platform';
45+
export { isAndroid, isIOS, isVisionOS, isApple, Screen, Device, platformNames } from './platform';
4646
export type { IDevice } from './platform';
4747
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';
4848
export type { InstrumentationMode, TimerInfo } from './profiling';

packages/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type { ImageAssetOptions } from './image-asset';
3333
export { ImageSource } from './image-source';
3434
export { ModuleNameResolver, _setResolver } from './module-name-resolver';
3535
export type { ModuleListProvider, PlatformContext } from './module-name-resolver';
36-
export { isAndroid, isIOS, Screen, Device, platformNames } from './platform';
36+
export { isAndroid, isIOS, isVisionOS, isApple, Screen, Device, platformNames } from './platform';
3737
export type { IDevice } from './platform';
3838

3939
// Profiling

packages/core/platform/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const platformNames = {
55
android: 'Android',
66
ios: 'iOS',
77
visionos: 'visionOS',
8+
apple: 'apple',
89
};
910

1011
export const isAndroid = !!__ANDROID__;

packages/core/ui/builder/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { xml2ui } from './xml2ui';
1717
export const ios = platformNames.ios.toLowerCase();
1818
export const android = platformNames.android.toLowerCase();
1919
export const visionos = platformNames.visionos.toLowerCase();
20+
export const apple = platformNames.apple.toLowerCase();
2021
export const defaultNameSpaceMatcher = /tns\.xsd$/i;
2122

2223
export interface LoadOptions {

packages/core/ui/builder/xml2ui.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getComponentModule } from './component-builder';
66
import type { ComponentModule } from './component-builder';
77
import { Device } from '../../platform';
88
import { profile } from '../../profiling';
9-
import { android, ios, visionos, loadCustomComponent, defaultNameSpaceMatcher, getExports, Builder } from './index';
9+
import { android, ios, visionos, apple, loadCustomComponent, defaultNameSpaceMatcher, getExports, Builder } from './index';
1010

1111
export namespace xml2ui {
1212
/**
@@ -135,14 +135,15 @@ export namespace xml2ui {
135135
if (value) {
136136
const toLower = value.toLowerCase();
137137

138-
return toLower === android || toLower === ios || toLower === visionos;
138+
return toLower === android || toLower === ios || toLower === visionos || toLower === apple;
139139
}
140140

141141
return false;
142142
}
143143

144144
private static isCurentPlatform(value: string): boolean {
145-
return value && value.toLowerCase() === Device.os.toLowerCase();
145+
value = value && value.toLowerCase();
146+
return value === apple ? __APPLE__ : value === Device.os.toLowerCase();
146147
}
147148
}
148149

packages/webpack5/src/loaders/xml-namespace-loader/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ async function parseXML(content: string): Promise<ParseResult> {
4444

4545
const saxParser = parser(true, { xmlns: true });
4646

47-
// // Register ios and android prefixes as namespaces to avoid "unbound xml namespace" errors
47+
// // Register platform prefixes as namespaces to avoid "unbound xml namespace" errors
4848
(saxParser as any).ns['ios'] = 'http://schemas.nativescript.org/tns.xsd';
4949
(saxParser as any).ns['visionos'] = 'http://schemas.nativescript.org/tns.xsd';
50+
(saxParser as any).ns['apple'] = 'http://schemas.nativescript.org/tns.xsd';
51+
(saxParser as any).ns['macos'] = 'http://schemas.nativescript.org/tns.xsd';
52+
(saxParser as any).ns['win'] = 'http://schemas.nativescript.org/tns.xsd';
5053
(saxParser as any).ns['android'] = 'http://schemas.nativescript.org/tns.xsd';
5154
(saxParser as any).ns['desktop'] = 'http://schemas.nativescript.org/tns.xsd';
5255
(saxParser as any).ns['web'] = 'http://schemas.nativescript.org/tns.xsd';

0 commit comments

Comments
 (0)
0