react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 5.8KB

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