react-native-navigation的迁移库

RCCNavigationController.m 22KB

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