mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: refactor modaltest (#8724)
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
import { View, EventData } from "tns-core-modules/ui/core/view";
|
import {
|
||||||
|
View,
|
||||||
|
EventData
|
||||||
|
} from "tns-core-modules/ui/core/view";
|
||||||
|
|
||||||
export function onNavigatingTo(args: EventData) {
|
export function onNavigatingTo(args: EventData) {
|
||||||
const page = args.object;
|
const page = args.object;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { View, EventData } from "tns-core-modules/ui/core/view";
|
import {
|
||||||
|
View,
|
||||||
|
EventData
|
||||||
|
} from "tns-core-modules/ui/core/view";
|
||||||
|
|
||||||
const colors = ["red", "orange", "magenta"];
|
const colors = ["red", "orange", "magenta"];
|
||||||
let x = 0;
|
let x = 0;
|
||||||
@@ -14,15 +17,22 @@ export function onLiveSync() {
|
|||||||
export function pageLoaded(args: EventData) {
|
export function pageLoaded(args: EventData) {
|
||||||
const view = args.object as View;
|
const view = args.object as View;
|
||||||
const page = view.page;
|
const page = view.page;
|
||||||
console.log("Page loaded: " + page + ", isLoaded: " + page.isLoaded);
|
console.log(`Page loaded: ${page}, isLoaded: ${page.isLoaded}`);
|
||||||
console.log("Frame: " + page.frame + ", currentPage: " + page.frame.currentPage);
|
console.log(`Frame: ${page.frame}, currentPage: ${page.frame.currentPage}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onTap(args) {
|
export function onTap(args) {
|
||||||
const view = args.object as View;
|
const view = args.object as View;
|
||||||
const page = view.page;
|
const page = view.page;
|
||||||
let context = page.bindingContext || 0;
|
let context = page.bindingContext || 0;
|
||||||
page.frame.navigate({ moduleName: "modaltest/page.2", bindingContext: ++context, transition: { name: "fade", duration: 1000 } });
|
page.frame.navigate({
|
||||||
|
moduleName: "modaltest/page.2",
|
||||||
|
bindingContext: ++context,
|
||||||
|
transition: {
|
||||||
|
name: "fade",
|
||||||
|
duration: 1000
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tenGoBacks(args) {
|
export function tenGoBacks(args) {
|
||||||
@@ -33,7 +43,14 @@ export function tenGoBacks(args) {
|
|||||||
let context = page.bindingContext || 0;
|
let context = page.bindingContext || 0;
|
||||||
let x = 4;
|
let x = 4;
|
||||||
while (x--) {
|
while (x--) {
|
||||||
frame.navigate({ moduleName: "modaltest/page.2", bindingContext: ++context, transition: { name: "fade", duration: 1000 } });
|
frame.navigate({
|
||||||
|
moduleName: "modaltest/page.2",
|
||||||
|
bindingContext: ++context,
|
||||||
|
transition: {
|
||||||
|
name: "fade",
|
||||||
|
duration: 1000
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
x = 4;
|
x = 4;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { View, EventData, ShownModallyData } from "tns-core-modules/ui/core/view";
|
import {
|
||||||
|
View,
|
||||||
|
EventData,
|
||||||
|
ShownModallyData
|
||||||
|
} from "tns-core-modules/ui/core/view";
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
|
|
||||||
@@ -17,7 +21,14 @@ export function onTap(args: EventData) {
|
|||||||
const view = args.object as View;
|
const view = args.object as View;
|
||||||
const page = view.page;
|
const page = view.page;
|
||||||
let context = page.bindingContext || 0;
|
let context = page.bindingContext || 0;
|
||||||
page.frame.navigate({ moduleName: "modaltest/page.2", bindingContext: ++context, transition: { name: "fade", duration: 1000 } });
|
page.frame.navigate({
|
||||||
|
moduleName: "modaltest/page.2",
|
||||||
|
bindingContext: ++context,
|
||||||
|
transition: {
|
||||||
|
name: "fade",
|
||||||
|
duration: 1000
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onBack(args: EventData) {
|
export function onBack(args: EventData) {
|
||||||
@@ -33,7 +44,7 @@ export function closeModal(args: EventData) {
|
|||||||
let modalContext = 0;
|
let modalContext = 0;
|
||||||
export function showModal(args: EventData) {
|
export function showModal(args: EventData) {
|
||||||
(args.object as View).showModal("modaltest/page.2", ++modalContext, function () {
|
(args.object as View).showModal("modaltest/page.2", ++modalContext, function () {
|
||||||
console.log("Closed Modal: " + (args.object as View).bindingContext);
|
console.log(`Closed Modal: ${(args.object as View).bindingContext}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user