react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 5.5KB

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