listview enable cell refresh

This commit is contained in:
pengfei.zhou
2019-11-13 20:43:05 +08:00
parent 3933582e1e
commit 4dcc89497d
7 changed files with 75 additions and 16 deletions

View File

@@ -40,10 +40,6 @@ export class ListItem extends Stack {
export class List extends Superview {
private cachedViews: Map<string, ListItem> = new Map
subviewById(id: string): ListItem | undefined {
return this.cachedViews.get(id)
}
allSubviews() {
return this.cachedViews.values()
}

View File

@@ -256,7 +256,13 @@ export abstract class View implements Modeling, IView {
}
export abstract class Superview extends View {
abstract subviewById(id: string): View | undefined
subviewById(id: string): View | undefined {
for (let v of this.allSubviews()) {
if (v.viewId === id) {
return v
}
}
}
abstract allSubviews(): Iterable<View>
isDirty() {
@@ -271,6 +277,17 @@ export abstract class Superview extends View {
}
return false
}
toModel() {
const subviews = []
for (let v of this.allSubviews()) {
if (v.isDirty()) {
subviews.push(v.toModel())
}
}
this.dirtyProps.subviews = subviews
return super.toModel()
}
}
export abstract class Group extends Superview {
@@ -284,15 +301,6 @@ export abstract class Group extends Superview {
}
})
subviewById(id: string): View | undefined {
for (let view of this.children) {
if (view.viewId === id) {
return view
}
}
return undefined
}
allSubviews() {
return this.children
}
@@ -310,7 +318,7 @@ export abstract class Group extends Superview {
return {}
}
})
return super.toModel()
return this.nativeViewModel
}
}