From a069cd717858829e4dec2b8d636081bb16f46d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 13 Dec 2019 14:32:39 +0800 Subject: [PATCH 1/2] potential es6 -> es5 code robust --- src/runtime/sandbox.ts | 3 ++- src/ui/view.ts | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/runtime/sandbox.ts b/src/runtime/sandbox.ts index f86b9ed8..12ac5555 100644 --- a/src/runtime/sandbox.ts +++ b/src/runtime/sandbox.ts @@ -194,11 +194,12 @@ export function jsObtainContext(id: string) { export function jsReleaseContext(id: string) { const context = gContexts.get(id) + const args = arguments if (context) { timerInfos.forEach((v, k) => { if (v.context === context) { if (global.nativeClearTimer === undefined) { - return Reflect.apply(_clearTimeout, undefined, arguments) + return Reflect.apply(_clearTimeout, undefined, args) } timerInfos.delete(k) nativeClearTimer(k) diff --git a/src/ui/view.ts b/src/ui/view.ts index 3ed26ffa..4f70088b 100644 --- a/src/ui/view.ts +++ b/src/ui/view.ts @@ -367,9 +367,11 @@ export abstract class Superview extends View { toModel() { const subviews = [] for (let v of this.allSubviews()) { - v.superview = this - if (v.isDirty()) { - subviews.push(v.toModel()) + if (v != undefined) { + v.superview = this + if (v.isDirty()) { + subviews.push(v.toModel()) + } } } this.dirtyProps.subviews = subviews From 5dea8b64e6c2b0171293bf14c0996c33abaa05ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 13 Dec 2019 14:32:59 +0800 Subject: [PATCH 2/2] add flow layout load more --- src/widget/flowlayout.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/widget/flowlayout.ts b/src/widget/flowlayout.ts index 5b8033d3..61d3191e 100644 --- a/src/widget/flowlayout.ts +++ b/src/widget/flowlayout.ts @@ -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) {