react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. [navigationController rnn_setNavigationBarLargeTitleVisible:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
  36. }
  37. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  38. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  39. RNNNavigationController* navigationController = self.bindedViewController;
  40. if (newOptions.popGesture.hasValue) {
  41. [navigationController rnn_setInteractivePopGestureEnabled:newOptions.popGesture.get];
  42. }
  43. if (newOptions.rootBackgroundImage.hasValue) {
  44. [navigationController rnn_setRootBackgroundImage:newOptions.rootBackgroundImage.get];
  45. }
  46. if (newOptions.topBar.testID.hasValue) {
  47. [navigationController rnn_setNavigationBarTestID:newOptions.topBar.testID.get];
  48. }
  49. if (newOptions.topBar.visible.hasValue) {
  50. [navigationController rnn_setNavigationBarVisible:newOptions.topBar.visible.get animated:[newOptions.topBar.animate getWithDefaultValue:YES]];
  51. }
  52. if (newOptions.topBar.hideOnScroll.hasValue) {
  53. [navigationController rnn_hideBarsOnScroll:[newOptions.topBar.hideOnScroll get]];
  54. }
  55. if (newOptions.topBar.noBorder.hasValue) {
  56. [navigationController rnn_setNavigationBarNoBorder:[newOptions.topBar.noBorder get]];
  57. }
  58. if (newOptions.topBar.barStyle.hasValue) {
  59. [navigationController rnn_setBarStyle:[RCTConvert UIBarStyle:newOptions.topBar.barStyle.get]];
  60. }
  61. if (newOptions.topBar.background.translucent.hasValue) {
  62. [navigationController rnn_setNavigationBarTranslucent:[newOptions.topBar.background.translucent get]];
  63. }
  64. if (newOptions.topBar.background.clipToBounds.hasValue) {
  65. [navigationController rnn_setNavigationBarClipsToBounds:[newOptions.topBar.background.clipToBounds get]];
  66. }
  67. if (newOptions.topBar.background.blur.hasValue) {
  68. [navigationController rnn_setNavigationBarBlur:[newOptions.topBar.background.blur get]];
  69. }
  70. if (newOptions.topBar.background.color.hasValue) {
  71. [navigationController setTopBarBackgroundColor:newOptions.topBar.background.color.get];
  72. }
  73. if (newOptions.topBar.largeTitle.visible.hasValue) {
  74. [navigationController rnn_setNavigationBarLargeTitleVisible:newOptions.topBar.largeTitle.visible.get];
  75. }
  76. if (newOptions.topBar.backButton.icon.hasValue) {
  77. [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] : @""];
  78. }
  79. if (newOptions.topBar.backButton.color.hasValue) {
  80. [navigationController rnn_setBackButtonColor:newOptions.topBar.backButton.color.get];
  81. }
  82. [navigationController rnn_setNavigationBarLargeTitleFontFamily:[newOptions.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[newOptions.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[newOptions.topBar.largeTitle.color getWithDefaultValue:nil]];
  83. [navigationController rnn_setNavigationBarFontFamily:[newOptions.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[newOptions.topBar.title.fontSize getWithDefaultValue:nil] color:[newOptions.topBar.title.color getWithDefaultValue:nil]];
  84. }
  85. @end