mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
migrated JS files toTS
This commit is contained in:
11
apps/app/modaltest/app.ts
Normal file
11
apps/app/modaltest/app.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as application from "tns-core-modules/application";
|
||||
// trace.addCategories(trace.categories.All);
|
||||
// application.run({ moduleName: "page.1" });
|
||||
// application.run({ moduleName: "main-page" });
|
||||
|
||||
application.run({ moduleName: "modal-tab" });
|
||||
// application.run({ moduleName: "textview" });
|
||||
|
||||
// application.start({ moduleName: "modal-tab.33" });
|
||||
// application.run({ moduleName: "modal-frame" });
|
||||
// application.start({ moduleName: "page.2" });
|
||||
34
apps/app/modaltest/main-page.ts
Normal file
34
apps/app/modaltest/main-page.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { View, EventData } from "tns-core-modules/ui/core/view";
|
||||
|
||||
export function onNavigatingTo(args: EventData) {
|
||||
const page = args.object;
|
||||
console.log("onNavigatingTo");
|
||||
}
|
||||
|
||||
export function navigate(args: EventData) {
|
||||
console.log("navigate");
|
||||
(args.object as View).page.frame.navigate("page.1");
|
||||
}
|
||||
|
||||
export function onModalTab(args: EventData) {
|
||||
const view = args.object as View;
|
||||
view.showModal("modal-tab", "context", closeModal, false);
|
||||
}
|
||||
|
||||
export function onModalFrame(args: EventData) {
|
||||
const view = args.object as View;
|
||||
view.showModal("modal-frame", "context", closeModal, false);
|
||||
}
|
||||
|
||||
export function onTap3(args: EventData) {
|
||||
const page = (args.object as View).page;
|
||||
page.actionBar.titleView.requestLayout();
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
console.log('closeModal Called');
|
||||
}
|
||||
|
||||
export function sync(args: EventData) {
|
||||
global.__onLiveSyncCore();
|
||||
}
|
||||
66
apps/app/modaltest/modal-tab.ts
Normal file
66
apps/app/modaltest/modal-tab.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { View, EventData } from "tns-core-modules/ui/core/view";
|
||||
|
||||
const colors = ['red', 'orange', 'magenta'];
|
||||
let x = 0;
|
||||
|
||||
export function onLoaded(args) {
|
||||
// args.object.backgroundColor = colors[++x % 3];
|
||||
}
|
||||
|
||||
export function onLiveSync() {
|
||||
global.__onLiveSyncCore();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
export function onTap(args) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
let context = page.bindingContext || 0;
|
||||
page.frame.navigate({ moduleName: "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: "page.2", bindingContext: ++context, transition: { name: "fade", duration: 1000 } });
|
||||
}
|
||||
|
||||
x = 4;
|
||||
while (x--) {
|
||||
frame.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
export function closeModal(args: EventData) {
|
||||
(args.object as View).closeModal()
|
||||
}
|
||||
|
||||
export function navigateToFrame(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
const frame = page.frame;
|
||||
frame.navigate("modal-frame");
|
||||
}
|
||||
|
||||
export function navigateToPageWithFrame(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
const frame = page.frame;
|
||||
frame.navigate("modal-frame.1");
|
||||
}
|
||||
|
||||
export function onModalFrame(args: EventData) {
|
||||
const view = args.object as View;
|
||||
view.showModal("modal-frame", "some context", closeModal, false);
|
||||
}
|
||||
@@ -4,8 +4,7 @@
|
||||
verticalAlignment="bottom"
|
||||
horizontalAlignment="right">
|
||||
<Button text="LIVESYNC" tap="onLiveSync" />
|
||||
<Button text="Close Modal" tap="tap" />
|
||||
<Button text="new Frame" tap="newFrame" />
|
||||
<Button text="Close Modal" tap="closeModal" />
|
||||
<Button text="Show Modal Frame" tap="onModalFrame" />
|
||||
<TextView text="text viesw" />
|
||||
<TextField text="text field" />
|
||||
@@ -35,7 +34,7 @@
|
||||
<TabViewItem title="Item 3">
|
||||
<ScrollView>
|
||||
<StackLayout verticalAlignment="bottom" horizontalAlignment="right">
|
||||
<Button text="Close Modal" tap="tap" />
|
||||
<Button text="Close Modal" tap="closeModal" />
|
||||
<Button text="Show Modal Frame" tap="onModalFrame" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
46
apps/app/modaltest/page.2.ts
Normal file
46
apps/app/modaltest/page.2.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { View, EventData, ShownModallyData } from "tns-core-modules/ui/core/view";
|
||||
|
||||
var x = 0;
|
||||
|
||||
export function tenGoBacks(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
const frame = page.frame;
|
||||
|
||||
x = 10;
|
||||
while (x--) {
|
||||
console.log(`Can go Back: ${frame.canGoBack()}`);
|
||||
frame.goBack();
|
||||
}
|
||||
}
|
||||
export function onTap(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
let context = page.bindingContext || 0;
|
||||
page.frame.navigate({ moduleName: "page.2", bindingContext: ++context, transition: { name: "fade", duration: 1000 } });
|
||||
}
|
||||
|
||||
export function onBack(args: EventData) {
|
||||
const view = args.object as View;
|
||||
const page = view.page;
|
||||
page.frame.goBack();
|
||||
}
|
||||
|
||||
export function closeModal(args: EventData) {
|
||||
(args.object as View).closeModal();
|
||||
}
|
||||
|
||||
let modalContext = 0;
|
||||
export function showModal(args: EventData) {
|
||||
(args.object as View).showModal("page.2", ++modalContext, function () {
|
||||
console.log("Closed Modal: " + (args.object as View).bindingContext);
|
||||
});
|
||||
}
|
||||
|
||||
export function showingModally(args: ShownModallyData) {
|
||||
(args.object as View).bindingContext = args.context;
|
||||
}
|
||||
|
||||
export function onLivesync() {
|
||||
global.__onLiveSyncCore();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<Page backgroundColor="pink" showingModally="showingModally">
|
||||
<ActionBar title="{{ $value, 'Page ' + $value }} ">
|
||||
<ActionBar title="{{ $value }} ">
|
||||
<ActionItem text="close" tap="closeModal" ios.position='right' />
|
||||
</ActionBar>
|
||||
<StackLayout backgroundColor="orange">
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<Frame>
|
||||
<Page backgroundColor="blue" >
|
||||
<StackLayout backgroundColor="orange" verticalAlignment="top">
|
||||
<Button text="set text" tap='tap' />
|
||||
<TextView text="text" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
</Frame>
|
||||
Reference in New Issue
Block a user