diff --git a/iOS/Pod/Classes/DoricViewController.m b/iOS/Pod/Classes/DoricViewController.m index 49d1068a..5627c989 100644 --- a/iOS/Pod/Classes/DoricViewController.m +++ b/iOS/Pod/Classes/DoricViewController.m @@ -27,45 +27,33 @@ @implementation DoricViewController - (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias { if (self = [super init]) { - [self push:scheme alias:alias]; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" - style:UIBarButtonItemStylePlain - target:self - action:@selector(pop)]; + DoricAsyncResult *result = [DoricJSLoaderManager.instance request:scheme]; + result.resultCallback = ^(NSString *result) { + dispatch_async(dispatch_get_main_queue(), ^{ + DoricPanel *panel = [DoricPanel new]; + [panel.view also:^(UIView *it) { + it.backgroundColor = [UIColor whiteColor]; + it.width = self.view.width; + it.height = self.view.height - 88; + it.top = 88; + }]; + [self.view addSubview:panel.view]; + [self addChildViewController:panel]; + [panel config:result alias:alias]; + + }); + }; } return self; } -- (void)push:(NSString *)scheme alias:(NSString *)alias { - DoricAsyncResult *result = [DoricJSLoaderManager.instance request:scheme]; - result.resultCallback = ^(NSString *result) { - dispatch_async(dispatch_get_main_queue(), ^{ - DoricPanel *panel = [DoricPanel new]; - [panel.view also:^(UIView *it) { - it.backgroundColor = [UIColor whiteColor]; - it.width = self.view.width; - it.height = self.view.height - 88; - it.top = 88; - }]; - [self.view addSubview:panel.view]; - [self addChildViewController:panel]; - [panel config:result alias:alias]; - }); - }; +- (void)push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated { + DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias]; + [self.navigationController pushViewController:viewController animated:animated]; } -- (void)pop { - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.childViewControllers.count > 1) { - [self.childViewControllers.lastObject also:^(UIViewController *it) { - [it removeFromParentViewController]; - [it.view removeFromSuperview]; - }]; - } else { - [self.navigationController popViewControllerAnimated:NO]; - } - - }); +- (void)pop:(BOOL)animated { + [self.navigationController popViewControllerAnimated:animated]; } @end diff --git a/iOS/Pod/Classes/Navigator/DoricNavigatorProtocol.h b/iOS/Pod/Classes/Navigator/DoricNavigatorProtocol.h index dd250290..ba87e713 100644 --- a/iOS/Pod/Classes/Navigator/DoricNavigatorProtocol.h +++ b/iOS/Pod/Classes/Navigator/DoricNavigatorProtocol.h @@ -5,7 +5,7 @@ #import @protocol DoricNavigatorProtocol -- (void)push:(NSString *)scheme alias:(NSString *)alias; +- (void)push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated; -- (void)pop; +- (void)pop:(BOOL)animated; @end \ No newline at end of file diff --git a/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m index d711b304..8cabc936 100644 --- a/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m +++ b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m @@ -22,10 +22,22 @@ @implementation DoricNavigatorPlugin - (void)push:(NSDictionary *)params { - [self.doricContext.navigator push:params[@"scheme"] alias:params[@"alias"]]; + dispatch_async(dispatch_get_main_queue(), ^{ + BOOL animated = YES; + if (params[@"animated"]) { + animated = [params[@"animated"] boolValue]; + } + [self.doricContext.navigator push:params[@"scheme"] alias:params[@"alias"] animated:animated]; + }); } -- (void)pop { - [self.doricContext.navigator pop]; +- (void)pop:(NSDictionary *)params { + dispatch_async(dispatch_get_main_queue(), ^{ + BOOL animated = YES; + if (params[@"animated"]) { + animated = [params[@"animated"] boolValue]; + } + [self.doricContext.navigator pop:animated]; + }); } @end \ No newline at end of file