diff --git a/React/Views/RCTNavItem.h b/React/Views/RCTNavItem.h index 094da3f3a1e3f4..a67a4713fe895c 100644 --- a/React/Views/RCTNavItem.h +++ b/React/Views/RCTNavItem.h @@ -8,13 +8,14 @@ */ #import - +#import "RCTWrapperViewController.h" #import "RCTComponent.h" @interface RCTNavItem : UIView @property (nonatomic, copy) NSString *title; @property (nonatomic, strong) UIImage *titleImage; +@property (nonatomic, weak) RCTWrapperViewController *delegate; @property (nonatomic, strong) UIImage *leftButtonIcon; @property (nonatomic, copy) NSString *leftButtonTitle; @property (nonatomic, strong) UIImage *rightButtonIcon; diff --git a/React/Views/RCTNavItem.m b/React/Views/RCTNavItem.m index 41cb88a16acbeb..fd0cce17960e25 100644 --- a/React/Views/RCTNavItem.m +++ b/React/Views/RCTNavItem.m @@ -11,6 +11,7 @@ @implementation RCTNavItem +@synthesize delegate = _delegate; @synthesize backButtonItem = _backButtonItem; @synthesize leftButtonItem = _leftButtonItem; @synthesize rightButtonItem = _rightButtonItem; @@ -24,6 +25,22 @@ - (UIImageView *)titleImageView } } +- (void)setTitle:(NSString *)title +{ + if (title != _title) { + _title = title; + [self.delegate titleDidChange:title]; + } +} + +- (void)setBarTintColor:(UIColor *)barTintColor +{ + if (barTintColor != _barTintColor) { + _barTintColor = barTintColor; + [self.delegate barTintColorDidChange:barTintColor]; + } +} + - (void)setBackButtonTitle:(NSString *)backButtonTitle { _backButtonTitle = backButtonTitle; diff --git a/React/Views/RCTWrapperViewController.h b/React/Views/RCTWrapperViewController.h index 7b24ae7d53072f..6919b4e2e9cfe1 100644 --- a/React/Views/RCTWrapperViewController.h +++ b/React/Views/RCTWrapperViewController.h @@ -26,6 +26,9 @@ didMoveToNavigationController:(UINavigationController *)navigationController; - (instancetype)initWithContentView:(UIView *)contentView NS_DESIGNATED_INITIALIZER; - (instancetype)initWithNavItem:(RCTNavItem *)navItem; +- (void)titleDidChange:(NSString *)title; +- (void)barTintColorDidChange:(UIColor *)barTintColor; + @property (nonatomic, weak) id navigationListener; @property (nonatomic, strong) RCTNavItem *navItem; diff --git a/React/Views/RCTWrapperViewController.m b/React/Views/RCTWrapperViewController.m index d9ea38b852dd43..165bfc8c975162 100644 --- a/React/Views/RCTWrapperViewController.m +++ b/React/Views/RCTWrapperViewController.m @@ -45,6 +45,7 @@ - (instancetype)initWithNavItem:(RCTNavItem *)navItem { if ((self = [self initWithContentView:navItem])) { _navItem = navItem; + _navItem.delegate = self; } return self; } @@ -60,6 +61,19 @@ - (void)viewWillLayoutSubviews _currentBottomLayoutGuide = self.bottomLayoutGuide; } + +- (void)titleDidChange:(NSString *)title +{ + UINavigationItem *item = self.navigationItem; + item.title = title; +} + +- (void)barTintColorDidChange:(UIColor *)barTintColor +{ + UINavigationBar *bar = self.navigationController.navigationBar; + bar.barTintColor = barTintColor; +} + static BOOL RCTFindScrollViewAndRefreshContentInsetInView(UIView *view) { if ([view conformsToProtocol:@protocol(RCTAutoInsetsProtocol)]) {