feat:add nativeChannel to let js call native view's method
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { LayoutConfig, Group, Property, IView } from "./view";
|
||||
import { Group, Property, IView } from "./view";
|
||||
import { Gravity } from "../util/gravity";
|
||||
|
||||
export interface IStack extends IView {
|
||||
@@ -22,8 +22,6 @@ export interface IStack extends IView {
|
||||
export class Stack extends Group implements IStack {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class Root extends Stack {
|
||||
|
||||
}
|
||||
|
@@ -255,6 +255,24 @@ export abstract class View implements Modeling, IView {
|
||||
in(group: Group) {
|
||||
group.addChild(this)
|
||||
}
|
||||
|
||||
nativeChannel(context: any, name: string) {
|
||||
let thisView: View | undefined = this
|
||||
return function (...args: any) {
|
||||
const func = context.shader.command
|
||||
const viewIds = []
|
||||
while (thisView != undefined) {
|
||||
viewIds.push(thisView.viewId)
|
||||
thisView = thisView.superview
|
||||
}
|
||||
const params = {
|
||||
viewIds: viewIds.reverse(),
|
||||
name,
|
||||
args,
|
||||
}
|
||||
return Reflect.apply(func, undefined, [params]) as Promise<any>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Superview extends View {
|
||||
|
Reference in New Issue
Block a user