mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
dialogs page updated
This commit is contained in:
@@ -3,15 +3,82 @@ import dialogs = require("ui/dialogs");
|
||||
export function alertTapped(args) {
|
||||
dialogs.alert("Hi there!");
|
||||
}
|
||||
|
||||
|
||||
export function alertWithOptionsTapped(args) {
|
||||
dialogs.alert({
|
||||
title: "Alert",
|
||||
message: "Hi there!",
|
||||
okButtonText: "Close"
|
||||
});
|
||||
}
|
||||
|
||||
export function confirmTapped(args) {
|
||||
dialogs.confirm("Are you sure?");
|
||||
dialogs.confirm("Are you sure?").then(r=> console.log(`Confirm result: ${r}`));
|
||||
}
|
||||
|
||||
export function confirmWithOptionsTapped(args) {
|
||||
dialogs.confirm({
|
||||
title: "Confirm",
|
||||
message: "Are you sure?",
|
||||
okButtonText: "OK",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore"
|
||||
}).then(r=> console.log(`Confirm result: ${r}`));
|
||||
}
|
||||
|
||||
export function promptTapped(args) {
|
||||
dialogs.prompt("Enter name", "John Doe");
|
||||
}
|
||||
|
||||
export function promptWithOptionsTapped(args) {
|
||||
dialogs.prompt({
|
||||
title: "Prompt",
|
||||
message: "Enter name",
|
||||
okButtonText: "OK",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore",
|
||||
defaultText: "John Doe",
|
||||
inputType: dialogs.inputType.text
|
||||
}).then(r=> console.log(`Prompt result: ${r.result}, text: ${r.text}`));
|
||||
}
|
||||
|
||||
export function promptWithOptionsPasswordTapped(args) {
|
||||
dialogs.prompt({
|
||||
title: "Prompt",
|
||||
message: "Enter name",
|
||||
okButtonText: "OK",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore",
|
||||
defaultText: "John Doe",
|
||||
inputType: dialogs.inputType.password
|
||||
}).then(r=> console.log(`Prompt result: ${r.result}, text: ${r.text}`));
|
||||
}
|
||||
|
||||
export function loginTapped(args) {
|
||||
dialogs.login("Login:", "username");
|
||||
dialogs.login("Login:", "username", "pwd").then(r=> console.log(`Login result: ${r.result}, user: ${r.userName}, pwd: ${r.password}`));
|
||||
}
|
||||
|
||||
export function loginWithOptionsTapped(args) {
|
||||
dialogs.login({
|
||||
title: "Login",
|
||||
message: "Enter user/pwd",
|
||||
okButtonText: "OK",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore",
|
||||
defaultText: "John Doe",
|
||||
userName: "USER",
|
||||
password: "PWD"
|
||||
}).then(r=> console.log(`Login result: ${r.result}, user: ${r.userName}, pwd: ${r.password}`));
|
||||
}
|
||||
|
||||
export function actionTapped(args) {
|
||||
dialogs.action("Action", "Close", ["One", "Two", "Three"]).then(r=> console.log(`Action result: ${r}`));
|
||||
}
|
||||
|
||||
export function actionWithOptionsTapped(args) {
|
||||
dialogs.action({
|
||||
message: "Action",
|
||||
cancelButtonText: "Close",
|
||||
actions: ["One", "Two", "Three"]
|
||||
}).then(r=> console.log(`Action result: ${r}`));
|
||||
}
|
||||
@@ -2,8 +2,15 @@
|
||||
<Page>
|
||||
<StackLayout>
|
||||
<Button text="alert" tap="alertTapped"/>
|
||||
<Button text="alert with options" tap="alertWithOptionsTapped"/>
|
||||
<Button text="confirm" tap="confirmTapped"/>
|
||||
<Button text="confirm with options" tap="confirmWithOptionsTapped"/>
|
||||
<Button text="prompt" tap="promptTapped"/>
|
||||
<Button text="prompt with options" tap="promptWithOptionsTapped"/>
|
||||
<Button text="prompt with options password" tap="promptWithOptionsPasswordTapped"/>
|
||||
<Button text="login" tap="loginTapped"/>
|
||||
<Button text="login with options" tap="loginWithOptionsTapped"/>
|
||||
<Button text="action" tap="actionTapped"/>
|
||||
<Button text="action with options" tap="actionWithOptionsTapped"/>
|
||||
</StackLayout>
|
||||
</Page>
|
||||
Reference in New Issue
Block a user