add supernode to apply layoutconfig

This commit is contained in:
pengfei.zhou
2019-11-13 17:26:26 +08:00
parent 6bf224aa9a
commit 0887ba72e8
8 changed files with 133 additions and 82 deletions

View File

@@ -1,4 +1,4 @@
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, ListItem, NativeCall } from "doric";
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, ListItem, NativeCall, listItem } from "doric";
@Entry
class ListPanel extends Panel {
@@ -9,17 +9,29 @@ class ListPanel extends Panel {
heightSpec: LayoutSpec.AT_MOST,
}
rootView.addChild(list)
list.itemCount = 10
list.bgColor = Color.parse("#ff00ff")
list.itemCount = 1000
list.renderItem = (idx) => {
const item = new ListItem
item.addChild(text({
width: 100,
height: 100,
return listItem(text({
layoutConfig: {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
margin: {
left: 10,
right: 10,
top: 10,
bottom: 10,
},
},
text: `${idx}行内容`,
textAlignment: gravity().center(),
}))
return item
})).also(it => {
it.gravity = gravity().center()
it.bgColor = Color.parse("#fff00f")
it.layoutConfig = {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
}
})
}
}
}