iOS: implements navbar set center
This commit is contained in:
parent
007786f4ef
commit
2e9459f80f
@ -134,6 +134,10 @@ - (void)doric_navBar_setRight:(UIView *)view {
|
||||
self.navigationItem.rightBarButtonItem = custom;
|
||||
}
|
||||
|
||||
- (void)doric_navBar_setCenter:(UIView *)view {
|
||||
self.navigationItem.titleView = view;
|
||||
}
|
||||
|
||||
- (BOOL)statusBarHidden {
|
||||
return _statusBarHidden;
|
||||
}
|
||||
|
@ -32,4 +32,6 @@
|
||||
- (void)doric_navBar_setLeft:(UIView *)view;
|
||||
|
||||
- (void)doric_navBar_setRight:(UIView *)view;
|
||||
|
||||
- (void)doric_navBar_setCenter:(UIView *)view;
|
||||
@end
|
||||
|
@ -26,6 +26,7 @@ @implementation DoricNavBarPlugin
|
||||
|
||||
static NSString *TYPE_LEFT = @"navbar_left";
|
||||
static NSString *TYPE_RIGHT = @"navbar_right";
|
||||
static NSString *TYPE_CENTER = @"navbar_center";
|
||||
|
||||
- (void)isHidden:(NSDictionary *)param withPromise:(DoricPromise *)promise {
|
||||
if (self.doricContext.navBar) {
|
||||
@ -133,4 +134,35 @@ - (void)setRight:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setCenter:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
||||
if (self.doricContext.navBar) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString *viewId = params[@"id"];
|
||||
NSString *type = params[@"type"];
|
||||
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
|
||||
if (!viewNode) {
|
||||
viewNode = [[DoricViewNode create:self.doricContext withType:type] also:^(DoricViewNode *it) {
|
||||
it.viewId = viewId;
|
||||
[it initWithSuperNode:nil];
|
||||
it.view.doricLayout = [DoricLayout new];
|
||||
[self.doricContext.navBar doric_navBar_setCenter:it.view];
|
||||
|
||||
NSMutableDictionary <NSString *, DoricViewNode *> *map = self.doricContext.headNodes[TYPE_CENTER];
|
||||
if (map != nil) {
|
||||
self.doricContext.headNodes[TYPE_CENTER][viewId] = it;
|
||||
} else {
|
||||
map = [[NSMutableDictionary alloc] init];
|
||||
map[viewId] = it;
|
||||
self.doricContext.headNodes[TYPE_CENTER] = map;
|
||||
}
|
||||
}];
|
||||
}
|
||||
[viewNode blend:params[@"props"]];
|
||||
[promise resolve:nil];
|
||||
});
|
||||
} else {
|
||||
[promise reject:@"Not implement NavBar"];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user