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
2021-12-08 12:06:25 +08:00

47 lines
1015 B
TypeScript

import {
Panel,
Group,
vlayout,
layoutConfig,
Gravity,
text,
Color,
navbar,
modal,
AssetsResource,
image,
} from "doric";
import { demoPlugin } from "__$__";
@Entry
class Example extends Panel {
onShow() {
navbar(context).setTitle("Example");
}
build(rootView: Group) {
vlayout([
image({
image: new AssetsResource("logo_doric.png"),
}),
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);
}
}