feat:add HeadView in panel
This commit is contained in:
parent
7ae868591f
commit
3e8c726330
@ -56,6 +56,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
RootNode rootNode = getDoricContext().getRootNode();
|
RootNode rootNode = getDoricContext().getRootNode();
|
||||||
|
rootNode.setId(jsObject.getProperty("id").asString().value());
|
||||||
rootNode.render(jsObject.getProperty("props").asObject());
|
rootNode.render(jsObject.getProperty("props").asObject());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
|||||||
do {
|
do {
|
||||||
ids.push(viewNode.mId);
|
ids.push(viewNode.mId);
|
||||||
viewNode = viewNode.mSuperNode;
|
viewNode = viewNode.mSuperNode;
|
||||||
} while (viewNode != null && !(viewNode instanceof RootNode));
|
} while (viewNode != null);
|
||||||
|
|
||||||
return ids.toArray(new String[0]);
|
return ids.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#import "DoricShaderPlugin.h"
|
#import "DoricShaderPlugin.h"
|
||||||
#import "DoricRootNode.h"
|
#import "DoricRootNode.h"
|
||||||
#import "DoricUtil.h"
|
#import "DoricUtil.h"
|
||||||
|
#import "Doric.h"
|
||||||
|
|
||||||
#import <JavaScriptCore/JavaScriptCore.h>
|
#import <JavaScriptCore/JavaScriptCore.h>
|
||||||
|
|
||||||
@ -31,13 +32,16 @@
|
|||||||
@implementation DoricShaderPlugin
|
@implementation DoricShaderPlugin
|
||||||
|
|
||||||
- (void)render:(NSDictionary *)argument {
|
- (void)render:(NSDictionary *)argument {
|
||||||
if(!argument) {
|
if (!argument) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__weak typeof(self) _self = self;
|
__weak typeof(self) _self = self;
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
[self.doricContext.rootNode render:argument[@"props"]];
|
[self.doricContext.rootNode also:^(DoricRootNode *it) {
|
||||||
|
it.viewId = argument[@"id"];
|
||||||
|
[it render:argument[@"props"]];
|
||||||
|
}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ - (void)onClick:(UIView *)view {
|
|||||||
do {
|
do {
|
||||||
[ret addObject:node.viewId];
|
[ret addObject:node.viewId];
|
||||||
node = node.superNode;
|
node = node.superNode;
|
||||||
} while (node && ![node isKindOfClass:[DoricRootNode class]]);
|
} while (node);
|
||||||
|
|
||||||
return [[ret reverseObjectEnumerator] allObjects];
|
return [[ret reverseObjectEnumerator] allObjects];
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,11 @@ export abstract class Panel {
|
|||||||
|
|
||||||
private __data__: any
|
private __data__: any
|
||||||
private __root__ = new Root
|
private __root__ = new Root
|
||||||
|
private headviews: Map<string, View> = new Map
|
||||||
|
|
||||||
|
addHeadView(v: View) {
|
||||||
|
this.headviews.set(v.viewId, v)
|
||||||
|
}
|
||||||
|
|
||||||
getRootView() {
|
getRootView() {
|
||||||
return this.__root__
|
return this.__root__
|
||||||
@ -50,6 +55,9 @@ export abstract class Panel {
|
|||||||
getInitData() {
|
getInitData() {
|
||||||
return this.__data__
|
return this.__data__
|
||||||
}
|
}
|
||||||
|
constructor() {
|
||||||
|
this.addHeadView(this.__root__)
|
||||||
|
}
|
||||||
|
|
||||||
@NativeCall
|
@NativeCall
|
||||||
private __init__(frame: Frame, data: any) {
|
private __init__(frame: Frame, data: any) {
|
||||||
@ -90,21 +98,26 @@ export abstract class Panel {
|
|||||||
const v = this.retrospectView(viewIds)
|
const v = this.retrospectView(viewIds)
|
||||||
if (v === undefined) {
|
if (v === undefined) {
|
||||||
loge(`Cannot find view for ${viewIds}`)
|
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 {
|
private retrospectView(ids: string[]): View | undefined {
|
||||||
return ids.reduce((acc: View, cur) => {
|
return ids.reduce((acc: View | undefined, cur) => {
|
||||||
if (Reflect.has(acc, "subviewById")) {
|
if (acc === undefined) {
|
||||||
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
return this.headviews.get(cur)
|
||||||
|
} else {
|
||||||
|
if (Reflect.has(acc, "subviewById")) {
|
||||||
|
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
||||||
|
}
|
||||||
|
return acc
|
||||||
}
|
}
|
||||||
return acc
|
}, undefined)
|
||||||
}, this.__root__)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private nativeRender(model: Model) {
|
private nativeRender(model: Model) {
|
||||||
|
@ -180,3 +180,18 @@ export function navigator(context: BridgeContext) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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