feat:List add header and footer

This commit is contained in:
pengfei.zhou
2021-10-09 16:50:34 +08:00
committed by osborn
parent f6d117da06
commit 5224be8f90
13 changed files with 243 additions and 46 deletions

View File

@@ -15,7 +15,7 @@ export declare class ListItem extends Stack {
}
export declare class List extends Superview {
private cachedViews;
allSubviews(): IterableIterator<ListItem> | ListItem[];
allSubviews(): ListItem[];
itemCount: number;
renderItem: (index: number) => ListItem;
batchCount: number;
@@ -36,6 +36,8 @@ export declare class List extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
header?: ListItem;
footer?: ListItem;
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
}): Promise<any>;

View File

@@ -43,12 +43,17 @@ export class List extends Superview {
this.batchCount = 15;
}
allSubviews() {
const ret = [...this.cachedViews.values()];
if (this.loadMoreView) {
return [...this.cachedViews.values(), this.loadMoreView];
ret.push(this.loadMoreView);
}
else {
return this.cachedViews.values();
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
@@ -74,6 +79,12 @@ export class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@@ -121,6 +132,14 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate([
Property,
__metadata("design:type", ListItem)
], List.prototype, "footer", void 0);
export function list(config) {
const ret = new List;
ret.apply(config);