feat: modular add test case

This commit is contained in:
pengfei.zhou
2021-05-13 16:26:48 +08:00
committed by osborn
parent c27a9bd672
commit 546af79534
14 changed files with 358 additions and 57 deletions

View File

@@ -27,12 +27,12 @@ class CounterView extends ViewHolder {
build(root: Group) {
vlayout(
[
text({
this.number = text({
textSize: 40,
tag: "tvNumber",
}),
text({
this.counter = text({
text: "Click To Count 1",
textSize: 20,
tag: "tvCounter",
@@ -44,8 +44,6 @@ class CounterView extends ViewHolder {
space: 20,
}
).in(root);
this.number = root.findViewByTag("tvNumber")!;
this.counter = root.findViewByTag("tvCounter")!;
}
}

View File

@@ -0,0 +1,81 @@
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
}
}