add flow layout load more

This commit is contained in:
王劲鹏 2019-12-13 14:32:59 +08:00
parent a069cd7178
commit 5dea8b64e6

View File

@ -43,7 +43,11 @@ export class FlowLayout extends Superview implements IFlowLayout {
private ignoreDirtyCallOnce = false
allSubviews() {
return this.cachedViews.values()
if (this.loadMoreView) {
return [...this.cachedViews.values(), this.loadMoreView]
} else {
return this.cachedViews.values()
}
}
@Property
@ -64,6 +68,15 @@ export class FlowLayout extends Superview implements IFlowLayout {
@Property
batchCount = 15
@Property
onLoadMore?: () => void
@Property
loadMore?: boolean
@Property
loadMoreView?: FlowLayoutItem
reset() {
this.cachedViews.clear()
this.itemCount = 0
@ -91,6 +104,13 @@ export class FlowLayout extends Superview implements IFlowLayout {
return listItem.toModel()
})
}
toModel() {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId
}
return super.toModel()
}
}
export function flowlayout(config: IFlowLayout) {