Files
NativeScript/tests/app/pages/page8.ts
Hristo Deshev b45cbe929b No more ambient modules for tns-core-modules/* subpackages.
- Use path mappings in tsconfig.json to resolve module typings
- Only use ambient mobules for global API's
- Move single-file modules to a subdir with the same name so that
we can provide a hand-written typing next to it (via package.json)
- Delete all mentions of tns-core-modules.d.ts
- Delete reference d.ts assembly build steps. Not needed anymore.
- HACK! Use a <reference> for global typings in application.d.ts
to avoid publishing a separate @types/tns-core-modules package.
- Rename declarations.d.ts to tns-core-modules.d.ts to preserve
JS project mappings in references.d.ts (the only place we use those)
2017-03-07 17:59:02 +02:00

67 lines
1.8 KiB
TypeScript

import * as btns from "ui/button";
import * as pages from "ui/page";
import * as stacks from "ui/layouts/stack-layout";
import * as scroll from "ui/scroll-view";
import * as textView from "ui/text-view";
import * as timer from "timer";
import * as http from "tns-core-modules/http";
import * as trace from "trace";
trace.enable();
trace.setCategories(trace.categories.Style);
export function createPage() {
function createTxt(text: string) {
var tv = new textView.TextView();
tv.text = text;
return tv;
}
var page = new pages.Page();
var scrollView = new scroll.ScrollView();
function performGet() {
console.log("Getting CSS");
http.getString("http://192.168.54.36:8080/test.css").then(
function (r) {
console.log("Applying CSS");
page.css = r;
timer.setTimeout(performGet, 1000);
},
function (e) {
console.log("Error: " + e);
timer.setTimeout(performGet, 1000);
});
}
var stack = new stacks.StackLayout();
scrollView.content = stack;
var counter = 0;
var btn = new btns.Button();
btn.text = "tap";
btn.on(btns.Button.tapEvent, function () {
btn.text = "hi: " + counter++;
});
btn.isEnabled = false;
stack.addChild(btn);
stack.addChild(createTxt("this is label"));
var info = new btns.Button();
info.text = "info";
info.className = "info";
info.on(btns.Button.tapEvent, function () {
info.text = "hi: " + counter++;
btn.isEnabled = true;
});
stack.addChild(info);
stack.addChild(createTxt("this is another label"));
page.content = scrollView;
timer.setTimeout(performGet, 2000);
return page;
}
//export var Page = page;