react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #import "RNNNavigationControllerPresenter.h"
  2. #import "UINavigationController+RNNOptions.h"
  3. #import "RNNNavigationController.h"
  4. #import <React/RCTConvert.h>
  5. @implementation RNNNavigationControllerPresenter
  6. - (void)applyOptions:(RNNNavigationOptions *)options {
  7. [super applyOptions:options];
  8. RNNNavigationController* navigationController = self.bindedViewController;
  9. [navigationController rnn_setInteractivePopGestureEnabled:[options.popGesture getWithDefaultValue:YES]];
  10. [navigationController rnn_setRootBackgroundImage:[options.rootBackgroundImage getWithDefaultValue:nil]];
  11. [navigationController rnn_setNavigationBarTestID:[options.topBar.testID getWithDefaultValue:nil]];
  12. [navigationController rnn_setNavigationBarVisible:[options.topBar.visible getWithDefaultValue:YES] animated:[options.topBar.animate getWithDefaultValue:YES]];
  13. [navigationController rnn_hideBarsOnScroll:[options.topBar.hideOnScroll getWithDefaultValue:NO]];
  14. [navigationController rnn_setNavigationBarNoBorder:[options.topBar.noBorder getWithDefaultValue:NO]];
  15. [navigationController rnn_setBarStyle:[RCTConvert UIBarStyle:[options.topBar.barStyle getWithDefaultValue:@"default"]]];
  16. [navigationController rnn_setNavigationBarTranslucent:[options.topBar.background.translucent getWithDefaultValue:NO]];
  17. [navigationController rnn_setNavigationBarClipsToBounds:[options.topBar.background.clipToBounds getWithDefaultValue:NO]];
  18. [navigationController rnn_setNavigationBarBlur:[options.topBar.background.blur getWithDefaultValue:NO]];
  19. [navigationController setTopBarBackgroundColor:[options.topBar.background.color getWithDefaultValue:nil]];
  20. [navigationController rnn_setNavigationBarLargeTitleVisible:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
  21. [navigationController rnn_setNavigationBarLargeTitleFontFamily:[options.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[options.topBar.largeTitle.color getWithDefaultValue:nil]];
  22. [navigationController rnn_setNavigationBarFontFamily:[options.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.title.fontSize getWithDefaultValue:nil] color:[options.topBar.title.color getWithDefaultValue:nil]];
  23. [navigationController rnn_setBackButtonColor:[options.topBar.backButton.color getWithDefaultValue:nil]];
  24. [navigationController rnn_setBackButtonIcon:[options.topBar.backButton.icon getWithDefaultValue:nil] withColor:[options.topBar.backButton.color getWithDefaultValue:nil] title:[options.topBar.backButton.showTitle getWithDefaultValue:YES] ? [options.topBar.backButton.title getWithDefaultValue:nil] : @""];
  25. }
  26. - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
  27. [super applyOptionsOnWillMoveToParentViewController:options];
  28. RNNNavigationController* navigationController = self.bindedViewController;
  29. [navigationController rnn_setBackButtonIcon:[options.topBar.backButton.icon getWithDefaultValue:nil] withColor:[options.topBar.backButton.color getWithDefaultValue:nil] title:[options.topBar.backButton.showTitle getWithDefaultValue:YES] ? [options.topBar.backButton.title getWithDefaultValue:nil] : @""];
  30. }
  31. - (void)applyOptionsBeforePopping:(RNNNavigationOptions *)options {
  32. RNNNavigationController* navigationController = self.bindedViewController;
  33. [navigationController setTopBarBackgroundColor:[options.topBar.background.color getWithDefaultValue:nil]];
  34. [navigationController rnn_setNavigationBarFontFamily:[options.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.title.fontSize getWithDefaultValue:@(17)] color:[options.topBar.title.color getWithDefaultValue:[UIColor blackColor]]];
  35. }
  36. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  37. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  38. RNNNavigationController* navigationController = self.bindedViewController;
  39. if (newOptions.popGesture.hasValue) {
  40. [navigationController rnn_setInteractivePopGestureEnabled:newOptions.popGesture.get];
  41. }
  42. if (newOptions.rootBackgroundImage.hasValue) {
  43. [navigationController rnn_setRootBackgroundImage:newOptions.rootBackgroundImage.get];
  44. }
  45. if (newOptions.topBar.testID.hasValue) {
  46. [navigationController rnn_setNavigationBarTestID:newOptions.topBar.testID.get];
  47. }
  48. if (newOptions.topBar.visible.hasValue) {
  49. [navigationController rnn_setNavigationBarVisible:newOptions.topBar.visible.get animated:[newOptions.topBar.animate getWithDefaultValue:YES]];
  50. }
  51. if (newOptions.topBar.hideOnScroll.hasValue) {
  52. [navigationController rnn_hideBarsOnScroll:[newOptions.topBar.hideOnScroll get]];
  53. }
  54. if (newOptions.topBar.noBorder.hasValue) {
  55. [navigationController rnn_setNavigationBarNoBorder:[newOptions.topBar.noBorder get]];
  56. }
  57. if (newOptions.topBar.barStyle.hasValue) {
  58. [navigationController rnn_setBarStyle:[RCTConvert UIBarStyle:newOptions.topBar.barStyle.get]];
  59. }
  60. if (newOptions.topBar.background.translucent.hasValue) {
  61. [navigationController rnn_setNavigationBarTranslucent:[newOptions.topBar.background.translucent get]];
  62. }
  63. if (newOptions.topBar.background.clipToBounds.hasValue) {
  64. [navigationController rnn_setNavigationBarClipsToBounds:[newOptions.topBar.background.clipToBounds get]];
  65. }
  66. if (newOptions.topBar.background.blur.hasValue) {
  67. [navigationController rnn_setNavigationBarBlur:[newOptions.topBar.background.blur get]];
  68. }
  69. if (newOptions.topBar.background.color.hasValue) {
  70. [navigationController setTopBarBackgroundColor:newOptions.topBar.background.color.get];
  71. }
  72. if (newOptions.topBar.largeTitle.visible.hasValue) {
  73. [navigationController rnn_setNavigationBarLargeTitleVisible:newOptions.topBar.largeTitle.visible.get];
  74. }
  75. if (newOptions.topBar.backButton.icon.hasValue) {
  76. [navigationController rnn_setBackButtonIcon:[newOptions.topBar.backButton.icon getWithDefaultValue:nil] withColor:[newOptions.topBar.backButton.color getWithDefaultValue:nil] title:[newOptions.topBar.backButton.showTitle getWithDefaultValue:YES] ? [newOptions.topBar.backButton.title getWithDefaultValue:nil] : @""];
  77. }
  78. if (newOptions.topBar.backButton.color.hasValue) {
  79. [navigationController rnn_setBackButtonColor:newOptions.topBar.backButton.color.get];
  80. }
  81. [navigationController rnn_setNavigationBarLargeTitleFontFamily:[newOptions.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[newOptions.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[newOptions.topBar.largeTitle.color getWithDefaultValue:nil]];
  82. [navigationController rnn_setNavigationBarFontFamily:[newOptions.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[newOptions.topBar.title.fontSize getWithDefaultValue:nil] color:[newOptions.topBar.title.color getWithDefaultValue:nil]];
  83. }
  84. @end