react-native-navigation的迁移库

RNNNavigationOptions.m 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 applyOtherOptions:self on:viewController];
  21. }
  22. - (void)applyOnNavigationController:(UINavigationController *)navigationController {
  23. [self.topBar applyOnNavigationController:navigationController];
  24. [self.statusBar applyOn:navigationController];
  25. [self.layout applyOn:navigationController];
  26. [self.bottomTab applyOn:navigationController];
  27. [self applyOtherOptions:self onNavigationController:navigationController];
  28. }
  29. - (void)applyOnTabBarController:(UITabBarController *)tabBarController {
  30. [self.bottomTabs applyOnTabBarController:tabBarController];
  31. }
  32. - (void)applyOtherOptions:(RNNNavigationOptions *)options onNavigationController:(UINavigationController*)navigationController {
  33. if (options.popGesture) {
  34. navigationController.interactivePopGestureRecognizer.enabled = [options.popGesture boolValue];
  35. }
  36. if (options.rootBackgroundImage) {
  37. UIImageView* backgroundImageView = (navigationController.view.subviews.count > 0) ? navigationController.view.subviews[0] : nil;
  38. if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
  39. backgroundImageView = [[UIImageView alloc] initWithFrame:navigationController.view.bounds];
  40. [navigationController.view insertSubview:backgroundImageView atIndex:0];
  41. }
  42. backgroundImageView.layer.masksToBounds = YES;
  43. backgroundImageView.image = [options.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)options.rootBackgroundImage : [RCTConvert UIImage:options.rootBackgroundImage];
  44. [backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
  45. }
  46. }
  47. - (void)applyOtherOptions:(RNNNavigationOptions *)options on:(UIViewController*)viewController {
  48. if (options.backgroundImage) {
  49. UIImageView* backgroundImageView = (viewController.view.subviews.count > 0) ? viewController.view.subviews[0] : nil;
  50. if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
  51. backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
  52. [viewController.view insertSubview:backgroundImageView atIndex:0];
  53. }
  54. backgroundImageView.layer.masksToBounds = YES;
  55. backgroundImageView.image = [options.backgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)options.backgroundImage : [RCTConvert UIImage:options.backgroundImage];
  56. [backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
  57. }
  58. if (options.modalPresentationStyle) {
  59. viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:options.modalPresentationStyle];
  60. [viewController.view setBackgroundColor:[UIColor clearColor]];
  61. }
  62. if (options.modalTransitionStyle) {
  63. viewController.modalTransitionStyle = [RCTConvert UIModalTransitionStyle:options.modalTransitionStyle];
  64. }
  65. }
  66. @end