2019-10-21 09:59:22 +08:00
|
|
|
/*
|
|
|
|
* Copyright [2019] [Doric.Pub]
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-07-27 14:36:41 +08:00
|
|
|
//
|
|
|
|
// DoricRegistry.m
|
|
|
|
// Doric
|
|
|
|
//
|
|
|
|
// Created by pengfei.zhou on 2019/7/27.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "DoricRegistry.h"
|
2019-07-29 20:23:00 +08:00
|
|
|
#import "DoricModalPlugin.h"
|
2019-11-21 20:16:48 +08:00
|
|
|
#import "DoricNetworkPlugin.h"
|
2019-07-30 11:25:05 +08:00
|
|
|
#import "DoricShaderPlugin.h"
|
2019-07-30 21:05:27 +08:00
|
|
|
#import "DoricStackNode.h"
|
|
|
|
#import "DoricVLayoutNode.h"
|
|
|
|
#import "DoricHLayoutNode.h"
|
2019-07-31 14:18:20 +08:00
|
|
|
#import "DoricTextNode.h"
|
2019-08-06 20:06:34 +08:00
|
|
|
#import "DoricImageNode.h"
|
2019-11-15 19:30:07 +08:00
|
|
|
#import "DoricListNode.h"
|
|
|
|
#import "DoricListItemNode.h"
|
2019-11-19 11:21:49 +08:00
|
|
|
#import "DoricScrollerNode.h"
|
2019-11-19 16:23:51 +08:00
|
|
|
#import "DoricSliderNode.h"
|
|
|
|
#import "DoricSlideItemNode.h"
|
2019-11-22 11:11:22 +08:00
|
|
|
#import "DoricStoragePlugin.h"
|
2019-11-23 17:22:27 +08:00
|
|
|
#import "DoricNavigatorPlugin.h"
|
2019-11-25 14:20:18 +08:00
|
|
|
#import "DoricNavBarPlugin.h"
|
2019-11-26 20:15:16 +08:00
|
|
|
#import "DoricRefreshableNode.h"
|
2019-11-28 15:25:34 +08:00
|
|
|
#import "DoricFlowLayoutItemNode.h"
|
|
|
|
#import "DoricFlowLayoutNode.h"
|
2019-07-29 20:23:00 +08:00
|
|
|
|
|
|
|
@interface DoricRegistry ()
|
|
|
|
|
2019-10-12 14:48:19 +08:00
|
|
|
@property(nonatomic, strong) NSMutableDictionary *bundles;
|
|
|
|
@property(nonatomic, strong) NSMutableDictionary *plugins;
|
|
|
|
@property(nonatomic, strong) NSMutableDictionary *nodes;
|
2019-07-29 20:23:00 +08:00
|
|
|
|
|
|
|
@end
|
2019-07-27 14:36:41 +08:00
|
|
|
|
|
|
|
@implementation DoricRegistry
|
|
|
|
|
2019-07-29 20:23:00 +08:00
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-29 20:23:00 +08:00
|
|
|
_bundles = [[NSMutableDictionary alloc] init];
|
|
|
|
_plugins = [[NSMutableDictionary alloc] init];
|
2019-07-30 21:05:27 +08:00
|
|
|
_nodes = [[NSMutableDictionary alloc] init];
|
2019-07-29 20:23:00 +08:00
|
|
|
[self innerRegister];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)innerRegister {
|
2019-11-22 11:11:22 +08:00
|
|
|
[self registerNativePlugin:DoricShaderPlugin.class withName:@"shader"];
|
2019-07-29 20:23:00 +08:00
|
|
|
[self registerNativePlugin:DoricModalPlugin.class withName:@"modal"];
|
2019-11-21 20:16:48 +08:00
|
|
|
[self registerNativePlugin:DoricNetworkPlugin.class withName:@"network"];
|
2019-11-22 11:11:22 +08:00
|
|
|
[self registerNativePlugin:DoricStoragePlugin.class withName:@"storage"];
|
2019-11-23 17:22:27 +08:00
|
|
|
[self registerNativePlugin:DoricNavigatorPlugin.class withName:@"navigator"];
|
2019-11-25 14:20:18 +08:00
|
|
|
[self registerNativePlugin:DoricNavBarPlugin.class withName:@"navbar"];
|
2019-10-12 14:48:19 +08:00
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
[self registerViewNode:DoricStackNode.class withName:@"Stack"];
|
|
|
|
[self registerViewNode:DoricVLayoutNode.class withName:@"VLayout"];
|
|
|
|
[self registerViewNode:DoricHLayoutNode.class withName:@"HLayout"];
|
2019-07-31 14:18:20 +08:00
|
|
|
[self registerViewNode:DoricTextNode.class withName:@"Text"];
|
2019-08-06 20:06:34 +08:00
|
|
|
[self registerViewNode:DoricImageNode.class withName:@"Image"];
|
2019-11-15 19:30:07 +08:00
|
|
|
[self registerViewNode:DoricListNode.class withName:@"List"];
|
|
|
|
[self registerViewNode:DoricListItemNode.class withName:@"ListItem"];
|
2019-11-19 11:21:49 +08:00
|
|
|
[self registerViewNode:DoricScrollerNode.class withName:@"Scroller"];
|
2019-11-19 16:23:51 +08:00
|
|
|
[self registerViewNode:DoricSliderNode.class withName:@"Slider"];
|
|
|
|
[self registerViewNode:DoricSlideItemNode.class withName:@"SlideItem"];
|
2019-11-26 20:15:16 +08:00
|
|
|
[self registerViewNode:DoricRefreshableNode.class withName:@"Refreshable"];
|
2019-11-28 15:25:34 +08:00
|
|
|
[self registerViewNode:DoricFlowLayoutItemNode.class withName:@"FlowLayoutItem"];
|
|
|
|
[self registerViewNode:DoricFlowLayoutNode.class withName:@"FlowLayout"];
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerJSBundle:(NSString *)bundle withName:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
self.bundles[name] = bundle;
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)acquireJSBundle:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
return self.bundles[name];
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerNativePlugin:(Class)pluginClass withName:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
self.plugins[name] = pluginClass;
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (Class)acquireNativePlugin:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
return self.plugins[name];
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
- (void)registerViewNode:(Class)nodeClass withName:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
self.nodes[name] = nodeClass;
|
2019-07-30 21:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (Class)acquireViewNode:(NSString *)name {
|
2019-10-23 20:17:24 +08:00
|
|
|
return self.nodes[name];
|
2019-07-30 21:05:27 +08:00
|
|
|
}
|
|
|
|
|
2019-07-27 14:36:41 +08:00
|
|
|
@end
|