react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 *)initialOptions {
  7. [super applyOptions:initialOptions];
  8. RNNNavigationOptions* options = [initialOptions withDefault:self.defaultOptions];
  9. RNNNavigationController* navigationController = self.bindedViewController;
  10. [navigationController rnn_setInteractivePopGestureEnabled:[options.popGesture getWithDefaultValue:YES]];
  11. [navigationController rnn_setRootBackgroundImage:[options.rootBackgroundImage getWithDefaultValue:nil]];
  12. [navigationController rnn_setNavigationBarTestID:[options.topBar.testID getWithDefaultValue:nil]];
  13. [navigationController rnn_setNavigationBarVisible:[options.topBar.visible getWithDefaultValue:YES] animated:[options.topBar.animate getWithDefaultValue:YES]];
  14. [navigationController rnn_hideBarsOnScroll:[options.topBar.hideOnScroll getWithDefaultValue:NO]];
  15. [navigationController rnn_setNavigationBarNoBorder:[options.topBar.noBorder getWithDefaultValue:NO]];
  16. [navigationController rnn_setBarStyle:[RCTConvert UIBarStyle:[options.topBar.barStyle getWithDefaultValue:@"default"]]];
  17. [navigationController rnn_setNavigationBarTranslucent:[options.topBar.background.translucent getWithDefaultValue:NO]];
  18. [navigationController rnn_setNavigationBarClipsToBounds:[options.topBar.background.clipToBounds getWithDefaultValue:NO]];
  19. [navigationController rnn_setNavigationBarBlur:[options.topBar.background.blur getWithDefaultValue:NO]];
  20. [navigationController setTopBarBackgroundColor:[options.topBar.background.color getWithDefaultValue:nil]];
  21. [navigationController rnn_setNavigationBarLargeTitleVisible:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
  22. [navigationController rnn_setNavigationBarLargeTitleFontFamily:[options.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[options.topBar.largeTitle.color getWithDefaultValue:nil]];
  23. [navigationController rnn_setNavigationBarFontFamily:[options.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[options.topBar.title.fontSize getWithDefaultValue:nil] color:[options.topBar.title.color getWithDefaultValue:nil]];
  24. [navigationController rnn_setBackButtonColor:[options.topBar.backButton.color 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)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
  32. [super mergeOptions:options resolvedOptions:resolvedOptions];
  33. RNNNavigationController* navigationController = self.bindedViewController;
  34. RNNNavigationOptions* withDefault = (RNNNavigationOptions *)[options withDefault:self.defaultOptions];
  35. if (options.popGesture.hasValue) {
  36. [navigationController rnn_setInteractivePopGestureEnabled:withDefault.popGesture.get];
  37. }
  38. if (options.rootBackgroundImage.hasValue) {
  39. [navigationController rnn_setRootBackgroundImage:withDefault.rootBackgroundImage.get];
  40. }
  41. if (options.topBar.testID.hasValue) {
  42. [navigationController rnn_setNavigationBarTestID:withDefault.topBar.testID.get];
  43. }
  44. if (options.topBar.visible.hasValue) {
  45. [navigationController rnn_setNavigationBarVisible:withDefault.topBar.visible.get animated:[withDefault.topBar.animate getWithDefaultValue:YES]];
  46. }
  47. if (options.topBar.hideOnScroll.hasValue) {
  48. [navigationController rnn_hideBarsOnScroll:[withDefault.topBar.hideOnScroll get]];
  49. }
  50. if (options.topBar.noBorder.hasValue) {
  51. [navigationController rnn_setNavigationBarNoBorder:[withDefault.topBar.noBorder get]];
  52. }
  53. if (options.topBar.barStyle.hasValue) {
  54. [navigationController rnn_setBarStyle:[RCTConvert UIBarStyle:withDefault.topBar.barStyle.get]];
  55. }
  56. if (options.topBar.background.translucent.hasValue) {
  57. [navigationController rnn_setNavigationBarTranslucent:[withDefault.topBar.background.translucent get]];
  58. }
  59. if (options.topBar.background.clipToBounds.hasValue) {
  60. [navigationController rnn_setNavigationBarClipsToBounds:[withDefault.topBar.background.clipToBounds get]];
  61. }
  62. if (options.topBar.background.blur.hasValue) {
  63. [navigationController rnn_setNavigationBarBlur:[withDefault.topBar.background.blur get]];
  64. }
  65. if (options.topBar.background.color.hasValue) {
  66. [navigationController setTopBarBackgroundColor:withDefault.topBar.background.color.get];
  67. }
  68. if (options.topBar.largeTitle.visible.hasValue) {
  69. [navigationController rnn_setNavigationBarLargeTitleVisible:withDefault.topBar.largeTitle.visible.get];
  70. }
  71. if (options.topBar.backButton.icon.hasValue) {
  72. [navigationController rnn_setBackButtonIcon:[withDefault.topBar.backButton.icon getWithDefaultValue:nil] withColor:[withDefault.topBar.backButton.color getWithDefaultValue:nil] title:[withDefault.topBar.backButton.showTitle getWithDefaultValue:YES] ? [withDefault.topBar.backButton.title getWithDefaultValue:nil] : @""];
  73. }
  74. if (options.topBar.backButton.color.hasValue) {
  75. [navigationController rnn_setBackButtonColor:options.topBar.backButton.color.get];
  76. }
  77. [navigationController rnn_setNavigationBarLargeTitleFontFamily:[withDefault.topBar.largeTitle.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.largeTitle.fontSize getWithDefaultValue:nil] color:[withDefault.topBar.largeTitle.color getWithDefaultValue:nil]];
  78. [navigationController rnn_setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:nil]];
  79. }
  80. @end