Files
Nicu 540b2b4f82 feat(view): added iOS parameter for modal presentation style (#6409)
* feat(view): added iOS parameter for modal presentation style

* Now passing options to showModal in one argument

* refactor: Move context and close in modal options

* chore: Comments added for UIModalPresentationStyle.Popover case

* refactor: Use modalOptions in e2e demo

* chore: fix pbroken test
2018-12-13 17:03:25 +02:00

70 lines
2.2 KiB
TypeScript

import { Page } from "tns-core-modules/ui/page";
import { Label } from "tns-core-modules/ui/label";
function createCloseCallback(label: Label, context?: string): (username: string, password: string) => void {
return function (username: string, password: string) {
let result = username + "/" + password;
result = context ? context + "/" + result : result;
console.log(result);
label.text = result;
}
}
function openModal(page: Page, label: Label, context: string) {
page.showModal("ui-tests-app/modal-view/login-page", {
context,
closeCallback: createCloseCallback(label, context),
fullscreen: false,
});
}
export function onTap(args) {
const page = <Page>args.object.page;
const label = page.getViewById<Label>("label");
var fullscreen = (<any>args.object).text.indexOf("(full-screen)") !== -1;
page.showModal("ui-tests-app/modal-view/login-page", {
context: "context",
closeCallback: createCloseCallback(label),
fullscreen
});
}
export function onTapStretched(args) {
const page = <Page>args.object.page;
const label = page.getViewById<Label>("label");
page.showModal("ui-tests-app/modal-view/login-page", {
context: "context",
closeCallback: createCloseCallback(label),
fullscreen: false,
animated: false,
stretched: true
});
}
export function onTapSecondModalInCB(args) {
const page = <Page>args.object.page;
const label = page.getViewById<Label>("label");
page.showModal("ui-tests-app/modal-view/login-page", {
context: "First",
closeCallback: (username: string, password: string) => {
const result = "First/" + username + "/" + password;
console.log(result);
label.text = result;
// Open second modal in the close callback of the first one.
openModal(page, label, "Second");
}
});
}
export function onTapSecondModalInTimer(args) {
const page = <Page>args.object.page;
const label = page.getViewById<Label>("label");
openModal(page, label, "First");
// Open second modal 1s after the first one.
setTimeout(() => openModal(page, label, "Second"), 1000);
}