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/ModularDemo.ts

81 lines
2.0 KiB
TypeScript
Raw Normal View History

2021-05-13 16:26:48 +08:00
import { Color, Gravity, Group, layoutConfig, LayoutSpec, ModularPanel, Panel, scroller, text, vlayout } from "doric";
import { CounterPage } from "./Counter";
class Module1 extends Panel {
build(root: Group) {
vlayout(
[
text({
text: "First Module",
textColor: Color.WHITE,
}),
],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
},
padding: {
top: 20,
bottom: 20
},
gravity: Gravity.Center,
backgroundColor: Color.parse("#3498db")
}
).in(root)
}
}
class Module2 extends Panel {
build(root: Group) {
vlayout(
[
text({
text: "Second Module",
textColor: Color.WHITE,
}),
],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
},
padding: {
top: 20,
bottom: 20
},
gravity: Gravity.Center,
backgroundColor: Color.parse("#f39c12")
}
).in(root)
}
}
@Entry
class ModularDemo extends ModularPanel {
setupModules() {
return [
Module1,
Module2,
CounterPage,
]
}
setupShelf(root: Group) {
const shelf = vlayout(
[],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
}
}
)
scroller(
shelf,
{
layoutConfig: layoutConfig().most()
}).in(root)
return shelf
}
}