react-native-navigation的迁移库

RNNTopBarOptions.m 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #import "RNNTopBarOptions.h"
  2. #import "RNNNavigationButtons.h"
  3. #import "RNNCustomTitleView.h"
  4. #import "UIViewController+RNNOptions.h"
  5. #import "UINavigationController+RNNOptions.h"
  6. @interface RNNTopBarOptions ()
  7. @property (nonatomic, strong) RNNNavigationButtons* navigationButtons;
  8. @end
  9. @implementation RNNTopBarOptions
  10. - (instancetype)initWithDict:(NSDictionary *)dict {
  11. self = [super init];
  12. self.visible = [BoolParser parse:dict key:@"visible"];
  13. self.hideOnScroll = [BoolParser parse:dict key:@"hideOnScroll"];
  14. self.leftButtonColor = [ColorParser parse:dict key:@"leftButtonColor"];
  15. self.rightButtonColor = [ColorParser parse:dict key:@"rightButtonColor"];
  16. self.leftButtonDisabledColor = [ColorParser parse:dict key:@"leftButtonDisabledColor"];
  17. self.rightButtonDisabledColor = [ColorParser parse:dict key:@"rightButtonDisabledColor"];
  18. self.drawBehind = [BoolParser parse:dict key:@"drawBehind"];
  19. self.noBorder = [BoolParser parse:dict key:@"noBorder"];
  20. self.animate = [BoolParser parse:dict key:@"animate"];
  21. self.searchBar = [BoolParser parse:dict key:@"searchBar"];
  22. self.searchBarHiddenWhenScrolling = [BoolParser parse:dict key:@"searchBarHiddenWhenScrolling"];
  23. self.testID = [TextParser parse:dict key:@"testID"];
  24. self.barStyle = [TextParser parse:dict key:@"barStyle"];
  25. self.searchBarPlaceholder = [TextParser parse:dict key:@"searchBarPlaceholder"];
  26. self.largeTitle = [[RNNLargeTitleOptions alloc] initWithDict:dict[@"largeTitle"]];
  27. self.title = [[RNNTitleOptions alloc] initWithDict:dict[@"title"]];
  28. self.subtitle = [[RNNSubtitleOptions alloc] initWithDict:dict[@"subtitle"]];
  29. self.background = [[RNNBackgroundOptions alloc] initWithDict:dict[@"background"]];
  30. self.backButton = [[RNNBackButtonOptions alloc] initWithDict:dict[@"backButton"]];
  31. self.leftButtonStyle = [[RNNButtonOptions alloc] initWithDict:dict[@"leftButtonStyle"]];
  32. self.rightButtonStyle = [[RNNButtonOptions alloc] initWithDict:dict[@"rightButtonStyle"]];
  33. if (self.leftButtonColor.hasValue) {
  34. self.leftButtonStyle.color = self.leftButtonColor;
  35. }
  36. if (self.rightButtonColor.hasValue) {
  37. self.rightButtonStyle.color = self.rightButtonColor;
  38. }
  39. if (self.leftButtonDisabledColor.hasValue) {
  40. self.leftButtonStyle.disabledColor = self.rightButtonDisabledColor;
  41. }
  42. if (self.rightButtonDisabledColor.hasValue) {
  43. self.rightButtonStyle.disabledColor = self.rightButtonDisabledColor;
  44. }
  45. self.leftButtons = dict[@"leftButtons"];
  46. self.rightButtons = dict[@"rightButtons"];
  47. return self;
  48. }
  49. - (void)applyOn:(UIViewController*)viewController {
  50. if (self.rightButtons || self.leftButtons) {
  51. _navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:(RNNRootViewController*)viewController];
  52. [_navigationButtons applyLeftButtons:self.leftButtons rightButtons:self.rightButtons defaultLeftButtonStyle:self.leftButtonStyle defaultRightButtonStyle:self.rightButtonStyle];
  53. }
  54. self.rightButtons = nil;
  55. self.leftButtons = nil;
  56. }
  57. //- (void)setRightButtonColor:(NSNumber *)rightButtonColor {
  58. // _rightButtonColor = rightButtonColor;
  59. // _rightButtonStyle.color = rightButtonColor;
  60. //}
  61. //
  62. //- (void)setRightButtonDisabledColor:(NSNumber *)rightButtonDisabledColor {
  63. // _rightButtonDisabledColor = rightButtonDisabledColor;
  64. // _rightButtonStyle.disabledColor = rightButtonDisabledColor;
  65. //}
  66. //
  67. //- (void)setLeftButtonColor:(NSNumber *)leftButtonColor {
  68. // _leftButtonColor = leftButtonColor;
  69. // _leftButtonStyle.color = leftButtonColor;
  70. //}
  71. //
  72. //- (void)setLeftButtonDisabledColor:(NSNumber *)leftButtonDisabledColor {
  73. // _leftButtonDisabledColor = leftButtonDisabledColor;
  74. // _leftButtonStyle.disabledColor = leftButtonDisabledColor;
  75. //}
  76. //- (void)setRightButtons:(id)rightButtons {
  77. // if ([rightButtons isKindOfClass:[NSArray class]]) {
  78. // _rightButtons = rightButtons;
  79. // } else if ([rightButtons isKindOfClass:[NSDictionary class]]) {
  80. // if (rightButtons[@"id"]) {
  81. // _rightButtons = @[rightButtons];
  82. // } else {
  83. // [_rightButtonStyle mergeWith:rightButtons];
  84. // }
  85. // } else {
  86. // _rightButtons = rightButtons;
  87. // }
  88. //}
  89. //
  90. //- (void)setLeftButtons:(id)leftButtons {
  91. // if ([leftButtons isKindOfClass:[NSArray class]]) {
  92. // _leftButtons = leftButtons;
  93. // } else if ([leftButtons isKindOfClass:[NSDictionary class]]) {
  94. // if (leftButtons[@"id"]) {
  95. // _leftButtons = @[leftButtons];
  96. // } else {
  97. // [_leftButtonStyle mergeWith:leftButtons];
  98. // }
  99. // } else {
  100. // _leftButtons = leftButtons;
  101. // }
  102. //}
  103. @end