Add modal-view demo to ui-tests-app.

This commit is contained in:
Vasil Chimev
2015-06-15 15:09:56 +03:00
parent 944e506eac
commit df265794e8
4 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,32 @@
import pages = require("ui/page");
import textField = require("ui/text-field");
import observable = require("data/observable");
var context: any;
var closeCallback: Function;
var page: pages.Page;
var usernameTextField: textField.TextField;
var passwordTextField: textField.TextField;
export function onShownModally(args: pages.ShownModallyData) {
console.log("login-page.onShownModally, context: " + args.context);
context = args.context;
closeCallback = args.closeCallback;
}
export function onLoaded(args: observable.EventData) {
console.log("login-page.onLoaded");
page = <pages.Page>args.object;
usernameTextField = page.getViewById<textField.TextField>("username");
passwordTextField = page.getViewById<textField.TextField>("password");
}
export function onUnloaded() {
console.log("login-page.onUnloaded");
}
export function onLoginButtonTap() {
console.log("login-page.onLoginButtonTap");
closeCallback(usernameTextField.text, passwordTextField.text);
}

View File

@ -0,0 +1,7 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" shownModally="onShownModally" loaded="onLoaded" unloaded="onUnloaded" backgroundColor="Red">
<StackLayout backgroundColor="PaleGreen">
<TextField hint="username" id="username" text="username"/>
<TextField hint="password" id="password" text="password" secure="true"/>
<Button text="Login" tap="onLoginButtonTap"/>
</StackLayout>
</Page>

View File

@ -0,0 +1,19 @@
import pages = require("ui/page");
import labelModule = require("ui/label");
import observable = require("data/observable");
var page: pages.Page;
var label: labelModule.Label;
export function pageLoaded(args: observable.EventData) {
page = <pages.Page>args.object;
label = page.getViewById<labelModule.Label>("label");
}
export function onTap(args: observable.EventData) {
var fullscreen = (<any>args.object).text.indexOf("(full-screen)") !== -1;
page.showModal("modal-view/login-page", "context", function (username: string, password: string) {
console.log(username + "/" + password);
label.text = username + "/" + password;
}, fullscreen);
}

View File

@ -0,0 +1,7 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded" backgroundColor="Red">
<StackLayout backgroundColor="PaleGreen">
<Button text="Login (pop-up)" tap="onTap" />
<Button text="Login (full-screen)" tap="onTap" />
<Label id="label" text="Anonymous"/>
</StackLayout>
</Page>