2019-07-24 10:14:17 +08:00
|
|
|
import { Gravity, Mutable, NativeCall, Text, Color, VLayout, Panel, log, logw, loge, Group, Stack, } from "./index"
|
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-23 13:01:45 +08:00
|
|
|
|
2019-07-22 14:36:32 +08:00
|
|
|
build(rootView: Group): void {
|
2019-07-24 10:14:17 +08:00
|
|
|
const state = Mutable.of(1)
|
2019-07-23 13:01:45 +08:00
|
|
|
const numberView = new Text
|
|
|
|
numberView.width = 100
|
|
|
|
numberView.height = 200
|
|
|
|
numberView.top = 50
|
2019-07-24 10:14:17 +08:00
|
|
|
state.bind((v) => {
|
|
|
|
numberView.text = v.toString()
|
|
|
|
})
|
2019-07-23 13:01:45 +08:00
|
|
|
numberView.textSize = 40
|
|
|
|
numberView.centerX = rootView.width / 2
|
|
|
|
rootView.addChild(numberView)
|
|
|
|
const click = new Text
|
|
|
|
click.textSize = 20
|
|
|
|
click.text = '点击计数'
|
|
|
|
click.onClick = () => {
|
2019-07-24 10:14:17 +08:00
|
|
|
state.set(state.get() + 1)
|
2019-07-23 13:01:45 +08:00
|
|
|
}
|
|
|
|
click.top = numberView.bottom + 20
|
2019-07-24 11:43:38 +08:00
|
|
|
|
|
|
|
click.layoutConfig = {
|
|
|
|
alignment: new Gravity().centerX()
|
|
|
|
}
|
|
|
|
|
2019-07-23 13:01:45 +08:00
|
|
|
rootView.addChild(click)
|
2019-07-24 10:14:17 +08:00
|
|
|
|
|
|
|
const vlayout = new VLayout
|
|
|
|
vlayout.width = this.getRootView().width
|
|
|
|
vlayout.height = 500
|
|
|
|
|
|
|
|
vlayout.top = 50
|
|
|
|
vlayout.centerX = this.getRootView().width / 2
|
|
|
|
vlayout.space = 0
|
|
|
|
vlayout.gravity = (new Gravity()).bottom()
|
|
|
|
const v = [1, 2, 3,].map(e => {
|
|
|
|
const stack = new Stack
|
|
|
|
stack.width = stack.height = 50
|
|
|
|
stack.bgColor = Color.safeParse('#00ff00')
|
|
|
|
vlayout.addChild(stack)
|
|
|
|
stack.onClick = () => {
|
|
|
|
loge('stack:onClick')
|
|
|
|
if (vlayout.space !== undefined) {
|
|
|
|
loge('change space')
|
|
|
|
vlayout.space += 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
rootView.addChild(vlayout)
|
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-18 16:29:24 +08:00
|
|
|
}
|
|
|
|
}
|