diff --git a/React/Views/RCTNavItem.h b/React/Views/RCTNavItem.h index 0f275de178f95b..02192adbc5f048 100644 --- a/React/Views/RCTNavItem.h +++ b/React/Views/RCTNavItem.h @@ -8,12 +8,13 @@ */ #import - +#import "RCTWrapperViewController.h" #import "RCTComponent.h" @interface RCTNavItem : UIView @property (nonatomic, copy) NSString *title; +@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 5fa8005c94f9b5..2d735fcd1e626e 100644 --- a/React/Views/RCTNavItem.m +++ b/React/Views/RCTNavItem.m @@ -11,10 +11,27 @@ @implementation RCTNavItem +@synthesize delegate = _delegate; @synthesize backButtonItem = _backButtonItem; @synthesize leftButtonItem = _leftButtonItem; @synthesize rightButtonItem = _rightButtonItem; +- (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 162412b7967d28..a9ff0c971572d7 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)]) {