Skip to content

Commit c9dc826

Browse files
author
VladimirAmiorkov
committed
chore: add example that shows "popover" mode for modal service
1 parent a4282ff commit c9dc826

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

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

Lines changed: 27 additions & 11 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 } 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";
@@ -16,20 +16,22 @@ import { ModalViewComponent } from "~/modal-shared/modal-view.component";
1616
<Button text="Show Modal Without Frame" (tap)="onModalNoFrame()" textAlignment="left"></Button>
1717
<Button text="Show Modal Page With Frame" (tap)="onModalFrame()" textAlignment="left"></Button>
1818
<Button text="Show Shared Modal" (tap)="onRootModalTap()" textAlignment="left"></Button>
19-
<Button text="Show Dialog" (tap)="onShowDialog()" textAlignment="left"></Button>
19+
<Button #popoverButtonComp text="Show Dialog" (tap)="onShowDialog()" textAlignment="left"></Button>
20+
<Button text="Show 'popover' modal" (tap)="onPopoverModal()" textAlignment="left"></Button>
2021
</StackLayout>`
2122
})
2223

2324
export class BasicsNavigationComponent {
2425

26+
@ViewChild("popoverButtonComp") popoverButtonComp;
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+
sourceView: this.popoverButtonComp
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" />

0 commit comments

Comments
 (0)