head view manipulation api changed
This commit is contained in:
parent
88d45c2967
commit
56852286e3
@ -671,22 +671,37 @@ class Panel {
|
||||
onDestroy() { }
|
||||
onShow() { }
|
||||
onHidden() { }
|
||||
addHeadView(v) {
|
||||
this.headviews.set(v.viewId, v);
|
||||
addHeadView(type, v) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
map.set(v.viewId, v);
|
||||
}
|
||||
else {
|
||||
map = new Map;
|
||||
map.set(v.viewId, v);
|
||||
this.headviews.set(type, map);
|
||||
}
|
||||
}
|
||||
allHeadViews() {
|
||||
return this.headviews.values();
|
||||
}
|
||||
removeHeadView(v) {
|
||||
removeHeadView(type, v) {
|
||||
if (this.headviews.has(type)) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
if (v instanceof View) {
|
||||
this.headviews.delete(v.viewId);
|
||||
map.delete(v.viewId);
|
||||
}
|
||||
else {
|
||||
this.headviews.delete(v);
|
||||
map.delete(v);
|
||||
}
|
||||
}
|
||||
clearHeadViews() {
|
||||
this.headviews.clear();
|
||||
}
|
||||
}
|
||||
clearHeadViews(type) {
|
||||
if (this.headviews.has(type)) {
|
||||
this.headviews.delete(type);
|
||||
}
|
||||
}
|
||||
getRootView() {
|
||||
return this.__root__;
|
||||
@ -753,11 +768,13 @@ class Panel {
|
||||
hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
this.__root__.clean();
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hookAfterNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
@ -766,13 +783,15 @@ class Panel {
|
||||
const model = this.__root__.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Promise.resolve().then(() => {
|
||||
if (this.__root__.isDirty()) {
|
||||
@ -780,13 +799,15 @@ class Panel {
|
||||
this.nativeRender(model);
|
||||
this.__root__.clean();
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1944,17 +1965,17 @@ function popover(context) {
|
||||
return {
|
||||
show: (view) => {
|
||||
if (panel) {
|
||||
panel.addHeadView(view);
|
||||
panel.addHeadView("popover", view);
|
||||
}
|
||||
return context.popover.show(view.toModel());
|
||||
},
|
||||
dismiss: (view = undefined) => {
|
||||
if (panel) {
|
||||
if (view) {
|
||||
panel.removeHeadView(view);
|
||||
panel.removeHeadView("popover", view);
|
||||
}
|
||||
else {
|
||||
panel.clearHeadViews();
|
||||
panel.clearHeadViews("popover");
|
||||
}
|
||||
}
|
||||
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
|
||||
@ -2060,7 +2081,8 @@ function animate(context) {
|
||||
root.clean();
|
||||
return ret;
|
||||
}
|
||||
for (let v of panel.allHeadViews()) {
|
||||
for (let map of panel.allHeadViews()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
const ret = it.animateRender(model);
|
||||
@ -2068,6 +2090,7 @@ function animate(context) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Cannot find any animated elements');
|
||||
});
|
||||
});
|
||||
|
@ -2130,22 +2130,37 @@ class Panel {
|
||||
onDestroy() { }
|
||||
onShow() { }
|
||||
onHidden() { }
|
||||
addHeadView(v) {
|
||||
this.headviews.set(v.viewId, v);
|
||||
addHeadView(type, v) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
map.set(v.viewId, v);
|
||||
}
|
||||
else {
|
||||
map = new Map;
|
||||
map.set(v.viewId, v);
|
||||
this.headviews.set(type, map);
|
||||
}
|
||||
}
|
||||
allHeadViews() {
|
||||
return this.headviews.values();
|
||||
}
|
||||
removeHeadView(v) {
|
||||
removeHeadView(type, v) {
|
||||
if (this.headviews.has(type)) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
if (v instanceof View) {
|
||||
this.headviews.delete(v.viewId);
|
||||
map.delete(v.viewId);
|
||||
}
|
||||
else {
|
||||
this.headviews.delete(v);
|
||||
map.delete(v);
|
||||
}
|
||||
}
|
||||
clearHeadViews() {
|
||||
this.headviews.clear();
|
||||
}
|
||||
}
|
||||
clearHeadViews(type) {
|
||||
if (this.headviews.has(type)) {
|
||||
this.headviews.delete(type);
|
||||
}
|
||||
}
|
||||
getRootView() {
|
||||
return this.__root__;
|
||||
@ -2212,11 +2227,13 @@ class Panel {
|
||||
hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
this.__root__.clean();
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hookAfterNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
@ -2225,13 +2242,15 @@ class Panel {
|
||||
const model = this.__root__.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Promise.resolve().then(() => {
|
||||
if (this.__root__.isDirty()) {
|
||||
@ -2239,13 +2258,15 @@ class Panel {
|
||||
this.nativeRender(model);
|
||||
this.__root__.clean();
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -3403,17 +3424,17 @@ function popover(context) {
|
||||
return {
|
||||
show: (view) => {
|
||||
if (panel) {
|
||||
panel.addHeadView(view);
|
||||
panel.addHeadView("popover", view);
|
||||
}
|
||||
return context.popover.show(view.toModel());
|
||||
},
|
||||
dismiss: (view = undefined) => {
|
||||
if (panel) {
|
||||
if (view) {
|
||||
panel.removeHeadView(view);
|
||||
panel.removeHeadView("popover", view);
|
||||
}
|
||||
else {
|
||||
panel.clearHeadViews();
|
||||
panel.clearHeadViews("popover");
|
||||
}
|
||||
}
|
||||
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
|
||||
@ -3519,7 +3540,8 @@ function animate(context) {
|
||||
root.clean();
|
||||
return ret;
|
||||
}
|
||||
for (let v of panel.allHeadViews()) {
|
||||
for (let map of panel.allHeadViews()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
const ret = it.animateRender(model);
|
||||
@ -3527,6 +3549,7 @@ function animate(context) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Cannot find any animated elements');
|
||||
});
|
||||
});
|
||||
|
8
doric-js/index.d.ts
vendored
8
doric-js/index.d.ts
vendored
@ -256,10 +256,10 @@ declare module 'doric/lib/src/ui/panel' {
|
||||
onShow(): void;
|
||||
onHidden(): void;
|
||||
abstract build(rootView: Group): void;
|
||||
addHeadView(v: View): void;
|
||||
allHeadViews(): IterableIterator<View>;
|
||||
removeHeadView(v: View | string): void;
|
||||
clearHeadViews(): void;
|
||||
addHeadView(type: string, v: View): void;
|
||||
allHeadViews(): IterableIterator<Map<string, View>>;
|
||||
removeHeadView(type: string, v: View | string): void;
|
||||
clearHeadViews(type: string): void;
|
||||
getRootView(): Root;
|
||||
getInitData(): object | undefined;
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ export function animate(context) {
|
||||
root.clean();
|
||||
return ret;
|
||||
}
|
||||
for (let v of panel.allHeadViews()) {
|
||||
for (let map of panel.allHeadViews()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
const ret = it.animateRender(model);
|
||||
@ -43,6 +44,7 @@ export function animate(context) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Cannot find any animated elements');
|
||||
});
|
||||
});
|
||||
|
@ -8,17 +8,17 @@ export function popover(context) {
|
||||
return {
|
||||
show: (view) => {
|
||||
if (panel) {
|
||||
panel.addHeadView(view);
|
||||
panel.addHeadView("popover", view);
|
||||
}
|
||||
return context.popover.show(view.toModel());
|
||||
},
|
||||
dismiss: (view = undefined) => {
|
||||
if (panel) {
|
||||
if (view) {
|
||||
panel.removeHeadView(view);
|
||||
panel.removeHeadView("popover", view);
|
||||
}
|
||||
else {
|
||||
panel.clearHeadViews();
|
||||
panel.clearHeadViews("popover");
|
||||
}
|
||||
}
|
||||
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
|
||||
|
8
doric-js/lib/src/ui/panel.d.ts
vendored
8
doric-js/lib/src/ui/panel.d.ts
vendored
@ -12,10 +12,10 @@ export declare abstract class Panel {
|
||||
private __data__?;
|
||||
private __root__;
|
||||
private headviews;
|
||||
addHeadView(v: View): void;
|
||||
allHeadViews(): IterableIterator<View>;
|
||||
removeHeadView(v: View | string): void;
|
||||
clearHeadViews(): void;
|
||||
addHeadView(type: string, v: View): void;
|
||||
allHeadViews(): IterableIterator<Map<string, View>>;
|
||||
removeHeadView(type: string, v: View | string): void;
|
||||
clearHeadViews(type: string): void;
|
||||
getRootView(): Root;
|
||||
getInitData(): object | undefined;
|
||||
private __init__;
|
||||
|
@ -42,22 +42,37 @@ export class Panel {
|
||||
onDestroy() { }
|
||||
onShow() { }
|
||||
onHidden() { }
|
||||
addHeadView(v) {
|
||||
this.headviews.set(v.viewId, v);
|
||||
addHeadView(type, v) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
map.set(v.viewId, v);
|
||||
}
|
||||
else {
|
||||
map = new Map;
|
||||
map.set(v.viewId, v);
|
||||
this.headviews.set(type, map);
|
||||
}
|
||||
}
|
||||
allHeadViews() {
|
||||
return this.headviews.values();
|
||||
}
|
||||
removeHeadView(v) {
|
||||
removeHeadView(type, v) {
|
||||
if (this.headviews.has(type)) {
|
||||
let map = this.headviews.get(type);
|
||||
if (map) {
|
||||
if (v instanceof View) {
|
||||
this.headviews.delete(v.viewId);
|
||||
map.delete(v.viewId);
|
||||
}
|
||||
else {
|
||||
this.headviews.delete(v);
|
||||
map.delete(v);
|
||||
}
|
||||
}
|
||||
clearHeadViews() {
|
||||
this.headviews.clear();
|
||||
}
|
||||
}
|
||||
clearHeadViews(type) {
|
||||
if (this.headviews.has(type)) {
|
||||
this.headviews.delete(type);
|
||||
}
|
||||
}
|
||||
getRootView() {
|
||||
return this.__root__;
|
||||
@ -124,11 +139,13 @@ export class Panel {
|
||||
hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
this.__root__.clean();
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hookAfterNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
@ -137,13 +154,15 @@ export class Panel {
|
||||
const model = this.__root__.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Promise.resolve().then(() => {
|
||||
if (this.__root__.isDirty()) {
|
||||
@ -151,13 +170,15 @@ export class Panel {
|
||||
this.nativeRender(model);
|
||||
this.__root__.clean();
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
this.nativeRender(model);
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ export function animate(context: BridgeContext) {
|
||||
root.clean()
|
||||
return ret
|
||||
}
|
||||
for (let v of panel.allHeadViews()) {
|
||||
for (let map of panel.allHeadViews()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel()
|
||||
const ret = it.animateRender(model)
|
||||
@ -47,6 +48,7 @@ export function animate(context: BridgeContext) {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Cannot find any animated elements')
|
||||
})
|
||||
})
|
||||
|
@ -26,16 +26,16 @@ export function popover(context: BridgeContext) {
|
||||
return {
|
||||
show: (view: View) => {
|
||||
if (panel) {
|
||||
panel.addHeadView(view)
|
||||
panel.addHeadView("popover", view)
|
||||
}
|
||||
return context.popover.show(view.toModel())
|
||||
},
|
||||
dismiss: (view: View | undefined = undefined) => {
|
||||
if (panel) {
|
||||
if (view) {
|
||||
panel.removeHeadView(view)
|
||||
panel.removeHeadView("popover", view)
|
||||
} else {
|
||||
panel.clearHeadViews()
|
||||
panel.clearHeadViews("popover")
|
||||
}
|
||||
}
|
||||
return context.popover.dismiss(view ? { id: view.viewId } : undefined)
|
||||
|
@ -43,24 +43,38 @@ export abstract class Panel {
|
||||
|
||||
private __data__?: object
|
||||
private __root__ = new Root
|
||||
private headviews: Map<string, View> = new Map
|
||||
private headviews: Map<string, Map<string, View>> = new Map
|
||||
|
||||
addHeadView(v: View) {
|
||||
this.headviews.set(v.viewId, v)
|
||||
addHeadView(type: string, v: View) {
|
||||
let map = this.headviews.get(type)
|
||||
if (map) {
|
||||
map.set(v.viewId, v)
|
||||
} else {
|
||||
map = new Map
|
||||
map.set(v.viewId, v)
|
||||
this.headviews.set(type, map)
|
||||
}
|
||||
}
|
||||
allHeadViews() {
|
||||
return this.headviews.values()
|
||||
}
|
||||
removeHeadView(v: View | string) {
|
||||
removeHeadView(type: string, v: View | string) {
|
||||
if (this.headviews.has(type)) {
|
||||
let map = this.headviews.get(type)
|
||||
if (map) {
|
||||
if (v instanceof View) {
|
||||
this.headviews.delete(v.viewId)
|
||||
map.delete(v.viewId)
|
||||
} else {
|
||||
this.headviews.delete(v)
|
||||
map.delete(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearHeadViews() {
|
||||
this.headviews.clear()
|
||||
clearHeadViews(type: string) {
|
||||
if (this.headviews.has(type)) {
|
||||
this.headviews.delete(type)
|
||||
}
|
||||
}
|
||||
|
||||
getRootView() {
|
||||
@ -144,11 +158,13 @@ export abstract class Panel {
|
||||
private hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
this.__root__.clean()
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
v.clean()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private hookAfterNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
@ -158,12 +174,14 @@ export abstract class Panel {
|
||||
const model = this.__root__.toModel()
|
||||
this.nativeRender(model)
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel()
|
||||
this.nativeRender(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Promise.resolve().then(() => {
|
||||
if (this.__root__.isDirty()) {
|
||||
@ -171,13 +189,15 @@ export abstract class Panel {
|
||||
this.nativeRender(model)
|
||||
this.__root__.clean()
|
||||
}
|
||||
for (let v of this.headviews.values()) {
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel()
|
||||
this.nativeRender(model)
|
||||
v.clean()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user