-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathmodal-test.ts
109 lines (96 loc) · 3.38 KB
/
modal-test.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
104
105
106
107
108
109
import { Component, ViewContainerRef } from "@angular/core";
import * as dialogs from "ui/dialogs";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { ModalContent } from "./modal-content";
@Component({
selector: "modal-test",
template: `
<GridLayout rows="*, auto">
<StackLayout verticalAlignment="top" margin="12">
<Button text="show component" (tap)="showModal(false)"></Button>
<Button text="show component fullscreen" (tap)="showModal(true)"></Button>
<Button text="alert" (tap)="showAlert()"></Button>
<Button text="confirm" (tap)="showConfirm()"></Button>
<Button text="prompt" (tap)="showPrompt()"></Button>
<Button text="action" (tap)="showAction()"></Button>
<Button text="login" (tap)="showLogin()"></Button>
</StackLayout>
<Label [text]="'RESULT: ' + result" row="1" margin="12"></Label>
</GridLayout>
`
})
export class ModalTest {
public result: string = "result";
constructor(private modal: ModalDialogService, private vcRef: ViewContainerRef) { }
static entries = [
ModalContent
];
public showModal(fullscreen: boolean) {
const options: ModalDialogOptions = {
context: { promptMsg: "This is the prompt message!" },
fullscreen: fullscreen,
viewContainerRef: this.vcRef
};
this.modal.showModal(ModalContent, options).then((res: string) => {
this.result = res || "empty result";
// console.log("MODAL:" + this.result);
});
}
public showAlert() {
dialogs.alert({
title: "Alert Title",
message: "The name will change.",
okButtonText: "OK"
}).then(() => {
this.result = "alert closed";
});
}
public showConfirm() {
dialogs.confirm({
title: "Name",
message: "Do you want to change the name?",
cancelButtonText: "No",
neutralButtonText: "Ignore",
okButtonText: "Yes"
}).then((confirmResult) => {
this.result = confirmResult + "";
});
}
public showPrompt() {
dialogs.prompt({
title: "Name",
message: "Enter name:",
cancelButtonText: "Cancel",
neutralButtonText: "Ignore",
okButtonText: "OK",
defaultText: "John Reese",
inputType: dialogs.inputType.text
}).then((promptResult) => {
this.result = promptResult.result ? promptResult.text : "no result";
});
}
public showAction() {
dialogs.action({
message: "Choose action:",
cancelButtonText: "Close",
actions: ["Foo", "Bar"]
}).then((actionResult) => {
this.result = actionResult;
});
}
public showLogin() {
dialogs.login({
title: "Name",
message: "Enter name:",
cancelButtonText: "Cancel",
neutralButtonText: "Ignore",
okButtonText: "OK",
userName: "John",
password: "Reese"
}).then((loginResult) => {
this.result = loginResult.result ?
("user: " + loginResult.userName + " pass: " + loginResult.password) :
"no result";
});
}
}