react-native-navigation的迁移库

RCCNavigationController.m 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. #import "RCCNavigationController.h"
  2. #import "RCCViewController.h"
  3. #import "RCCManager.h"
  4. #import <React/RCTEventDispatcher.h>
  5. #import <React/RCTUIManager.h>
  6. #if __has_include(<React/RCTUIManagerUtils.h>)
  7. #import <React/RCTUIManagerUtils.h>
  8. #endif
  9. #import <React/RCTConvert.h>
  10. #import <React/RCTRootView.h>
  11. #import <objc/runtime.h>
  12. #import "RCCTitleViewHelper.h"
  13. #import "RCCCustomBarButtonItem.h"
  14. #import "UIViewController+Rotation.h"
  15. #import "RCTHelpers.h"
  16. #import "RCTConvert+UIBarButtonSystemItem.h"
  17. @implementation RCCNavigationController
  18. {
  19. BOOL _transitioning;
  20. NSMutableArray *_queuedViewControllers;
  21. }
  22. NSString const *CALLBACK_ASSOCIATED_KEY = @"RCCNavigationController.CALLBACK_ASSOCIATED_KEY";
  23. NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSOCIATED_ID";
  24. -(UIInterfaceOrientationMask)supportedInterfaceOrientations {
  25. return [self supportedControllerOrientations];
  26. }
  27. - (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge
  28. {
  29. _queuedViewControllers = [NSMutableArray new];
  30. NSString *component = props[@"component"];
  31. if (!component) return nil;
  32. NSDictionary *passProps = props[@"passProps"];
  33. NSDictionary *navigatorStyle = props[@"style"];
  34. RCCViewController *viewController = [[RCCViewController alloc] initWithComponent:component passProps:passProps navigatorStyle:navigatorStyle globalProps:globalProps bridge:bridge];
  35. if (!viewController) return nil;
  36. viewController.controllerId = passProps[@"screenInstanceID"];
  37. NSArray *leftButtons = props[@"leftButtons"];
  38. if (leftButtons)
  39. {
  40. [self setButtons:leftButtons viewController:viewController side:@"left" animated:NO];
  41. }
  42. NSArray *rightButtons = props[@"rightButtons"];
  43. if (rightButtons)
  44. {
  45. [self setButtons:rightButtons viewController:viewController side:@"right" animated:NO];
  46. }
  47. self = [super initWithRootViewController:viewController];
  48. if (!self) return nil;
  49. self.delegate = self;
  50. self.navigationBar.translucent = NO; // default
  51. [self processTitleView:viewController
  52. props:props
  53. style:navigatorStyle];
  54. [self setRotation:props];
  55. return self;
  56. }
  57. - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge
  58. {
  59. BOOL animated = actionParams[@"animated"] ? [actionParams[@"animated"] boolValue] : YES;
  60. // push
  61. if ([performAction isEqualToString:@"push"])
  62. {
  63. NSString *component = actionParams[@"component"];
  64. if (!component) return;
  65. NSMutableDictionary *passProps = [actionParams[@"passProps"] mutableCopy];
  66. passProps[GLOBAL_SCREEN_ACTION_COMMAND_TYPE] = COMMAND_TYPE_PUSH;
  67. passProps[GLOBAL_SCREEN_ACTION_TIMESTAMP] = actionParams[GLOBAL_SCREEN_ACTION_TIMESTAMP];
  68. NSDictionary *navigatorStyle = actionParams[@"style"];
  69. NSNumber *keepStyleAcrossPush = [[RCCManager sharedInstance] getAppStyle][@"keepStyleAcrossPush"];
  70. BOOL keepStyleAcrossPushBool = keepStyleAcrossPush ? [keepStyleAcrossPush boolValue] : YES;
  71. if (keepStyleAcrossPushBool) {
  72. if ([self.topViewController isKindOfClass:[RCCViewController class]])
  73. {
  74. RCCViewController *parent = (RCCViewController*)self.topViewController;
  75. NSMutableDictionary *mergedStyle = [NSMutableDictionary dictionaryWithDictionary:parent.navigatorStyle];
  76. // there are a few styles that we don't want to remember from our parent (they should be local)
  77. [mergedStyle removeObjectForKey:@"navBarHidden"];
  78. [mergedStyle removeObjectForKey:@"statusBarHidden"];
  79. [mergedStyle removeObjectForKey:@"navBarHideOnScroll"];
  80. [mergedStyle removeObjectForKey:@"drawUnderNavBar"];
  81. [mergedStyle removeObjectForKey:@"drawUnderTabBar"];
  82. [mergedStyle removeObjectForKey:@"statusBarBlur"];
  83. [mergedStyle removeObjectForKey:@"navBarBlur"];
  84. [mergedStyle removeObjectForKey:@"navBarTranslucent"];
  85. [mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
  86. [mergedStyle removeObjectForKey:@"autoAdjustScrollViewInsets"];
  87. [mergedStyle removeObjectForKey:@"statusBarTextColorSchemeSingleScreen"];
  88. [mergedStyle removeObjectForKey:@"disabledBackGesture"];
  89. [mergedStyle removeObjectForKey:@"disabledSimultaneousGesture"];
  90. [mergedStyle removeObjectForKey:@"navBarCustomView"];
  91. [mergedStyle removeObjectForKey:@"navBarComponentAlignment"];
  92. [mergedStyle addEntriesFromDictionary:navigatorStyle];
  93. navigatorStyle = mergedStyle;
  94. }
  95. }
  96. RCCViewController *viewController = [[RCCViewController alloc] initWithComponent:component passProps:passProps navigatorStyle:navigatorStyle globalProps:nil bridge:bridge];
  97. viewController.controllerId = passProps[@"screenInstanceID"];
  98. [self processTitleView:viewController
  99. props:actionParams
  100. style:navigatorStyle];
  101. NSString *backButtonTitle = actionParams[@"backButtonTitle"];
  102. if (!backButtonTitle) {
  103. NSNumber *hideBackButtonTitle = [[RCCManager sharedInstance] getAppStyle][@"hideBackButtonTitle"];
  104. BOOL hideBackButtonTitleBool = hideBackButtonTitle ? [hideBackButtonTitle boolValue] : NO;
  105. backButtonTitle = hideBackButtonTitleBool ? @"" : backButtonTitle;
  106. }
  107. if (backButtonTitle)
  108. {
  109. UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:backButtonTitle
  110. style:UIBarButtonItemStylePlain
  111. target:nil
  112. action:nil];
  113. self.topViewController.navigationItem.backBarButtonItem = backItem;
  114. }
  115. else
  116. {
  117. self.topViewController.navigationItem.backBarButtonItem = nil;
  118. }
  119. NSNumber *backButtonHidden = actionParams[@"backButtonHidden"];
  120. BOOL backButtonHiddenBool = backButtonHidden ? [backButtonHidden boolValue] : NO;
  121. if (backButtonHiddenBool)
  122. {
  123. viewController.navigationItem.hidesBackButton = YES;
  124. }
  125. NSArray *leftButtons = actionParams[@"leftButtons"];
  126. if (leftButtons)
  127. {
  128. [self setButtons:leftButtons viewController:viewController side:@"left" animated:NO];
  129. }
  130. NSArray *rightButtons = actionParams[@"rightButtons"];
  131. if (rightButtons)
  132. {
  133. [self setButtons:rightButtons viewController:viewController side:@"right" animated:NO];
  134. }
  135. NSArray *previewActions = actionParams[@"previewActions"];
  136. NSString *previewViewID = actionParams[@"previewViewID"];
  137. if (previewViewID) {
  138. if ([self.topViewController isKindOfClass:[RCCViewController class]])
  139. {
  140. RCCViewController *topViewController = ((RCCViewController*)self.topViewController);
  141. topViewController.previewController = nil;
  142. [topViewController.navigationController unregisterForPreviewingWithContext:topViewController.previewContext];
  143. viewController.previewActions = previewActions;
  144. viewController.previewCommit = actionParams[@"previewCommit"] ? [actionParams[@"previewCommit"] boolValue] : YES;
  145. NSNumber *previewHeight = actionParams[@"previewHeight"];
  146. if (previewHeight) {
  147. viewController.preferredContentSize = CGSizeMake(viewController.view.frame.size.width, [previewHeight floatValue]);
  148. }
  149. if (topViewController.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
  150. {
  151. dispatch_async(RCTGetUIManagerQueue(), ^{
  152. [bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
  153. UIView *view = viewRegistry[previewViewID];
  154. topViewController.previewView = view;
  155. topViewController.previewContext = [topViewController registerForPreviewingWithDelegate:(id)topViewController sourceView:view];
  156. }];
  157. });
  158. topViewController.previewController = viewController;
  159. }
  160. return;
  161. }
  162. }
  163. NSString *animationType = actionParams[@"animationType"];
  164. if ([animationType isEqualToString:@"fade"])
  165. {
  166. CATransition *transition = [CATransition animation];
  167. transition.duration = 0.25;
  168. transition.type = kCATransitionFade;
  169. [self.view.layer addAnimation:transition forKey:kCATransition];
  170. [self pushViewController:viewController animated:NO];
  171. }
  172. else
  173. {
  174. [self pushViewController:viewController animated:animated];
  175. }
  176. return;
  177. }
  178. // pop
  179. if ([performAction isEqualToString:@"pop"])
  180. {
  181. NSString *animationType = actionParams[@"animationType"];
  182. if ([animationType isEqualToString:@"fade"])
  183. {
  184. CATransition *transition = [CATransition animation];
  185. transition.duration = 0.25;
  186. transition.type = kCATransitionFade;
  187. [self.view.layer addAnimation:transition forKey:kCATransition];
  188. [self popViewControllerAnimated:NO];
  189. }
  190. else
  191. {
  192. [self popViewControllerAnimated:animated];
  193. }
  194. return;
  195. }
  196. // popToRoot
  197. if ([performAction isEqualToString:@"popToRoot"])
  198. {
  199. NSString *animationType = actionParams[@"animationType"];
  200. if ([animationType isEqualToString:@"fade"])
  201. {
  202. CATransition *transition = [CATransition animation];
  203. transition.duration = 0.25;
  204. transition.type = kCATransitionFade;
  205. [self.view.layer addAnimation:transition forKey:kCATransition];
  206. [self popToRootViewControllerAnimated:NO];
  207. }
  208. else
  209. {
  210. [self popToRootViewControllerAnimated:animated];
  211. }
  212. return;
  213. }
  214. // resetTo
  215. if ([performAction isEqualToString:@"resetTo"])
  216. {
  217. NSArray<UIViewController *> *viewControllers;
  218. NSString *component = actionParams[@"component"];
  219. NSArray<NSDictionary *> *componentConfigs = actionParams[@"components"];
  220. if (component) {
  221. NSMutableDictionary *passProps = [actionParams[@"passProps"] mutableCopy];
  222. passProps[@"commandType"] = @"resetTo";
  223. NSDictionary *style = actionParams[@"style"];
  224. NSArray *leftButtons = actionParams[@"leftButtons"];
  225. NSArray *rightButtons = actionParams[@"rightButtons"];
  226. UIViewController *viewController = [self viewControllerWithComponent:component
  227. props:[passProps copy]
  228. style:style
  229. leftButtons:leftButtons
  230. rightButtons:rightButtons
  231. bridge:bridge];
  232. viewControllers = @[viewController];
  233. } else if (componentConfigs) {
  234. NSMutableArray *mutableViewControllers = [NSMutableArray arrayWithCapacity:[componentConfigs count]];
  235. [componentConfigs enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull config, NSUInteger idx, BOOL * _Nonnull stop) {
  236. NSString *component = config[@"component"];
  237. NSMutableDictionary *props = [config[@"passProps"] mutableCopy];
  238. props[@"commandType"] = @"resetTo";
  239. NSDictionary *style = config[@"style"];
  240. NSArray *leftButtons = config[@"leftButtons"];
  241. NSArray *rightButtons = config[@"rightButtons"];
  242. UIViewController *viewController = [self viewControllerWithComponent:component
  243. props:[props copy]
  244. style:style
  245. leftButtons:leftButtons
  246. rightButtons:rightButtons
  247. bridge:bridge];
  248. [mutableViewControllers addObject:viewController];
  249. }];
  250. viewControllers = [mutableViewControllers copy];
  251. }
  252. if (!viewControllers) return;
  253. BOOL animated = actionParams[@"animated"] ? [actionParams[@"animated"] boolValue] : YES;
  254. NSString *animationType = actionParams[@"animationType"];
  255. if ([animationType isEqualToString:@"fade"])
  256. {
  257. CATransition *transition = [CATransition animation];
  258. transition.duration = 0.25;
  259. transition.type = kCATransitionFade;
  260. [self.view.layer addAnimation:transition forKey:kCATransition];
  261. [self setViewControllers:viewControllers animated:NO];
  262. }
  263. else
  264. {
  265. [self setViewControllers:viewControllers animated:animated];
  266. }
  267. return;
  268. }
  269. // setButtons
  270. if ([performAction isEqualToString:@"setButtons"])
  271. {
  272. NSArray *buttons = actionParams[@"buttons"];
  273. BOOL animated = actionParams[@"animated"] ? [actionParams[@"animated"] boolValue] : YES;
  274. NSString *side = actionParams[@"side"] ? actionParams[@"side"] : @"left";
  275. [self setButtons:buttons viewController:self.topViewController side:side animated:animated];
  276. return;
  277. }
  278. // setTitle
  279. if ([performAction isEqualToString:@"setTitle"] || [performAction isEqualToString:@"setTitleImage"])
  280. {
  281. NSDictionary *navigatorStyle = actionParams[@"style"];
  282. [self processTitleView:self.topViewController
  283. props:actionParams
  284. style:navigatorStyle];
  285. return;
  286. }
  287. // toggleNavBar
  288. if ([performAction isEqualToString:@"setHidden"]) {
  289. NSNumber *animated = actionParams[@"animated"];
  290. BOOL animatedBool = animated ? [animated boolValue] : YES;
  291. NSNumber *setHidden = actionParams[@"hidden"];
  292. BOOL isHiddenBool = setHidden ? [setHidden boolValue] : NO;
  293. RCCViewController *topViewController = ((RCCViewController*)self.topViewController);
  294. topViewController.navigatorStyle[@"navBarHidden"] = setHidden;
  295. [topViewController setNavBarVisibilityChange:animatedBool];
  296. }
  297. // setStyle
  298. if ([performAction isEqualToString:@"setStyle"])
  299. {
  300. NSDictionary *navigatorStyle = actionParams;
  301. // merge the navigatorStyle of our parent
  302. if ([self.topViewController isKindOfClass:[RCCViewController class]])
  303. {
  304. RCCViewController *parent = (RCCViewController*)self.topViewController;
  305. NSMutableDictionary *mergedStyle = [NSMutableDictionary dictionaryWithDictionary:parent.navigatorStyle];
  306. // there are a few styles that we don't want to remember from our parent (they should be local)
  307. [mergedStyle setValuesForKeysWithDictionary:navigatorStyle];
  308. navigatorStyle = mergedStyle;
  309. parent.navigatorStyle = navigatorStyle;
  310. [parent setStyleOnInit];
  311. [parent updateStyle];
  312. }
  313. }
  314. }
  315. - (UIViewController *)viewControllerWithComponent:(NSString *)component
  316. props:(NSDictionary *)props
  317. style:(NSDictionary *)style
  318. leftButtons:(NSArray<NSDictionary *> *)leftButtons
  319. rightButtons:(NSArray<NSDictionary *> *)rightButtons
  320. bridge:(RCTBridge *)bridge
  321. {
  322. RCCViewController *viewController = [[RCCViewController alloc] initWithComponent:component
  323. passProps:props
  324. navigatorStyle:style
  325. globalProps:nil
  326. bridge:bridge];
  327. viewController.controllerId = props[@"screenInstanceID"];
  328. viewController.navigationItem.hidesBackButton = YES;
  329. [self processTitleView:viewController
  330. props:props
  331. style:style];
  332. if (leftButtons)
  333. {
  334. [self setButtons:leftButtons viewController:viewController side:@"left" animated:NO];
  335. }
  336. if (rightButtons)
  337. {
  338. [self setButtons:rightButtons viewController:viewController side:@"right" animated:NO];
  339. }
  340. return viewController;
  341. }
  342. -(void)onButtonPress:(UIBarButtonItem*)barButtonItem
  343. {
  344. NSString *callbackId = objc_getAssociatedObject(barButtonItem, &CALLBACK_ASSOCIATED_KEY);
  345. if (!callbackId) return;
  346. NSString *buttonId = objc_getAssociatedObject(barButtonItem, &CALLBACK_ASSOCIATED_ID);
  347. [[[RCCManager sharedInstance] getBridge].eventDispatcher sendAppEventWithName:callbackId body:@
  348. {
  349. @"type": @"NavBarButtonPress",
  350. @"id": buttonId ? buttonId : [NSNull null]
  351. }];
  352. }
  353. -(void)setButtons:(NSArray*)buttons viewController:(UIViewController*)viewController side:(NSString*)side animated:(BOOL)animated
  354. {
  355. NSMutableArray *barButtonItems = [NSMutableArray new];
  356. for (NSDictionary *button in buttons)
  357. {
  358. NSString *title = button[@"title"];
  359. UIImage *iconImage = nil;
  360. id icon = button[@"icon"];
  361. if (icon) iconImage = [RCTConvert UIImage:icon];
  362. NSString *__nullable component = button[@"component"];
  363. NSString *__nullable systemItemName = button[@"systemItem"];
  364. UIBarButtonSystemItem systemItem = [RCTConvert UIBarButtonSystemItem:systemItemName];
  365. UIBarButtonItem *barButtonItem;
  366. if (iconImage)
  367. {
  368. barButtonItem = [[UIBarButtonItem alloc] initWithImage:iconImage style:UIBarButtonItemStylePlain target:self action:@selector(onButtonPress:)];
  369. }
  370. else if (title)
  371. {
  372. barButtonItem = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(onButtonPress:)];
  373. NSMutableDictionary *buttonTextAttributes = [RCTHelpers textAttributesFromDictionary:button withPrefix:@"button"];
  374. if (buttonTextAttributes.allKeys.count > 0) {
  375. [barButtonItem setTitleTextAttributes:buttonTextAttributes forState:UIControlStateNormal];
  376. [barButtonItem setTitleTextAttributes:buttonTextAttributes forState:UIControlStateHighlighted];
  377. }
  378. }
  379. else if (component) {
  380. RCTBridge *bridge = [[RCCManager sharedInstance] getBridge];
  381. barButtonItem = [[RCCCustomBarButtonItem alloc] initWithComponentName:component passProps:button[@"passProps"] bridge:bridge];
  382. }
  383. else if (systemItemName) {
  384. barButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:systemItem target:self action:@selector(onButtonPress:)];
  385. }
  386. else continue;
  387. objc_setAssociatedObject(barButtonItem, &CALLBACK_ASSOCIATED_KEY, button[@"onPress"], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  388. [barButtonItems addObject:barButtonItem];
  389. NSString *buttonId = button[@"id"];
  390. if (buttonId)
  391. {
  392. objc_setAssociatedObject(barButtonItem, &CALLBACK_ASSOCIATED_ID, buttonId, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  393. }
  394. NSNumber *disabled = button[@"disabled"];
  395. BOOL disabledBool = disabled ? [disabled boolValue] : NO;
  396. if (disabledBool) {
  397. [barButtonItem setEnabled:NO];
  398. }
  399. NSNumber *disableIconTintString = button[@"disableIconTint"];
  400. BOOL disableIconTint = disableIconTintString ? [disableIconTintString boolValue] : NO;
  401. if (disableIconTint) {
  402. [barButtonItem setImage:[barButtonItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  403. }
  404. if ([viewController isKindOfClass:[RCCViewController class]]) {
  405. RCCViewController *rccViewController = ((RCCViewController*)viewController);
  406. NSDictionary *navigatorStyle = rccViewController.navigatorStyle;
  407. id disabledButtonColor = navigatorStyle[@"disabledButtonColor"];
  408. if (disabledButtonColor) {
  409. UIColor *color = [RCTConvert UIColor:disabledButtonColor];
  410. [barButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName : color} forState:UIControlStateDisabled];
  411. }
  412. }
  413. NSString *testID = button[@"testID"];
  414. if (testID)
  415. {
  416. barButtonItem.accessibilityIdentifier = testID;
  417. }
  418. }
  419. if ([side isEqualToString:@"left"])
  420. {
  421. [viewController.navigationItem setLeftBarButtonItems:barButtonItems animated:animated];
  422. }
  423. if ([side isEqualToString:@"right"])
  424. {
  425. [viewController.navigationItem setRightBarButtonItems:barButtonItems animated:animated];
  426. }
  427. }
  428. -(void)processTitleView:(UIViewController*)viewController
  429. props:(NSDictionary*)props
  430. style:(NSDictionary*)style
  431. {
  432. BOOL isSetSubtitleBool = props[@"isSetSubtitle"] ? [props[@"isSetSubtitle"] boolValue] : NO;
  433. RCCTitleViewHelper *titleViewHelper = [[RCCTitleViewHelper alloc] init:viewController
  434. navigationController:self
  435. title:props[@"title"]
  436. subtitle:props[@"subtitle"]
  437. titleImageData:props[@"titleImage"]
  438. isSetSubtitle:isSetSubtitleBool];
  439. [titleViewHelper setup:style];
  440. }
  441. - (UIStatusBarStyle)preferredStatusBarStyle {
  442. return [self.topViewController preferredStatusBarStyle];
  443. }
  444. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
  445. {
  446. if(_transitioning)
  447. {
  448. NSDictionary *pushDetails =@{ @"viewController": viewController, @"animated": @(animated) };
  449. [_queuedViewControllers addObject:pushDetails];
  450. return;
  451. }
  452. _transitioning = YES;
  453. [super pushViewController:viewController animated:animated];
  454. }
  455. #pragma mark - UINavigationControllerDelegate
  456. -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  457. [viewController setNeedsStatusBarAppearanceUpdate];
  458. }
  459. - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
  460. {
  461. dispatch_async(dispatch_get_main_queue(), ^{
  462. _transitioning = NO;
  463. if ([_queuedViewControllers count] > 0) {
  464. NSDictionary *toPushDetails = [_queuedViewControllers firstObject];
  465. [_queuedViewControllers removeObjectAtIndex:0];
  466. [self pushViewController:toPushDetails[@"viewController"] animated:[toPushDetails[@"animated"] boolValue]];
  467. }
  468. });
  469. }
  470. @end