react-native-navigation的迁移库

RNNTopBarOptions.m 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.hideNavBarOnFocusSearchBar = [BoolParser parse:dict key:@"hideNavBarOnFocusSearchBar"];
  24. self.testID = [TextParser parse:dict key:@"testID"];
  25. self.barStyle = [TextParser parse:dict key:@"barStyle"];
  26. self.searchBarPlaceholder = [TextParser parse:dict key:@"searchBarPlaceholder"];
  27. self.largeTitle = [[RNNLargeTitleOptions alloc] initWithDict:dict[@"largeTitle"]];
  28. self.title = [[RNNTitleOptions alloc] initWithDict:dict[@"title"]];
  29. self.subtitle = [[RNNSubtitleOptions alloc] initWithDict:dict[@"subtitle"]];
  30. self.background = [[RNNBackgroundOptions alloc] initWithDict:dict[@"background"]];
  31. self.backButton = [[RNNBackButtonOptions alloc] initWithDict:dict[@"backButton"]];
  32. self.leftButtonStyle = [[RNNButtonOptions alloc] initWithDict:dict[@"leftButtonStyle"]];
  33. self.rightButtonStyle = [[RNNButtonOptions alloc] initWithDict:dict[@"rightButtonStyle"]];
  34. if (self.leftButtonColor.hasValue) {
  35. self.leftButtonStyle.color = self.leftButtonColor;
  36. }
  37. if (self.rightButtonColor.hasValue) {
  38. self.rightButtonStyle.color = self.rightButtonColor;
  39. }
  40. if (self.leftButtonDisabledColor.hasValue) {
  41. self.leftButtonStyle.disabledColor = self.rightButtonDisabledColor;
  42. }
  43. if (self.rightButtonDisabledColor.hasValue) {
  44. self.rightButtonStyle.disabledColor = self.rightButtonDisabledColor;
  45. }
  46. self.leftButtons = dict[@"leftButtons"];
  47. self.rightButtons = dict[@"rightButtons"];
  48. return self;
  49. }
  50. - (BOOL)shouldDrawBehind {
  51. return [self.drawBehind getWithDefaultValue:NO] ||
  52. [self.background.translucent getWithDefaultValue:NO] ||
  53. ![self.visible getWithDefaultValue:YES] ||
  54. [self.largeTitle.visible getWithDefaultValue:NO];
  55. }
  56. @end