add ListView DEMO ,show
This commit is contained in:
@@ -230,6 +230,7 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
|
||||
hookBeforeNativeCall(context)
|
||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
||||
hookAfterNativeCall(context)
|
||||
loge(methodName, ret)
|
||||
return ret
|
||||
} else {
|
||||
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
||||
|
@@ -34,7 +34,6 @@ export class ListItem extends Stack {
|
||||
*/
|
||||
@Property
|
||||
identifier?: string
|
||||
list!: List
|
||||
}
|
||||
|
||||
export class List extends Superview {
|
||||
@@ -61,14 +60,16 @@ export class List extends Superview {
|
||||
let view = this.cachedViews.get(`${itemIdx}`)
|
||||
if (view === undefined) {
|
||||
view = this.renderItem(itemIdx)
|
||||
view.list = this
|
||||
view.superview = this
|
||||
this.cachedViews.set(`${itemIdx}`, view)
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
@Property
|
||||
private renderBunchedItems(items: number[]): ListItem[] {
|
||||
return items.map(e => this.getItem(e))
|
||||
private renderBunchedItems(start: number, length: number) {
|
||||
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx)
|
||||
return listItem.toModel()
|
||||
})
|
||||
}
|
||||
}
|
@@ -94,7 +94,7 @@ export abstract class Panel {
|
||||
for (let i = 2; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i])
|
||||
}
|
||||
Reflect.apply(v.responseCallback, v, argumentsList)
|
||||
return Reflect.apply(v.responseCallback, v, argumentsList)
|
||||
}
|
||||
|
||||
private retrospectView(ids: string[]): View {
|
||||
|
@@ -121,7 +121,10 @@ export abstract class View implements Modeling, IView {
|
||||
}
|
||||
|
||||
private id2Callback(id: string) {
|
||||
const f = this.callbacks.get(id)
|
||||
let f = this.callbacks.get(id)
|
||||
if (f === undefined) {
|
||||
f = Reflect.get(this, id) as Function
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -228,7 +231,7 @@ export abstract class View implements Modeling, IView {
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i])
|
||||
}
|
||||
Reflect.apply(f, this, argumentsList)
|
||||
return Reflect.apply(f, this, argumentsList)
|
||||
} else {
|
||||
loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user