add supernode to apply layoutconfig
This commit is contained in:
@@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user