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/doric-demo/src/TSXDemo.tsx

52 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-09-01 10:47:40 +08:00
import {
Panel,
Group,
VLayout,
layoutConfig,
Gravity,
Text,
Color,
navbar,
jsx,
} from "doric";
@Entry
class Example extends Panel {
onShow() {
navbar(context).setTitle("Example");
}
build(rootView: Group) {
let count = 0;
(
<VLayout
layoutConfig={layoutConfig().just().configAlignment(Gravity.Center)}
width={200}
height={200}
space={20}
border={{ color: Color.BLUE, width: 1 }}
gravity={Gravity.Center}
>
<Text
tag="Label"
text={`${count}`}
textSize={40}
layoutConfig={layoutConfig().fit()}
/>
<Text
text="Click to count"
textSize={20}
backgroundColor={Color.parse("#70a1ff")}
textColor={Color.WHITE}
onClick={() => {
count++;
const label = rootView.findViewByTag("Label") as Text;
label.text = `${count}`;
}}
width={200}
height={50}
/>
</VLayout>
).in(rootView);
}
}