-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathbasic.navigation.component.ts
103 lines (89 loc) · 3.43 KB
/
basic.navigation.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { Component, ViewContainerRef, Input, ViewChild, ElementRef } from "@angular/core";
import { Router, NavigationEnd } from "@angular/router";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { ModalComponent } from "../modal/modal.component";
import { ModalRouterComponent } from "../modal/modal-router/modal-router.component";
import { confirm } from "tns-core-modules/ui/dialogs";
import { ViewContainerRefService } from "../shared/ViewContainerRefService";
import { ModalViewComponent } from "~/modal-shared/modal-view.component";
@Component({
selector: "basic-nav",
template: `
<StackLayout col="{{ col }}">
<TextView text="Navigate to example" editable="false"></TextView>
<Button text="Show Modal Without Frame" (tap)="onModalNoFrame()" textAlignment="left"></Button>
<Button text="Show Modal Page With Frame" (tap)="onModalFrame()" textAlignment="left"></Button>
<Button text="Show Shared Modal" (tap)="onRootModalTap()" textAlignment="left"></Button>
<Button text="Show Dialog" (tap)="onShowDialog()" textAlignment="left"></Button>
<Button #popoverButtonComp text="Show 'popover' modal" (tap)="onPopoverModal()" textAlignment="left"></Button>
</StackLayout>`
})
export class BasicsNavigationComponent {
@ViewChild("popoverButtonComp") popoverButtonComp: ElementRef;
@Input() col: number;
constructor(
private modal: ModalDialogService,
private router: Router,
private vcf: ViewContainerRef,
private viewContainerRefService: ViewContainerRefService) {
}
onModalNoFrame() {
const options: ModalDialogOptions = {
context: {
navigationVisibility: false
},
fullscreen: true,
viewContainerRef: this.vcf
};
this.modal.showModal(ModalComponent, options).then((res: string) => {
console.log("modal-no-frame closed");
});
}
onModalFrame() {
const options: ModalDialogOptions = {
context: {
navigationVisibility: true,
modalRoute: "modal"
},
fullscreen: true,
viewContainerRef: this.vcf
};
this.modal.showModal(ModalRouterComponent, options).then((res: string) => {
console.log("modal-frame closed");
});
}
onShowDialog() {
let options = {
title: "Dialog",
message: "Message",
okButtonText: "Yes",
cancelButtonText: "No"
}
confirm(options).then((result: boolean) => {
console.log(result);
})
}
onRootModalTap(): void {
const options: ModalDialogOptions = {
viewContainerRef: this.viewContainerRefService.root,
context: {},
fullscreen: true
};
this.modal.showModal(ModalViewComponent, options)
.then((result: string) => {
console.log(result);
});
}
onPopoverModal() {
const options: ModalDialogOptions = {
viewContainerRef: this.viewContainerRefService.root,
context: {},
ios: {
presentationStyle: UIModalPresentationStyle.Popover
},
target: this.popoverButtonComp.nativeElement
};
this.modal.showModal(ModalViewComponent, options)
.then((result: string) => { console.log(result);});
}
}