react-native-navigation的迁移库

RNNNavigationControllerPresenter.m 5.4KB

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