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-cli/assets-lib/example/src/Example.ts

42 lines
911 B
TypeScript
Raw Normal View History

2021-08-04 15:32:19 +08:00
import {
Panel,
Group,
vlayout,
layoutConfig,
Gravity,
text,
Color,
navbar,
modal,
} from "doric";
import { demoPlugin } from "__$__";
@Entry
class Example extends Panel {
onShow() {
navbar(context).setTitle("Example");
}
build(rootView: Group) {
vlayout([
text({
text: "Click to call native plugin",
textSize: 20,
backgroundColor: Color.parse("#70a1ff"),
textColor: Color.WHITE,
onClick: async () => {
const result = await demoPlugin(this.context).call();
await modal(this.context).alert(result);
},
layoutConfig: layoutConfig().fit(),
padding: { left: 20, right: 20, top: 20, bottom: 20 },
}),
])
.apply({
layoutConfig: layoutConfig().fit().configAlignment(Gravity.Center),
space: 20,
gravity: Gravity.Center,
})
.in(rootView);
}
}