-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathlayout.component.ts
97 lines (82 loc) · 2.82 KB
/
layout.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
import { Component, ViewContainerRef } from "@angular/core";
import { Router, NavigationEnd } from "@angular/router";
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { ModalComponent } from "./modal/modal.component";
import { ModalViewComponent } from "./modal-shared/modal-view.component";
import { ModalRouterComponent } from "./modal/modal-router/modal-router.component";
import { confirm } from "ui/dialogs";
import { AppModule } from "./app.module";
import { ViewContainerRefService } from "./shared/ViewContainerRefService";
@Component({
selector: "ns-layout",
templateUrl: "layout.component.html",
})
export class LayoutComponent {
constructor(
private modal: ModalDialogService,
private router: Router,
private location: NSLocationStrategy,
private vcRef: ViewContainerRef,
private _viewContainerRefService: ViewContainerRefService) {
router.events.subscribe(e => {
if (e instanceof NavigationEnd) {
console.log("[ROUTER]: " + e.toString());
console.log(location.toString());
}
});
this._viewContainerRefService.root = this.vcRef;
}
onModalNoFrame() {
const options: ModalDialogOptions = {
context: {
navigationVisibility: false
},
fullscreen: true,
viewContainerRef: this.vcRef
};
this.modal.showModal(ModalComponent, options).then((res: string) => {
console.log("moda-no-frame closed");
});
}
onModalFrame() {
const options: ModalDialogOptions = {
context: {
navigationVisibility: true,
modalRoute: "modal"
},
fullscreen: true,
viewContainerRef: this.vcRef
};
this.modal.showModal(ModalRouterComponent, options).then((res: string) => {
console.log("moda-frame closed");
});
}
onFrameRootViewReset() {
AppModule.root = "page-router";
AppModule.platformRef._livesync();
}
onNamedFrameRootViewReset() {
AppModule.root = "named-page-router";
AppModule.platformRef._livesync();
}
onTabRootViewReset() {
AppModule.root = "tab";
AppModule.platformRef._livesync();
}
onLayoutRootViewReset() {
AppModule.root = "layout";
AppModule.platformRef._livesync();
}
onShowDialog() {
let options = {
title: "Dialog",
message: "Message",
okButtonText: "Yes",
cancelButtonText: "No"
}
confirm(options).then((result: boolean) => {
console.log(result);
})
}
}