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) {
|
||||
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"];
|
||||
let x = 0;
|
||||
@@ -14,26 +17,40 @@ export function onLiveSync() {
|
||||
export function pageLoaded(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
console.log("Page loaded: " + page + ", isLoaded: " + page.isLoaded);
|
||||
console.log("Frame: " + page.frame + ", currentPage: " + page.frame.currentPage);
|
||||
console.log(`Page loaded: ${page}, isLoaded: ${page.isLoaded}`);
|
||||
console.log(`Frame: ${page.frame}, currentPage: ${page.frame.currentPage}`);
|
||||
}
|
||||
|
||||
export function onTap(args) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
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) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
const frame = page.frame;
|
||||
|
||||
|
||||
let context = page.bindingContext || 0;
|
||||
let x = 4;
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,7 +21,14 @@ export function onTap(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
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) {
|
||||
@@ -33,7 +44,7 @@ export function closeModal(args: EventData) {
|
||||
let modalContext = 0;
|
||||
export function showModal(args: EventData) {
|
||||
(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