diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Back.png b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Back.png new file mode 100644 index 0000000..3c46f1f Binary files /dev/null and b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Back.png differ diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..b87ebf6 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "filename" : "Back.png", + "idiom" : "reality", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Back.solidimagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Contents.json new file mode 100644 index 0000000..950af4d --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Contents.json @@ -0,0 +1,17 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "layers" : [ + { + "filename" : "Front.solidimagestacklayer" + }, + { + "filename" : "Middle.solidimagestacklayer" + }, + { + "filename" : "Back.solidimagestacklayer" + } + ] +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..49f496c --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "filename" : "Front.png", + "idiom" : "reality", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Front.png b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Front.png new file mode 100644 index 0000000..3a5ccaa Binary files /dev/null and b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Content.imageset/Front.png differ diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Front.solidimagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..52a7e86 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "filename" : "Middle.png", + "idiom" : "reality", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Middle.png b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Middle.png new file mode 100644 index 0000000..2475def Binary files /dev/null and b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset/Middle.png differ diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/AppIcon.solidimagestack/Middle.solidimagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/Contents.json b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/Info.plist b/apps/nativescript-demo-ng/App_Resources/visionOS/Info.plist new file mode 100644 index 0000000..fcdc9b2 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/Info.plist @@ -0,0 +1,58 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion∂ + 1.0 + LSRequiresIPhoneOS + + UIRequiresFullScreen + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + NSHandsTrackingUsageDescription + Use your hands to adjust lighting positions. + NSWorldSensingUsageDescription + To be able to place virtual contents in your surroundings. + UIApplicationSceneManifest + + UIApplicationPreferredDefaultSceneSessionRole + UIWindowSceneSessionRoleApplication + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + + + diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/build.xcconfig b/apps/nativescript-demo-ng/App_Resources/visionOS/build.xcconfig new file mode 100644 index 0000000..8bb8c51 --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/build.xcconfig @@ -0,0 +1,3 @@ +// DEVELOPMENT_TEAM = YOUR_TEAM_ID; +ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; +IPHONEOS_DEPLOYMENT_TARGET = 17.0; \ No newline at end of file diff --git a/apps/nativescript-demo-ng/App_Resources/visionOS/src/NativeScriptApp.swift b/apps/nativescript-demo-ng/App_Resources/visionOS/src/NativeScriptApp.swift new file mode 100644 index 0000000..f2eda5a --- /dev/null +++ b/apps/nativescript-demo-ng/App_Resources/visionOS/src/NativeScriptApp.swift @@ -0,0 +1,9 @@ +import SwiftUI + +@main +struct NativeScriptApp: App { + + var body: some Scene { + NativeScriptMainWindow() + } +} diff --git a/apps/nativescript-demo-ng/package.json b/apps/nativescript-demo-ng/package.json index 16848d6..2dc6992 100644 --- a/apps/nativescript-demo-ng/package.json +++ b/apps/nativescript-demo-ng/package.json @@ -3,13 +3,13 @@ "main": "./src/main.ts", "description": "NativeScript Application", "dependencies": { - "@nativescript/core": "file:../../node_modules/@nativescript/core", - "@nativescript-community/ui-material-bottom-navigation": "^7.2.0" + "@nativescript/core": "file:../../node_modules/@nativescript/core" }, "devDependencies": { "@nativescript/android": "~8.8.0", "@nativescript/ios": "~8.8.0", "@nativescript/tailwind": "^2.1.0", - "@nativescript/unit-test-runner": "^3.0.1" + "@nativescript/unit-test-runner": "^3.0.1", + "@nativescript/visionos": "8.8.1" } } diff --git a/apps/nativescript-demo-ng/src/app/item3/items.component.html b/apps/nativescript-demo-ng/src/app/item3/items.component.html index 79bb513..e1a1312 100644 --- a/apps/nativescript-demo-ng/src/app/item3/items.component.html +++ b/apps/nativescript-demo-ng/src/app/item3/items.component.html @@ -27,8 +27,23 @@ - - + + diff --git a/apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts b/apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts index 7d89e17..941f09c 100644 --- a/apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts +++ b/apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts @@ -1,7 +1,7 @@ // make sure you import mocha-config before @angular/core import { Component, ElementRef, NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { AndroidFilterComponent, DEVICE, IOSFilterComponent, NativeScriptModule } from '@nativescript/angular'; +import { AndroidFilterComponent, DEVICE, IOSFilterComponent, AppleFilterComponent, NativeScriptModule } from '@nativescript/angular'; import { platformNames } from '@nativescript/core/platform'; import { createDevice, dumpView } from './test-utils.spec'; @Component({ @@ -15,6 +15,17 @@ export class IosSpecificComponent { constructor(public elementRef: ElementRef) {} } +@Component({ + template: ` + + `, + imports: [AppleFilterComponent], + schemas: [NO_ERRORS_SCHEMA], +}) +export class AppleSpecificComponent { + constructor(public elementRef: ElementRef) {} +} + @Component({ template: ` @@ -71,6 +82,31 @@ describe('Platform filter directives', () => { }); }); + describe('on Apple device', () => { + beforeEach(() => { + return TestBed.configureTestingModule({ + imports: DECLARATIONS, + providers: [{ provide: DEVICE, useValue: createDevice(platformNames.ios) }], + schemas: [NO_ERRORS_SCHEMA], + }).compileComponents(); + }); + it('does render apple specific content', () => { + const fixture = TestBed.createComponent(AppleSpecificComponent); + fixture.detectChanges(); + const componentRef = fixture.componentRef; + const componentRoot = componentRef.instance.elementRef.nativeElement; + expect(dumpView(componentRoot, true).indexOf('(label[text=Apple])') >= 0).toBe(true); + }); + it('does not render android specific content', () => { + const fixture = TestBed.createComponent(AndroidSpecificComponent); + fixture.detectChanges(); + const componentRef = fixture.componentRef; + const componentRoot = componentRef.instance.elementRef.nativeElement; + console.log(dumpView(componentRoot, true)); + expect(dumpView(componentRoot, true).indexOf('label') < 0).toBe(true); + }); + }); + describe('on Android device', () => { beforeEach(() => { return TestBed.configureTestingModule({ diff --git a/package.json b/package.json index b229013..a952bb5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "workspace-generator": "nx workspace-generator", "demo.android": "nx debug nativescript-demo-ng android -c=prod", "demo.ios": "nx debug nativescript-demo-ng ios -c=prod", - "demo.clean": "nx clean nativescript-demo-ng clean", + "demo.vision": "nx debug nativescript-demo-ng visionos -c=prod", + "demo.clean": "nx clean nativescript-demo-ng", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" }, "dependencies": { diff --git a/packages/angular/src/lib/cdk/platform-filters/apple-filter.component.ts b/packages/angular/src/lib/cdk/platform-filters/apple-filter.component.ts new file mode 100644 index 0000000..30c27e7 --- /dev/null +++ b/packages/angular/src/lib/cdk/platform-filters/apple-filter.component.ts @@ -0,0 +1,13 @@ +/* eslint-disable @angular-eslint/component-selector */ +import { Component } from '@angular/core'; + +@Component({ + selector: 'apple', + template: `@if (show) { + + }`, + standalone: true, +}) +export class AppleFilterComponent { + public show = __APPLE__; +} diff --git a/packages/angular/src/lib/nativescript-common.module.ts b/packages/angular/src/lib/nativescript-common.module.ts index e60ee3f..1da5953 100644 --- a/packages/angular/src/lib/nativescript-common.module.ts +++ b/packages/angular/src/lib/nativescript-common.module.ts @@ -8,9 +8,10 @@ import { ModalDialogService } from './legacy/directives/dialogs'; import { TabViewDirective, TabViewItemDirective } from './cdk/tab-view'; import { AndroidFilterComponent } from './cdk/platform-filters/android-filter.component'; import { IOSFilterComponent } from './cdk/platform-filters/ios-filter.component'; +import { AppleFilterComponent } from './cdk/platform-filters/apple-filter.component'; import { VisionOSFilterComponent } from './cdk/platform-filters/vision-filter.component'; -const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent, VisionOSFilterComponent]; +const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent, AppleFilterComponent, VisionOSFilterComponent]; registerNativeScriptViewComponents(); diff --git a/packages/angular/src/lib/public_api.ts b/packages/angular/src/lib/public_api.ts index 6d47785..db8b663 100644 --- a/packages/angular/src/lib/public_api.ts +++ b/packages/angular/src/lib/public_api.ts @@ -32,6 +32,7 @@ export * from './cdk/portal'; export * from './cdk/dialog'; export * from './cdk/tab-view'; export * from './cdk/platform-filters/android-filter.component'; +export * from './cdk/platform-filters/apple-filter.component'; export * from './cdk/platform-filters/ios-filter.component'; export * from './cdk/platform-filters/vision-filter.component'; export * from './file-system';