flowlayout add header and footer:js and android implement

This commit is contained in:
pengfei.zhou
2021-10-11 11:14:55 +08:00
committed by osborn
parent 5224be8f90
commit 5ad4f4b981
12 changed files with 208 additions and 32 deletions

View File

@@ -2944,12 +2944,17 @@ var FlowLayout = /** @class */ (function (_super) {
return _this;
}
FlowLayout.prototype.allSubviews = function () {
var ret = __spreadArray([], __read(this.cachedViews.values()));
if (this.loadMoreView) {
return __spreadArray(__spreadArray([], __read(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;
};
FlowLayout.prototype.reset = function () {
this.cachedViews.clear();
@@ -2972,6 +2977,12 @@ var FlowLayout = /** @class */ (function (_super) {
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.prototype.toModel.call(this);
};
__decorate$5([
@@ -3026,6 +3037,14 @@ var FlowLayout = /** @class */ (function (_super) {
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
return FlowLayout;
}(Superview));
function flowlayout(config) {

View File

@@ -2220,12 +2220,17 @@ class FlowLayout 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;
}
reset() {
this.cachedViews.clear();
@@ -2247,6 +2252,12 @@ class FlowLayout 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();
}
}
@@ -2302,6 +2313,14 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

View File

@@ -3741,12 +3741,17 @@ class FlowLayout 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;
}
reset() {
this.cachedViews.clear();
@@ -3768,6 +3773,12 @@ class FlowLayout 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();
}
}
@@ -3823,6 +3834,14 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

4
doric-js/index.d.ts vendored
View File

@@ -832,7 +832,7 @@ declare module 'doric/lib/src/widget/flowlayout' {
identifier?: string;
}
export class FlowLayout extends Superview {
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];
allSubviews(): FlowLayoutItem[];
columnCount: number;
columnSpace?: number;
rowSpace?: number;
@@ -855,6 +855,8 @@ declare module 'doric/lib/src/widget/flowlayout' {
* Take effect only on iOS
*/
bounces?: boolean;
header?: FlowLayoutItem;
footer?: FlowLayoutItem;
reset(): void;
toModel(): NativeViewModel;
}

View File

@@ -8,7 +8,7 @@ export declare class FlowLayoutItem extends Stack {
}
export declare class FlowLayout extends Superview {
private cachedViews;
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];
allSubviews(): FlowLayoutItem[];
columnCount: number;
columnSpace?: number;
rowSpace?: number;
@@ -31,6 +31,8 @@ export declare class FlowLayout extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
header?: FlowLayoutItem;
footer?: FlowLayoutItem;
reset(): void;
private getItem;
private renderBunchedItems;

View File

@@ -40,12 +40,17 @@ export class FlowLayout 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;
}
reset() {
this.cachedViews.clear();
@@ -67,6 +72,12 @@ export class FlowLayout 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();
}
}
@@ -122,6 +133,14 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate([
Property,
__metadata("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
export function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

View File

@@ -29,11 +29,17 @@ export class FlowLayout extends Superview {
private cachedViews: Map<string, FlowLayoutItem> = new Map
allSubviews() {
const ret = [...this.cachedViews.values()]
if (this.loadMoreView) {
return [...this.cachedViews.values(), this.loadMoreView]
} else {
return this.cachedViews.values()
ret.push(this.loadMoreView)
}
if (this.header) {
ret.push(this.header)
}
if (this.footer) {
ret.push(this.footer)
}
return ret
}
@Property
@@ -77,6 +83,12 @@ export class FlowLayout extends Superview {
@Property
bounces?: boolean
@Property
header?: FlowLayoutItem
@Property
footer?: FlowLayoutItem
reset() {
this.cachedViews.clear()
this.itemCount = 0
@@ -98,6 +110,12 @@ export class FlowLayout 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()
}
}