feat:Navigator add extra
This commit is contained in:
parent
276c8c9ef9
commit
bf7a22a4d7
@ -33,7 +33,7 @@ - (void)viewDidLoad {
|
|||||||
[self.view addSubview:it];
|
[self.view addSubview:it];
|
||||||
}];
|
}];
|
||||||
[self addChildViewController:panel];
|
[self addChildViewController:panel];
|
||||||
[panel config:jsContent alias:self.filePath];
|
[panel config:jsContent alias:self.filePath extra:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -77,7 +77,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
|
|||||||
if ([file containsString:@"NavigatorDemo"]) {
|
if ([file containsString:@"NavigatorDemo"]) {
|
||||||
DoricViewController *doricViewController = [[DoricViewController alloc]
|
DoricViewController *doricViewController = [[DoricViewController alloc]
|
||||||
initWithScheme:[NSString stringWithFormat:@"assets://demo/%@", file]
|
initWithScheme:[NSString stringWithFormat:@"assets://demo/%@", file]
|
||||||
alias:self.demoFilePaths[(NSUInteger) indexPath.row]];
|
alias:self.demoFilePaths[(NSUInteger) indexPath.row]
|
||||||
|
extra:nil
|
||||||
|
];
|
||||||
[self.navigationController pushViewController:doricViewController animated:NO];
|
[self.navigationController pushViewController:doricViewController animated:NO];
|
||||||
} else {
|
} else {
|
||||||
DemoVC *demoVC = [[DemoVC alloc] initWithPath:file];
|
DemoVC *demoVC = [[DemoVC alloc] initWithPath:file];
|
||||||
|
@ -41,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property(nonatomic, strong) NSMutableDictionary *initialParams;
|
@property(nonatomic, strong) NSMutableDictionary *initialParams;
|
||||||
@property(nonatomic, strong) DoricRootNode *rootNode;
|
@property(nonatomic, strong) DoricRootNode *rootNode;
|
||||||
@property(nonatomic, strong) NSMutableDictionary <NSString *, DoricViewNode *> *headNodes;
|
@property(nonatomic, strong) NSMutableDictionary <NSString *, DoricViewNode *> *headNodes;
|
||||||
|
@property(nonatomic, copy) NSString *extra;
|
||||||
|
|
||||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source;
|
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra;
|
||||||
|
|
||||||
- (DoricAsyncResult *)callEntity:(NSString *)method, ...;
|
- (DoricAsyncResult *)callEntity:(NSString *)method, ...;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
@implementation DoricContext
|
@implementation DoricContext
|
||||||
|
|
||||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source {
|
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
_driver = [DoricDriver instance];
|
_driver = [DoricDriver instance];
|
||||||
_pluginInstanceMap = [NSMutableDictionary new];
|
_pluginInstanceMap = [NSMutableDictionary new];
|
||||||
@ -39,6 +39,7 @@ - (instancetype)initWithScript:(NSString *)script source:(NSString *)source {
|
|||||||
_script = script;
|
_script = script;
|
||||||
_source = source;
|
_source = source;
|
||||||
_initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy];
|
_initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy];
|
||||||
|
_extra = extra;
|
||||||
[self callEntity:DORIC_ENTITY_CREATE, nil];
|
[self callEntity:DORIC_ENTITY_CREATE, nil];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -78,7 +79,7 @@ - (void)initContextWithWidth:(CGFloat)width height:(CGFloat)height {
|
|||||||
it[@"width"] = @(width);
|
it[@"width"] = @(width);
|
||||||
it[@"height"] = @(height);
|
it[@"height"] = @(height);
|
||||||
}];
|
}];
|
||||||
[self callEntity:DORIC_ENTITY_INIT, self.initialParams, nil];
|
[self callEntity:DORIC_ENTITY_INIT, self.initialParams, self.extra, nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reload:(NSString *)script {
|
- (void)reload:(NSString *)script {
|
||||||
|
@ -25,5 +25,5 @@
|
|||||||
@interface DoricPanel : UIViewController
|
@interface DoricPanel : UIViewController
|
||||||
@property(nonatomic, strong) DoricContext *doricContext;
|
@property(nonatomic, strong) DoricContext *doricContext;
|
||||||
|
|
||||||
- (void)config:(NSString *)script alias:(NSString *)alias;
|
- (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extra;
|
||||||
@end
|
@end
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
@implementation DoricPanel
|
@implementation DoricPanel
|
||||||
|
|
||||||
- (void)config:(NSString *)script alias:(NSString *)alias {
|
- (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extra {
|
||||||
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias] also:^(DoricContext *it) {
|
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias extra:extra] also:^(DoricContext *it) {
|
||||||
[it.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
[it.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
||||||
[self.view addSubview:it];
|
[self.view addSubview:it];
|
||||||
}]];
|
}]];
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed onO an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
@ -22,5 +22,5 @@
|
|||||||
#import "DoricNavBarDelegate.h"
|
#import "DoricNavBarDelegate.h"
|
||||||
|
|
||||||
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate>
|
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate>
|
||||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias;
|
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra;
|
||||||
@end
|
@end
|
@ -32,7 +32,7 @@ @interface DoricViewController ()
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricViewController
|
@implementation DoricViewController
|
||||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||||
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:scheme];
|
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:scheme];
|
||||||
@ -46,7 +46,7 @@ - (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
|||||||
}];
|
}];
|
||||||
[self.view addSubview:panel.view];
|
[self.view addSubview:panel.view];
|
||||||
[self addChildViewController:panel];
|
[self addChildViewController:panel];
|
||||||
[panel config:result alias:alias];
|
[panel config:result alias:alias extra:extra];
|
||||||
panel.doricContext.navigator = self;
|
panel.doricContext.navigator = self;
|
||||||
panel.doricContext.navBar = self;
|
panel.doricContext.navBar = self;
|
||||||
self.doricPanel = panel;
|
self.doricPanel = panel;
|
||||||
@ -78,8 +78,8 @@ - (void)viewWillLayoutSubviews {
|
|||||||
self.doricPanel.view.height = self.view.height;
|
self.doricPanel.view.height = self.view.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated {
|
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra {
|
||||||
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias];
|
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias extra:extra];
|
||||||
[self.navigationController pushViewController:viewController animated:animated];
|
[self.navigationController pushViewController:viewController animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@protocol DoricNavigatorDelegate <NSObject>
|
@protocol DoricNavigatorDelegate <NSObject>
|
||||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated;
|
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra;
|
||||||
|
|
||||||
- (void)doric_navigator_pop:(BOOL)animated;
|
- (void)doric_navigator_pop:(BOOL)animated;
|
||||||
@end
|
@end
|
||||||
|
@ -24,10 +24,19 @@ @implementation DoricNavigatorPlugin
|
|||||||
- (void)push:(NSDictionary *)params {
|
- (void)push:(NSDictionary *)params {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
BOOL animated = YES;
|
BOOL animated = YES;
|
||||||
if (params[@"animated"]) {
|
NSString *scheme = params[@"scheme"];
|
||||||
animated = [params[@"animated"] boolValue];
|
NSString *alias = scheme;
|
||||||
|
NSDictionary *config = params[@"config"];
|
||||||
|
if (config) {
|
||||||
|
if (config[@"animated"]) {
|
||||||
|
animated = [config[@"animated"] boolValue];
|
||||||
}
|
}
|
||||||
[self.doricContext.navigator doric_navigator_push:params[@"scheme"] alias:params[@"alias"] animated:animated];
|
|
||||||
|
if (config[@"alias"]) {
|
||||||
|
alias = config[@"alias"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[self.doricContext.navigator doric_navigator_push:scheme alias:alias animated:animated extra:config[@"extra"]];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user