From a36a2f2c91661b32e12b2329df74b67c4a4da9de Mon Sep 17 00:00:00 2001 From: Dylan Llewellyn <46717769+herefishyfish@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:58:43 +0800 Subject: [PATCH 1/2] feat: visionos platform filter --- .../platform-filters/vision-filter.component.ts | 16 ++++++++++++++++ .../src/lib/nativescript-common.module.ts | 3 ++- packages/angular/src/lib/public_api.ts | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts diff --git a/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts b/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts new file mode 100644 index 0000000..fcb4ef7 --- /dev/null +++ b/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts @@ -0,0 +1,16 @@ +/* eslint-disable @angular-eslint/component-selector */ +import { Component, Inject } from '@angular/core'; +import { platformNames, IDevice } from '@nativescript/core'; +import { DEVICE } from '../../tokens'; + +@Component({ + selector: 'visionos', + template: ``, +}) +export class VisionOSFilterComponent { + public show: boolean; + + constructor(@Inject(DEVICE) device: IDevice) { + this.show = device.os === platformNames.visionos; + } +} diff --git a/packages/angular/src/lib/nativescript-common.module.ts b/packages/angular/src/lib/nativescript-common.module.ts index 3bc6315..67b6b04 100644 --- a/packages/angular/src/lib/nativescript-common.module.ts +++ b/packages/angular/src/lib/nativescript-common.module.ts @@ -8,8 +8,9 @@ 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 { VisionOSFilterComponent } from './cdk/platform-filters/vision-filter.component'; -const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent]; +const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent, VisionOSFilterComponent]; registerNativeScriptViewComponents(); diff --git a/packages/angular/src/lib/public_api.ts b/packages/angular/src/lib/public_api.ts index 6aff2d9..aa008bd 100644 --- a/packages/angular/src/lib/public_api.ts +++ b/packages/angular/src/lib/public_api.ts @@ -16,6 +16,7 @@ export * from './cdk/dialog'; export * from './cdk/tab-view'; export * from './cdk/platform-filters/android-filter.component'; export * from './cdk/platform-filters/ios-filter.component'; +export * from './cdk/platform-filters/vision-filter.component'; export * from './file-system'; export * from './nativescript-common.module'; export * from './loading.service'; From 272ba583c933837558868b67f74fbe7c035ad4cb Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 10 Oct 2023 08:29:45 -0700 Subject: [PATCH 2/2] chore: make backwards compatible --- .../src/lib/cdk/platform-filters/vision-filter.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts b/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts index fcb4ef7..b84bdef 100644 --- a/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts +++ b/packages/angular/src/lib/cdk/platform-filters/vision-filter.component.ts @@ -11,6 +11,8 @@ export class VisionOSFilterComponent { public show: boolean; constructor(@Inject(DEVICE) device: IDevice) { - this.show = device.os === platformNames.visionos; + // Note: casting any to be backwards compatible + // Available in 8.6+ only + this.show = device.os === (platformNames as any).visionos; } }