Skip to content

Commit 8931415

Browse files
authored
Merge branch 'master' into minor-fixes
2 parents ed6954a + 9dfc569 commit 8931415

File tree

15 files changed

+238
-92
lines changed

15 files changed

+238
-92
lines changed

build-docs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set -e
2+
3+
ENV="${ENV:-dev}"
4+
DIST_DIR="nativescript-angular/bin/dist"
5+
APIREF_DIR="$DIST_DIR/ng-api-reference"
6+
rm -rf "$APIREF_DIR"
7+
cd "nativescript-angular"
8+
npm install
9+
npm run typedoc

e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewContainerRef, Input } from "@angular/core";
1+
import { Component, ViewContainerRef, Input, ViewChild, ElementRef } from "@angular/core";
22
import { Router, NavigationEnd } from "@angular/router";
33
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
44
import { ModalComponent } from "../modal/modal.component";
@@ -17,19 +17,21 @@ import { ModalViewComponent } from "~/modal-shared/modal-view.component";
1717
<Button text="Show Modal Page With Frame" (tap)="onModalFrame()" textAlignment="left"></Button>
1818
<Button text="Show Shared Modal" (tap)="onRootModalTap()" textAlignment="left"></Button>
1919
<Button text="Show Dialog" (tap)="onShowDialog()" textAlignment="left"></Button>
20+
<Button #popoverButtonComp text="Show 'popover' modal" (tap)="onPopoverModal()" textAlignment="left"></Button>
2021
</StackLayout>`
2122
})
2223

2324
export class BasicsNavigationComponent {
2425

26+
@ViewChild("popoverButtonComp") popoverButtonComp: ElementRef;
2527
@Input() col: number;
2628
constructor(
2729
private modal: ModalDialogService,
2830
private router: Router,
2931
private vcf: ViewContainerRef,
3032
private viewContainerRefService: ViewContainerRefService) {
3133
}
32-
34+
3335
onModalNoFrame() {
3436
const options: ModalDialogOptions = {
3537
context: {
@@ -74,14 +76,28 @@ export class BasicsNavigationComponent {
7476

7577
onRootModalTap(): void {
7678
const options: ModalDialogOptions = {
77-
viewContainerRef: this.viewContainerRefService.root,
78-
context: {},
79-
fullscreen: true
79+
viewContainerRef: this.viewContainerRefService.root,
80+
context: {},
81+
fullscreen: true
8082
};
81-
83+
8284
this.modal.showModal(ModalViewComponent, options)
83-
.then((result: string) => {
84-
console.log(result);
85-
});
86-
}
85+
.then((result: string) => {
86+
console.log(result);
87+
});
88+
}
89+
90+
onPopoverModal() {
91+
const options: ModalDialogOptions = {
92+
viewContainerRef: this.viewContainerRefService.root,
93+
context: {},
94+
ios: {
95+
presentationStyle: UIModalPresentationStyle.Popover
96+
},
97+
target: this.popoverButtonComp.nativeElement
98+
};
99+
100+
this.modal.showModal(ModalViewComponent, options)
101+
.then((result: string) => { console.log(result);});
102+
}
87103
}

e2e/modal-navigation-ng/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"nativescript-dev-appium": "next",
4747
"nativescript-dev-typescript": "next",
4848
"nativescript-dev-webpack": "next",
49+
"tns-platform-declarations": "next",
4950
"typescript": "~3.1.1"
5051
},
5152
"scripts": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />

e2e/single-page/app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.title {
2-
font-size: 30;
2+
font-size: 15;
33
margin: 16;
44
}
55

e2e/single-page/app/app.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ import { AppComponent } from "./app.component";
1111

1212
import { rendererTraceCategory, viewUtilCategory, routeReuseStrategyTraceCategory, routerTraceCategory } from "nativescript-angular/trace";
1313
import { setCategories, enable } from "tns-core-modules/trace";
14+
import { ModalComponent } from "./second/modal/modal.component";
1415
setCategories(routerTraceCategory + "," + routeReuseStrategyTraceCategory);
1516
enable();
1617

1718
@NgModule({
1819
declarations: [
1920
AppComponent,
21+
ModalComponent,
2022
...navigatableComponents,
2123
],
24+
entryComponents:[
25+
ModalComponent
26+
],
2227
bootstrap: [AppComponent],
2328
providers: [
2429
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<StackLayout>
2+
<Label text="Welcome to modal"></Label>
3+
<Button text="Close Modal" (tap)="close()"></Button>
4+
</StackLayout>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component } from '@angular/core';
2+
import { ModalDialogParams } from "nativescript-angular/modal-dialog";
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'modal',
7+
templateUrl: './modal.component.html'
8+
})
9+
10+
export class ModalComponent {
11+
12+
constructor(private params: ModalDialogParams) {
13+
}
14+
15+
public close() {
16+
this.params.closeCallback();
17+
}
18+
19+
}

e2e/single-page/app/second/second.component.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { Component, OnInit, OnDestroy } from "@angular/core";
1+
import { Component, OnInit, OnDestroy, ViewContainerRef } from "@angular/core";
22
import { ActivatedRoute, Router, Route } from "@angular/router";
33

4+
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular";
45
import { Page } from "tns-core-modules/ui/page";
56
import { Observable } from "rxjs";
67
import { map } from "rxjs/operators";
78
import { RouterExtensions } from "nativescript-angular/router";
9+
import { ModalComponent } from "./modal/modal.component";
810

911
@Component({
1012
selector: "second",
@@ -19,12 +21,16 @@ import { RouterExtensions } from "nativescript-angular/router";
1921
2022
<StackLayout>
2123
<Label [text]="'Second Component: ' + (id$ | async)" class="title"></Label>
24+
<Button text="Show Modal" (tap)="onShowModal()"></Button>
2225
<Button text="Back" (tap)="back()"></Button>
2326
</StackLayout>`
2427
})
2528
export class SecondComponent implements OnInit, OnDestroy {
2629
public id$: Observable<number>;
27-
constructor(route: ActivatedRoute, private routerExtensions: RouterExtensions) {
30+
constructor(route: ActivatedRoute,
31+
private routerExtensions: RouterExtensions,
32+
private viewContainerRef: ViewContainerRef,
33+
private modalService: ModalDialogService) {
2834
this.id$ = route.params.pipe(map(r => +r["id"]));
2935
}
3036

@@ -39,4 +45,16 @@ export class SecondComponent implements OnInit, OnDestroy {
3945
back() {
4046
this.routerExtensions.back();
4147
}
48+
49+
onShowModal() {
50+
let options: ModalDialogOptions = {
51+
viewContainerRef: this.viewContainerRef,
52+
context: {
53+
},
54+
fullscreen: true
55+
};
56+
57+
this.modalService.showModal(ModalComponent, options).then((dialogResult: string) => {
58+
});
59+
}
4260
}

e2e/single-page/e2e/tests.e2e-spec.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,45 @@ describe("Single page app", () => {
1919
});
2020

2121
it("should load second(1) page", async () => {
22-
await findAndClick(driver, "SECOND(1)")
22+
await findAndClick(driver, "SECOND(1)");
2323

2424
await driver.findElementByAutomationText("Second Component: 1");
25-
25+
2626
// ActionBar Title and item
2727
await driver.findElementByAutomationText("Second Title");
2828
await driver.findElementByAutomationText("ACTION2");
2929
});
3030

3131
it("should load second(2) page", async () => {
32-
await findAndClick(driver, "SECOND(2)")
32+
await findAndClick(driver, "SECOND(2)");
33+
34+
await driver.findElementByAutomationText("Second Component: 2");
3335

34-
await driver.findElementByAutomationText("Second Component: 1");
35-
3636
// ActionBar Title and items
3737
await driver.findElementByAutomationText("Second Title");
3838
await driver.findElementByAutomationText("ACTION2");
3939
await driver.findElementByAutomationText("ADD");
4040
});
41+
42+
it("should open and close modal view", async () => {
43+
await findAndClick(driver, "Show Modal");
44+
45+
await driver.findElementByAutomationText("Welcome to modal");
46+
await findAndClick(driver, "Close Modal");
47+
48+
await driver.findElementByAutomationText("Second Component: 2");
49+
});
50+
51+
it("should go back to second(1) and first", async () => {
52+
await findAndClick(driver, "Back");
53+
await driver.findElementByAutomationText("Second Component: 1");
54+
await findAndClick(driver, "Back");
55+
await driver.findElementByAutomationText("First Title");
56+
await driver.findElementByAutomationText("ACTION1");
57+
});
4158
});
4259

4360
async function findAndClick(driver: AppiumDriver, text: string) {
44-
const navigationButton =
45-
await driver.findElementByAutomationText(text);
46-
navigationButton.click();
61+
const navigationButton = await driver.findElementByAutomationText(text);
62+
await navigationButton.click();
4763
}

0 commit comments

Comments
 (0)