feat:add DoricLibrary
This commit is contained in:
parent
30d8fb4b71
commit
3545424f62
@ -11,6 +11,7 @@
|
|||||||
C6AF7EB0B40D76A46B2BB384 /* Pods_ExampleUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF50786B1D1793EC3228133B /* Pods_ExampleUITests.framework */; };
|
C6AF7EB0B40D76A46B2BB384 /* Pods_ExampleUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF50786B1D1793EC3228133B /* Pods_ExampleUITests.framework */; };
|
||||||
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D19E97EF4EDD7588FEBE /* DemoVC.m */; };
|
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D19E97EF4EDD7588FEBE /* DemoVC.m */; };
|
||||||
D751D4FCC0A2322211DE3D55 /* QRScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D751DA399F1ADB6D34563B5D /* QRScanViewController.m */; };
|
D751D4FCC0A2322211DE3D55 /* QRScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D751DA399F1ADB6D34563B5D /* QRScanViewController.m */; };
|
||||||
|
D751DDB012BAF476A252CD93 /* DemoLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D2175D09F2C10691FB81 /* DemoLibrary.m */; };
|
||||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
|
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
|
||||||
E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; };
|
E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; };
|
||||||
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; };
|
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; };
|
||||||
@ -51,7 +52,9 @@
|
|||||||
BF50786B1D1793EC3228133B /* Pods_ExampleUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
BF50786B1D1793EC3228133B /* Pods_ExampleUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D751D18AD6496F4A9BE1AB45 /* QRScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRScanViewController.h; sourceTree = "<group>"; };
|
D751D18AD6496F4A9BE1AB45 /* QRScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRScanViewController.h; sourceTree = "<group>"; };
|
||||||
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
||||||
|
D751D2175D09F2C10691FB81 /* DemoLibrary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoLibrary.m; sourceTree = "<group>"; };
|
||||||
D751DA399F1ADB6D34563B5D /* QRScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRScanViewController.m; sourceTree = "<group>"; };
|
D751DA399F1ADB6D34563B5D /* QRScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRScanViewController.m; sourceTree = "<group>"; };
|
||||||
|
D751DB0CB3009E12990F661E /* DemoLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoLibrary.h; sourceTree = "<group>"; };
|
||||||
D751DDEC114E037231257E64 /* DemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC.h; sourceTree = "<group>"; };
|
D751DDEC114E037231257E64 /* DemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC.h; sourceTree = "<group>"; };
|
||||||
D91241144B5A3356A3C60644 /* Pods-ExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
|
D91241144B5A3356A3C60644 /* Pods-ExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
E2334AEB22E9D2060098A085 /* Doric Playground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Doric Playground.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
E2334AEB22E9D2060098A085 /* Doric Playground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Doric Playground.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@ -163,6 +166,8 @@
|
|||||||
D751DDEC114E037231257E64 /* DemoVC.h */,
|
D751DDEC114E037231257E64 /* DemoVC.h */,
|
||||||
D751DA399F1ADB6D34563B5D /* QRScanViewController.m */,
|
D751DA399F1ADB6D34563B5D /* QRScanViewController.m */,
|
||||||
D751D18AD6496F4A9BE1AB45 /* QRScanViewController.h */,
|
D751D18AD6496F4A9BE1AB45 /* QRScanViewController.h */,
|
||||||
|
D751D2175D09F2C10691FB81 /* DemoLibrary.m */,
|
||||||
|
D751DB0CB3009E12990F661E /* DemoLibrary.h */,
|
||||||
);
|
);
|
||||||
path = Example;
|
path = Example;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -430,6 +435,7 @@
|
|||||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */,
|
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */,
|
||||||
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */,
|
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */,
|
||||||
D751D4FCC0A2322211DE3D55 /* QRScanViewController.m in Sources */,
|
D751D4FCC0A2322211DE3D55 /* QRScanViewController.m in Sources */,
|
||||||
|
D751DDB012BAF476A252CD93 /* DemoLibrary.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
10
Example/Example/DemoLibrary.h
Normal file
10
Example/Example/DemoLibrary.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Created by pengfei.zhou on 2019/12/11.
|
||||||
|
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Doric/Doric.h>
|
||||||
|
|
||||||
|
@interface DemoLibrary : DoricLibrary
|
||||||
|
@end
|
24
Example/Example/DemoLibrary.m
Normal file
24
Example/Example/DemoLibrary.m
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// Created by pengfei.zhou on 2019/12/11.
|
||||||
|
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "DemoLibrary.h"
|
||||||
|
|
||||||
|
@interface DoricDemoPlugin : DoricNativePlugin
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricDemoPlugin
|
||||||
|
- (void)test {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
ShowToast(@"Test called", CENTER);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DemoLibrary
|
||||||
|
- (void)load:(DoricRegistry *)registry {
|
||||||
|
[registry registerNativePlugin:[DoricDemoPlugin class] withName:@"demo"];
|
||||||
|
}
|
||||||
|
@end
|
@ -10,6 +10,7 @@
|
|||||||
#import <Doric/Doric.h>
|
#import <Doric/Doric.h>
|
||||||
#import "DemoVC.h"
|
#import "DemoVC.h"
|
||||||
#import "QRScanViewController.h"
|
#import "QRScanViewController.h"
|
||||||
|
#import "DemoLibrary.h"
|
||||||
|
|
||||||
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
|
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||||
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
||||||
@ -41,6 +42,7 @@ - (void)viewDidLoad {
|
|||||||
it.dataSource = self;
|
it.dataSource = self;
|
||||||
it.delegate = self;
|
it.delegate = self;
|
||||||
}]];
|
}]];
|
||||||
|
[DoricRegistry register:[DemoLibrary new]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||||
|
@ -26,3 +26,5 @@
|
|||||||
#import "DoricNavBarDelegate.h"
|
#import "DoricNavBarDelegate.h"
|
||||||
#import "DoricViewController.h"
|
#import "DoricViewController.h"
|
||||||
#import "DoricPromise.h"
|
#import "DoricPromise.h"
|
||||||
|
#import "DoricLibrary.h"
|
||||||
|
#import "DoricNativePlugin.h"
|
25
Pod/Classes/DoricLibrary.h
Normal file
25
Pod/Classes/DoricLibrary.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Created by pengfei.zhou on 2019/12/11.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "DoricRegistry.h"
|
||||||
|
|
||||||
|
@interface DoricLibrary : NSObject
|
||||||
|
- (void)load:(DoricRegistry *)registry;
|
||||||
|
@end
|
26
Pod/Classes/DoricLibrary.m
Normal file
26
Pod/Classes/DoricLibrary.m
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Created by pengfei.zhou on 2019/12/11.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "DoricLibrary.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation DoricLibrary
|
||||||
|
- (void)load:(DoricRegistry *)registry {
|
||||||
|
}
|
||||||
|
@end
|
@ -23,6 +23,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
@class DoricLibrary;
|
||||||
|
|
||||||
@interface DoricRegistry : NSObject
|
@interface DoricRegistry : NSObject
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (void)registerViewNode:(Class)nodeClass withName:(NSString *)name;
|
- (void)registerViewNode:(Class)nodeClass withName:(NSString *)name;
|
||||||
|
|
||||||
- (Class)acquireViewNode:(NSString *)name;
|
- (Class)acquireViewNode:(NSString *)name;
|
||||||
|
|
||||||
|
+ (void)register:(DoricLibrary *)library;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@ -43,6 +43,33 @@
|
|||||||
#import "DoricPopoverPlugin.h"
|
#import "DoricPopoverPlugin.h"
|
||||||
#import "DoricAnimatePlugin.h"
|
#import "DoricAnimatePlugin.h"
|
||||||
#import "DoricNestedSliderNode.h"
|
#import "DoricNestedSliderNode.h"
|
||||||
|
#import "DoricLibrary.h"
|
||||||
|
|
||||||
|
|
||||||
|
@interface DoricLibraries : NSObject
|
||||||
|
@property(nonatomic, strong) NSMutableSet <DoricLibrary *> *libraries;
|
||||||
|
|
||||||
|
+ (instancetype)instance;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricLibraries
|
||||||
|
- (instancetype)init {
|
||||||
|
if (self = [super init]) {
|
||||||
|
_libraries = [NSMutableSet new];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)instance {
|
||||||
|
static DoricLibraries *_instance;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
_instance = [[DoricLibraries alloc] init];
|
||||||
|
});
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface DoricRegistry ()
|
@interface DoricRegistry ()
|
||||||
|
|
||||||
@ -54,12 +81,19 @@ @interface DoricRegistry ()
|
|||||||
|
|
||||||
@implementation DoricRegistry
|
@implementation DoricRegistry
|
||||||
|
|
||||||
|
+ (void)register:(DoricLibrary *)library {
|
||||||
|
[DoricLibraries.instance.libraries addObject:library];
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
_bundles = [[NSMutableDictionary alloc] init];
|
_bundles = [[NSMutableDictionary alloc] init];
|
||||||
_plugins = [[NSMutableDictionary alloc] init];
|
_plugins = [[NSMutableDictionary alloc] init];
|
||||||
_nodes = [[NSMutableDictionary alloc] init];
|
_nodes = [[NSMutableDictionary alloc] init];
|
||||||
[self innerRegister];
|
[self innerRegister];
|
||||||
|
[DoricLibraries.instance.libraries enumerateObjectsUsingBlock:^(DoricLibrary *obj, BOOL *stop) {
|
||||||
|
[obj load:self];
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user