js: add generated child remove api

This commit is contained in:
王劲鹏 2020-05-15 17:58:25 +08:00 committed by osborn
parent 750215917b
commit 4d80048d60
7 changed files with 37 additions and 1 deletions

View File

@ -444,6 +444,14 @@ class Group extends Superview {
addChild(view) { addChild(view) {
this.children.push(view); this.children.push(view);
} }
removeChild(view) {
const ret = this.children.filter(e => e !== view);
this.children.length = 0;
ret.forEach(e => this.addChild(e));
}
removeAllChildren() {
this.children.length = 0;
}
} }
const SPECIFIED = 1; const SPECIFIED = 1;

View File

@ -1903,6 +1903,14 @@ class Group extends Superview {
addChild(view) { addChild(view) {
this.children.push(view); this.children.push(view);
} }
removeChild(view) {
const ret = this.children.filter(e => e !== view);
this.children.length = 0;
ret.forEach(e => this.addChild(e));
}
removeAllChildren() {
this.children.length = 0;
}
} }
const SPECIFIED = 1; const SPECIFIED = 1;

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

@ -242,6 +242,8 @@ declare module 'doric/lib/src/ui/view' {
readonly children: View[]; readonly children: View[];
allSubviews(): View[]; allSubviews(): View[];
addChild(view: View): void; addChild(view: View): void;
removeChild(view: View): void;
removeAllChildren(): void;
} }
} }

View File

@ -123,4 +123,6 @@ export declare abstract class Group extends Superview {
readonly children: View[]; readonly children: View[];
allSubviews(): View[]; allSubviews(): View[];
addChild(view: View): void; addChild(view: View): void;
removeChild(view: View): void;
removeAllChildren(): void;
} }

View File

@ -329,4 +329,12 @@ export class Group extends Superview {
addChild(view) { addChild(view) {
this.children.push(view); this.children.push(view);
} }
removeChild(view) {
const ret = this.children.filter(e => e !== view);
this.children.length = 0;
ret.forEach(e => this.addChild(e));
}
removeAllChildren() {
this.children.length = 0;
}
} }

View File

@ -1961,6 +1961,14 @@ class Group extends Superview {
addChild(view) { addChild(view) {
this.children.push(view); this.children.push(view);
} }
removeChild(view) {
const ret = this.children.filter(e => e !== view);
this.children.length = 0;
ret.forEach(e => this.addChild(e));
}
removeAllChildren() {
this.children.length = 0;
}
} }
const SPECIFIED = 1; const SPECIFIED = 1;

File diff suppressed because one or more lines are too long