feat:add HeadView in panel
This commit is contained in:
parent
7ae868591f
commit
3e8c726330
@ -56,6 +56,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
RootNode rootNode = getDoricContext().getRootNode();
|
||||
rootNode.setId(jsObject.getProperty("id").asString().value());
|
||||
rootNode.render(jsObject.getProperty("props").asObject());
|
||||
return null;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
do {
|
||||
ids.push(viewNode.mId);
|
||||
viewNode = viewNode.mSuperNode;
|
||||
} while (viewNode != null && !(viewNode instanceof RootNode));
|
||||
} while (viewNode != null);
|
||||
|
||||
return ids.toArray(new String[0]);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#import "DoricShaderPlugin.h"
|
||||
#import "DoricRootNode.h"
|
||||
#import "DoricUtil.h"
|
||||
#import "Doric.h"
|
||||
|
||||
#import <JavaScriptCore/JavaScriptCore.h>
|
||||
|
||||
@ -31,13 +32,16 @@
|
||||
@implementation DoricShaderPlugin
|
||||
|
||||
- (void)render:(NSDictionary *)argument {
|
||||
if(!argument) {
|
||||
if (!argument) {
|
||||
return;
|
||||
}
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__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 {
|
||||
[ret addObject:node.viewId];
|
||||
node = node.superNode;
|
||||
} while (node && ![node isKindOfClass:[DoricRootNode class]]);
|
||||
} while (node);
|
||||
|
||||
return [[ret reverseObjectEnumerator] allObjects];
|
||||
}
|
||||
|
@ -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