// // XplanFlutterBoostDelegate.m // PlanetStar // // Created by zu on 2021/3/18. // Copyright © 2021 WUJIE INTERACTIVE. All rights reserved. // #import #import "XCCurrentVCStackManager.h" #import "BaseNavigationController.h" #import "XplanFlutterBoostDelegate.h" #import "XCFlutterKeyConst.h" #import "XPWebViewController.h" #import "XPRoomViewController.h" #import "XPHtmlUrl.h" #import "XplanFBFlutterViewContainer.h" @implementation XplanFlutterBoostDelegate ///flutter页面打开一个原生的页面 - (void) pushNativeRoute:(NSString *) pageName arguments:(NSDictionary *) arguments { BOOL animated = arguments[@"animated"] ? [arguments[@"animated"] boolValue] : YES; BOOL present = arguments[@"present"] ? [arguments[@"present"] boolValue] : NO; BOOL isRoomVC = [pageName isEqualToString:YYFlutterPushNavitePageChatRoom]; UIViewController *controller; controller = [self getNaviteClassNameWithPageName:pageName arguments:arguments]; UIViewController * currentVC = [[FlutterBoost instance] currentViewController]; if (currentVC.navigationController) { self.navigationController = currentVC.navigationController; } if (controller) { if(present || isRoomVC){ [self.navigationController presentViewController:controller animated:animated completion:nil]; } else { [self.navigationController pushViewController:controller animated:animated]; } } else { NSLog(@"输入的类名不存在"); } } ///原生的页面打开一个flutter页面 - (void)pushFlutterRoute:(NSString *)pageName uniqueId:(NSString *)uniqueId arguments:(NSDictionary *)arguments completion:(void (^)(BOOL))completion { XplanFBFlutterViewContainer *vc = XplanFBFlutterViewContainer.new; [vc setName:pageName uniqueId:nil params:arguments]; UIViewController *rvc = [XCCurrentVCStackManager shareManager].getCurrentVC; self.navigationController = rvc.navigationController; BOOL animated = arguments[@"animated"] ? [arguments[@"animated"] boolValue] : YES; BOOL present = arguments[@"present"] ? [arguments[@"present"] boolValue] : NO; if(present){ ///包装一个导航控制器 可以在当前的flutter页面自由的导航 BaseNavigationController * flutterNav = [[BaseNavigationController alloc] initWithRootViewController:vc]; [self.navigationController presentViewController:flutterNav animated:animated completion:^{ }]; }else{ ///如果是push的话 就使用当前的导航控制器 [self.navigationController pushViewController:vc animated:animated]; } } ///flutter页面退出个页面 - (void)popRoute:(NSString *)uniqueId { ///如果当前是present的话 if (self.navigationController.presentingViewController) { [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } else { [self.navigationController popViewControllerAnimated:YES]; } } - (UIViewController *)getNaviteClassNameWithPageName:(NSString *)pageName arguments:(NSDictionary *)arguments { if ([pageName isEqualToString:YYFlutterPushNavitePageCharge]) { return [[NSClassFromString(@"XPMineRechargeViewController") alloc] init]; } else if ([pageName isEqualToString:YYFlutterPushNavitePageChatRoom]) { XPRoomViewController* roomVC = [[XPRoomViewController alloc]init]; roomVC.roomUid = arguments[@"chatRoomID"]; roomVC.roomUid = @"1004699"; BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; baseNav.modalPresentationStyle = UIModalPresentationFullScreen; return baseNav; } // if([pageName isEqualToString:YYFlutterPushNavitePageBindPaymentPwd]){ // return [[NSClassFromString(@"TTPayPwdViewController") alloc] init];; // } else if([pageName isEqualToString:YYFlutterPushNavitePageBindGameAccount]){ // TTWKWebViewViewController * webVC = [[TTWKWebViewViewController alloc] init]; // webVC.urlString = HtmlUrlKey(kGameBindAccountURL); // return webVC; // } else if([pageName isEqualToString:YYFlutterPushNavitePageInvite]){ XPWebViewController * webVC = [[XPWebViewController alloc] init]; webVC.url = URLWithType(kUserInviteFriendURL); return webVC; } else if([pageName isEqualToString:YYFlutterPushNavitePageWebview]) { XPWebViewController * webVC = [[XPWebViewController alloc] init]; webVC.url = arguments[@"webviewUrl"]; return webVC; } else { return nil; } } @end