This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/js-framework/demo.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-07-22 13:52:30 +08:00
import { NativeCall, Text, Alignment, Color, VLayout, Panel, log, logw, loge } from "./index"
2019-07-22 14:36:32 +08:00
import { Group } from "./src/ui/view";
2019-07-18 16:29:24 +08:00
2019-07-18 20:11:01 +08:00
2019-07-22 13:41:38 +08:00
@Entry
2019-07-18 16:29:24 +08:00
export class MyPage extends Panel {
2019-07-22 17:57:58 +08:00
text?: Text
2019-07-22 14:36:32 +08:00
build(rootView: Group): void {
2019-07-22 17:57:58 +08:00
this.text = new Text
this.text.text = "hello"
this.text.width = 50
this.text.height = 50
this.text.y = 100
rootView.children.push(this.text)
2019-07-22 15:38:30 +08:00
rootView.bgColor = Color.safeParse('#00ff00')
2019-07-22 17:57:58 +08:00
log('build view:', JSON.stringify(rootView.toModel()))
2019-07-18 16:29:24 +08:00
}
2019-07-22 14:36:32 +08:00
2019-07-22 13:41:38 +08:00
@NativeCall
2019-07-18 16:29:24 +08:00
log() {
2019-07-22 13:41:38 +08:00
log("Hello.HEGO")
logw("Hello.HEGO")
loge("Hello.HEGO")
2019-07-22 17:57:58 +08:00
2019-07-22 15:02:38 +08:00
context.demo.testPromise(true).then((r) => {
2019-07-22 11:22:19 +08:00
log('resolve', r)
}, (e) => {
log('reject', e)
})
2019-07-22 17:57:58 +08:00
2019-07-22 15:02:38 +08:00
context.demo.testPromise(false).then((r) => {
2019-07-22 11:22:19 +08:00
log('resolve', r)
}, (e) => {
log('reject', e)
})
2019-07-22 17:57:58 +08:00
2019-07-22 13:41:38 +08:00
setTimeout(function () {
log('settimeout')
}, 1000)
2019-07-22 17:57:58 +08:00
setInterval(() => {
log('setInterval')
if (this.text) {
this.text.y += 10
}
log('build view:', JSON.stringify(this.getRootView().toModel()))
}, 1000)
2019-07-18 16:29:24 +08:00
}
}