add listview

This commit is contained in:
pengfei.zhou
2019-11-12 15:31:25 +08:00
parent 5b3f929ee0
commit e14f4d04cd
12 changed files with 369 additions and 156 deletions

View File

@@ -1,4 +1,5 @@
export default [
'src/Counter',
'src/Snake',
'src/ListDemo',
]

26
demo/src/ListDemo.ts Normal file
View File

@@ -0,0 +1,26 @@
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, ListItem } from "doric";
@Entry
class ListPanel extends Panel {
build(rootView: Group): void {
const list = new List
list.layoutConfig = {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.AT_MOST,
}
rootView.addChild(list)
list.itemCount = 10
list.bgColor = Color.parse("#ff00ff")
list.renderItem = (idx) => {
const item = new ListItem
item.addChild(text({
width: 100,
height: 100,
text: `${idx}行内容`,
textAlignment: gravity().center(),
}))
return item
}
}
}