feat:add HeadView in panel
This commit is contained in:
@@ -42,6 +42,11 @@ export abstract class Panel {
|
||||
|
||||
private __data__: any
|
||||
private __root__ = new Root
|
||||
private headviews: Map<string, View> = new Map
|
||||
|
||||
addHeadView(v: View) {
|
||||
this.headviews.set(v.viewId, v)
|
||||
}
|
||||
|
||||
getRootView() {
|
||||
return this.__root__
|
||||
@@ -50,6 +55,9 @@ export abstract class Panel {
|
||||
getInitData() {
|
||||
return this.__data__
|
||||
}
|
||||
constructor() {
|
||||
this.addHeadView(this.__root__)
|
||||
}
|
||||
|
||||
@NativeCall
|
||||
private __init__(frame: Frame, data: any) {
|
||||
@@ -90,21 +98,26 @@ export abstract class Panel {
|
||||
const v = this.retrospectView(viewIds)
|
||||
if (v === undefined) {
|
||||
loge(`Cannot find view for ${viewIds}`)
|
||||
} else {
|
||||
const argumentsList: any = [callbackId]
|
||||
for (let i = 2; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i])
|
||||
}
|
||||
return Reflect.apply(v.responseCallback, v, argumentsList)
|
||||
}
|
||||
const argumentsList: any = [callbackId]
|
||||
for (let i = 2; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i])
|
||||
}
|
||||
return Reflect.apply(v.responseCallback, v, argumentsList)
|
||||
}
|
||||
|
||||
private retrospectView(ids: string[]): View {
|
||||
return ids.reduce((acc: View, cur) => {
|
||||
if (Reflect.has(acc, "subviewById")) {
|
||||
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
||||
private retrospectView(ids: string[]): View | undefined {
|
||||
return ids.reduce((acc: View | undefined, cur) => {
|
||||
if (acc === undefined) {
|
||||
return this.headviews.get(cur)
|
||||
} else {
|
||||
if (Reflect.has(acc, "subviewById")) {
|
||||
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
||||
}
|
||||
return acc
|
||||
}
|
||||
return acc
|
||||
}, this.__root__)
|
||||
}, undefined)
|
||||
}
|
||||
|
||||
private nativeRender(model: Model) {
|
||||
|
@@ -179,4 +179,19 @@ export function navigator(context: BridgeContext) {
|
||||
return context.navigator.pop({ animated })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function navbar(context: BridgeContext) {
|
||||
return {
|
||||
setHidden: (hidden: boolean) => {
|
||||
return context.navbar.push({
|
||||
hidden,
|
||||
})
|
||||
},
|
||||
setTitle: (title: string) => {
|
||||
return context.navbar.push({
|
||||
title,
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user