react-native-navigation的迁移库

RNNNavigationOptions.m 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #import "RNNNavigationOptions.h"
  2. #import <React/RCTConvert.h>
  3. #import "RNNNavigationController.h"
  4. #import "RNNTabBarController.h"
  5. #import "RNNTopBarOptions.h"
  6. #import "RNNSideMenuController.h"
  7. #import "RNNRootViewController.h"
  8. #import "RNNSplitViewController.h"
  9. #import "RNNNavigationButtons.h"
  10. @implementation RNNNavigationOptions
  11. - (void)applyOn:(UIViewController *)viewController {
  12. [self.topBar applyOn:viewController];
  13. [self.bottomTabs applyOn:viewController];
  14. [self.topTab applyOn:viewController];
  15. [self.bottomTab applyOn:viewController];
  16. [self.sideMenu applyOn:viewController];
  17. [self.overlay applyOn:viewController];
  18. [self.statusBar applyOn:viewController];
  19. [self.layout applyOn:viewController];
  20. [self applyOtherOptionsOn:viewController];
  21. [self applyOnNavigationController:viewController.navigationController];
  22. [self applyOnTabBarController:viewController.tabBarController];
  23. }
  24. - (void)applyOnNavigationController:(UINavigationController *)navigationController {
  25. [self.topBar applyOnNavigationController:navigationController];
  26. [self.statusBar applyOn:navigationController];
  27. [self.layout applyOn:navigationController];
  28. [self.bottomTab applyOn:navigationController];
  29. [self applyOtherOptionsOnNavigationController:navigationController];
  30. }
  31. - (void)applyOnTabBarController:(UITabBarController *)tabBarController {
  32. [self.bottomTabs applyOnTabBarController:tabBarController];
  33. }
  34. - (void)applyOtherOptionsOnNavigationController:(UINavigationController*)navigationController {
  35. if (self.popGesture) {
  36. navigationController.interactivePopGestureRecognizer.enabled = [self.popGesture boolValue];
  37. }
  38. if (self.rootBackgroundImage) {
  39. UIImageView* backgroundImageView = (navigationController.view.subviews.count > 0) ? navigationController.view.subviews[0] : nil;
  40. if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
  41. backgroundImageView = [[UIImageView alloc] initWithFrame:navigationController.view.bounds];
  42. [navigationController.view insertSubview:backgroundImageView atIndex:0];
  43. }
  44. backgroundImageView.layer.masksToBounds = YES;
  45. backgroundImageView.image = [self.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.rootBackgroundImage : [RCTConvert UIImage:self.rootBackgroundImage];
  46. [backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
  47. }
  48. }
  49. - (void)applyOtherOptionsOn:(UIViewController*)viewController {
  50. if (self.backgroundImage) {
  51. UIImageView* backgroundImageView = (viewController.view.subviews.count > 0) ? viewController.view.subviews[0] : nil;
  52. if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
  53. backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
  54. [viewController.view insertSubview:backgroundImageView atIndex:0];
  55. }
  56. backgroundImageView.layer.masksToBounds = YES;
  57. backgroundImageView.image = [self.backgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.backgroundImage : [RCTConvert UIImage:self.backgroundImage];
  58. [backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
  59. }
  60. if (self.modalPresentationStyle) {
  61. viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:self.modalPresentationStyle];
  62. [viewController.view setBackgroundColor:[UIColor clearColor]];
  63. }
  64. if (self.modalTransitionStyle) {
  65. viewController.modalTransitionStyle = [RCTConvert UIModalTransitionStyle:self.modalTransitionStyle];
  66. }
  67. }
  68. @end