mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Add modal-view demo to ui-tests-app.
This commit is contained in:
32
apps/ui-tests-app/modal-view/login-page.ts
Normal file
32
apps/ui-tests-app/modal-view/login-page.ts
Normal 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);
|
||||||
|
}
|
7
apps/ui-tests-app/modal-view/login-page.xml
Normal file
7
apps/ui-tests-app/modal-view/login-page.xml
Normal 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>
|
19
apps/ui-tests-app/modal-view/modal-view.ts
Normal file
19
apps/ui-tests-app/modal-view/modal-view.ts
Normal 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);
|
||||||
|
}
|
7
apps/ui-tests-app/modal-view/modal-view.xml
Normal file
7
apps/ui-tests-app/modal-view/modal-view.xml
Normal 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>
|
Reference in New Issue
Block a user