Skip to content

Commit f5431bd

Browse files
authored
feat: apple view filter to cover ios and visionos together (#148)
1 parent 02c218f commit f5431bd

File tree

21 files changed

+225
-8
lines changed

21 files changed

+225
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Back.png",
5+
"idiom" : "reality",
6+
"scale" : "2x"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
},
6+
"layers" : [
7+
{
8+
"filename" : "Front.solidimagestacklayer"
9+
},
10+
{
11+
"filename" : "Middle.solidimagestacklayer"
12+
},
13+
{
14+
"filename" : "Back.solidimagestacklayer"
15+
}
16+
]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Front.png",
5+
"idiom" : "reality",
6+
"scale" : "2x"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Middle.png",
5+
"idiom" : "reality",
6+
"scale" : "2x"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>${PRODUCT_NAME}</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>1.0</string>
23+
<key>LSRequiresIPhoneOS</key>
24+
<true/>
25+
<key>UIRequiresFullScreen</key>
26+
<true/>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
<key>UISupportedInterfaceOrientations~ipad</key>
38+
<array>
39+
<string>UIInterfaceOrientationPortrait</string>
40+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
41+
<string>UIInterfaceOrientationLandscapeLeft</string>
42+
<string>UIInterfaceOrientationLandscapeRight</string>
43+
</array>
44+
<key>NSHandsTrackingUsageDescription</key>
45+
<string>Use your hands to adjust lighting positions.</string>
46+
<key>NSWorldSensingUsageDescription</key>
47+
<string>To be able to place virtual contents in your surroundings.</string>
48+
<key>UIApplicationSceneManifest</key>
49+
<dict>
50+
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
51+
<string>UIWindowSceneSessionRoleApplication</string>
52+
<key>UIApplicationSupportsMultipleScenes</key>
53+
<true/>
54+
<key>UISceneConfigurations</key>
55+
<dict/>
56+
</dict>
57+
</dict>
58+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
2+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
3+
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import SwiftUI
2+
3+
@main
4+
struct NativeScriptApp: App {
5+
6+
var body: some Scene {
7+
NativeScriptMainWindow()
8+
}
9+
}

apps/nativescript-demo-ng/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"main": "./src/main.ts",
44
"description": "NativeScript Application",
55
"dependencies": {
6-
"@nativescript/core": "file:../../node_modules/@nativescript/core",
7-
"@nativescript-community/ui-material-bottom-navigation": "^7.2.0"
6+
"@nativescript/core": "file:../../node_modules/@nativescript/core"
87
},
98
"devDependencies": {
109
"@nativescript/android": "~8.8.0",
1110
"@nativescript/ios": "~8.8.0",
1211
"@nativescript/tailwind": "^2.1.0",
13-
"@nativescript/unit-test-runner": "^3.0.1"
12+
"@nativescript/unit-test-runner": "^3.0.1",
13+
"@nativescript/visionos": "8.8.1"
1414
}
1515
}

apps/nativescript-demo-ng/src/app/item3/items.component.html

+17-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,23 @@
2727
<Label [text]="message" class="text-3xl font-bold text-center text-blue-500"></Label>
2828
<Image src="~/assets/angular.png" class="w-[200] h-center mb-2 align-top"></Image>
2929
<!-- <Button (tap)="openModal()" text="Taste the Rainbow 🌈" [borderRadius]="borderRadius" [fontSize]="fontSize" backgroundColor="#00d2ff" color="#fff" margin="0" width="100%" fontWeight="bold" height="50"></Button> -->
30-
<Button (tap)="openModal()" text="Open Modal" [borderRadius]="borderRadius" [fontSize]="fontSize" backgroundColor="#00d2ff" class="text-white w-full font-bold h-[50]"></Button>
31-
<Button (tap)="fetchTodos()" text="Make a native Http networking request" [borderRadius]="borderRadius" [fontSize]="fontSize" padding="0" backgroundColor="#00d2ff" class="text-white mt-2 w-full font-bold h-[50]"></Button>
30+
<Button
31+
(tap)="openModal()"
32+
text="Open Modal"
33+
[borderRadius]="borderRadius"
34+
[fontSize]="fontSize"
35+
backgroundColor="#00d2ff"
36+
class="text-white w-full font-bold h-[50]"
37+
></Button>
38+
<Button
39+
(tap)="fetchTodos()"
40+
text="Make a native Http networking request"
41+
[borderRadius]="borderRadius"
42+
[fontSize]="fontSize"
43+
padding="0"
44+
backgroundColor="#00d2ff"
45+
class="text-white mt-2 w-full font-bold h-[50]"
46+
></Button>
3247
</StackLayout>
3348
<ListView row="1" [items]="items" backgroundColor="#efefef">
3449
<ng-template let-item="item">

apps/nativescript-demo-ng/src/tests/platform-filter-components.spec.ts

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// make sure you import mocha-config before @angular/core
22
import { Component, ElementRef, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
33
import { TestBed } from '@angular/core/testing';
4-
import { AndroidFilterComponent, DEVICE, IOSFilterComponent, NativeScriptModule } from '@nativescript/angular';
4+
import { AndroidFilterComponent, DEVICE, IOSFilterComponent, AppleFilterComponent, NativeScriptModule } from '@nativescript/angular';
55
import { platformNames } from '@nativescript/core/platform';
66
import { createDevice, dumpView } from './test-utils.spec';
77
@Component({
@@ -15,6 +15,17 @@ export class IosSpecificComponent {
1515
constructor(public elementRef: ElementRef) {}
1616
}
1717

18+
@Component({
19+
template: ` <StackLayout>
20+
<apple><Label text="Apple"></Label></apple>
21+
</StackLayout>`,
22+
imports: [AppleFilterComponent],
23+
schemas: [NO_ERRORS_SCHEMA],
24+
})
25+
export class AppleSpecificComponent {
26+
constructor(public elementRef: ElementRef) {}
27+
}
28+
1829
@Component({
1930
template: ` <StackLayout>
2031
<android><Label text="ANDROID"></Label></android>
@@ -71,6 +82,31 @@ describe('Platform filter directives', () => {
7182
});
7283
});
7384

85+
describe('on Apple device', () => {
86+
beforeEach(() => {
87+
return TestBed.configureTestingModule({
88+
imports: DECLARATIONS,
89+
providers: [{ provide: DEVICE, useValue: createDevice(platformNames.ios) }],
90+
schemas: [NO_ERRORS_SCHEMA],
91+
}).compileComponents();
92+
});
93+
it('does render apple specific content', () => {
94+
const fixture = TestBed.createComponent(AppleSpecificComponent);
95+
fixture.detectChanges();
96+
const componentRef = fixture.componentRef;
97+
const componentRoot = componentRef.instance.elementRef.nativeElement;
98+
expect(dumpView(componentRoot, true).indexOf('(label[text=Apple])') >= 0).toBe(true);
99+
});
100+
it('does not render android specific content', () => {
101+
const fixture = TestBed.createComponent(AndroidSpecificComponent);
102+
fixture.detectChanges();
103+
const componentRef = fixture.componentRef;
104+
const componentRoot = componentRef.instance.elementRef.nativeElement;
105+
console.log(dumpView(componentRoot, true));
106+
expect(dumpView(componentRoot, true).indexOf('label') < 0).toBe(true);
107+
});
108+
});
109+
74110
describe('on Android device', () => {
75111
beforeEach(() => {
76112
return TestBed.configureTestingModule({

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"workspace-generator": "nx workspace-generator",
3232
"demo.android": "nx debug nativescript-demo-ng android -c=prod",
3333
"demo.ios": "nx debug nativescript-demo-ng ios -c=prod",
34-
"demo.clean": "nx clean nativescript-demo-ng clean",
34+
"demo.vision": "nx debug nativescript-demo-ng visionos -c=prod",
35+
"demo.clean": "nx clean nativescript-demo-ng",
3536
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
3637
},
3738
"dependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-disable @angular-eslint/component-selector */
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
selector: 'apple',
6+
template: `@if (show) {
7+
<ng-content></ng-content>
8+
}`,
9+
standalone: true,
10+
})
11+
export class AppleFilterComponent {
12+
public show = __APPLE__;
13+
}

packages/angular/src/lib/nativescript-common.module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { ModalDialogService } from './legacy/directives/dialogs';
88
import { TabViewDirective, TabViewItemDirective } from './cdk/tab-view';
99
import { AndroidFilterComponent } from './cdk/platform-filters/android-filter.component';
1010
import { IOSFilterComponent } from './cdk/platform-filters/ios-filter.component';
11+
import { AppleFilterComponent } from './cdk/platform-filters/apple-filter.component';
1112
import { VisionOSFilterComponent } from './cdk/platform-filters/vision-filter.component';
1213

13-
const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent, VisionOSFilterComponent];
14+
const CDK_COMPONENTS = [ActionBarComponent, ActionBarScope, ActionItemDirective, NavigationButtonDirective, ListViewComponent, TemplateKeyDirective, TabViewDirective, TabViewItemDirective, AndroidFilterComponent, IOSFilterComponent, AppleFilterComponent, VisionOSFilterComponent];
1415

1516
registerNativeScriptViewComponents();
1617

packages/angular/src/lib/public_api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export * from './cdk/portal';
3232
export * from './cdk/dialog';
3333
export * from './cdk/tab-view';
3434
export * from './cdk/platform-filters/android-filter.component';
35+
export * from './cdk/platform-filters/apple-filter.component';
3536
export * from './cdk/platform-filters/ios-filter.component';
3637
export * from './cdk/platform-filters/vision-filter.component';
3738
export * from './file-system';

0 commit comments

Comments
 (0)