diff --git a/lib/ios/RNNBasePresenter.h b/lib/ios/RNNBasePresenter.h index 8262030ce0e..42f7ab0946f 100644 --- a/lib/ios/RNNBasePresenter.h +++ b/lib/ios/RNNBasePresenter.h @@ -12,7 +12,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void); - (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; -- (void)bindViewController:(UIViewController *)boundViewController; +- (void)boundViewController:(UIViewController *)boundViewController; - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions; diff --git a/lib/ios/RNNBasePresenter.m b/lib/ios/RNNBasePresenter.m index 6f38a7bd435..a4b05786086 100644 --- a/lib/ios/RNNBasePresenter.m +++ b/lib/ios/RNNBasePresenter.m @@ -18,7 +18,7 @@ -(instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { return self; } -- (void)bindViewController:(UIViewController *)boundViewController { +- (void)boundViewController:(UIViewController *)boundViewController { self.boundComponentId = boundViewController.layoutInfo.componentId; _boundViewController = boundViewController; } diff --git a/lib/ios/RNNCommandsHandler.m b/lib/ios/RNNCommandsHandler.m index 2d34f5a8537..ceecc23cba2 100644 --- a/lib/ios/RNNCommandsHandler.m +++ b/lib/ios/RNNCommandsHandler.m @@ -89,7 +89,6 @@ - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)mergeOptions [CATransaction begin]; [CATransaction setCompletionBlock:completion]; - [vc overrideOptions:newOptions]; [vc mergeOptions:newOptions]; [CATransaction commit]; diff --git a/lib/ios/RNNComponentOptions.h b/lib/ios/RNNComponentOptions.h index 4826aed2369..2e3abed9d5c 100644 --- a/lib/ios/RNNComponentOptions.h +++ b/lib/ios/RNNComponentOptions.h @@ -7,4 +7,6 @@ @property (nonatomic, strong) Text* alignment; @property (nonatomic, strong) Bool* waitForRender; +- (BOOL)hasValue; + @end diff --git a/lib/ios/RNNComponentOptions.m b/lib/ios/RNNComponentOptions.m index 0dd8e042dd1..9d65dcb2e7d 100644 --- a/lib/ios/RNNComponentOptions.m +++ b/lib/ios/RNNComponentOptions.m @@ -13,4 +13,8 @@ - (instancetype)initWithDict:(NSDictionary *)dict { return self; } +- (BOOL)hasValue { + return _name.hasValue; +} + @end diff --git a/lib/ios/RNNComponentPresenter.m b/lib/ios/RNNComponentPresenter.m index c5366a1f471..66b511f50cf 100644 --- a/lib/ios/RNNComponentPresenter.m +++ b/lib/ios/RNNComponentPresenter.m @@ -21,8 +21,8 @@ - (instancetype)initWithComponentRegistry:(RNNReactComponentRegistry *)component return self; } -- (void)bindViewController:(UIViewController *)bindedViewController { - [super bindViewController:bindedViewController]; +- (void)boundViewController:(UIViewController *)boundViewController { + [super boundViewController:boundViewController]; _navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self.boundViewController componentRegistry:_componentRegistry]; } @@ -80,9 +80,9 @@ - (void)applyOptionsOnInit:(RNNNavigationOptions *)options { - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions { [super mergeOptions:options resolvedOptions:currentOptions]; RNNNavigationOptions * withDefault = (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]]; - UIViewController* viewController = self.boundViewController; - + [self removeTitleComponentIfNeeded:options]; + if (options.backgroundImage.hasValue) { [viewController setBackgroundImage:options.backgroundImage.get]; } @@ -155,9 +155,6 @@ - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigat if (options.topBar.title.component.name.hasValue) { [self setCustomNavigationTitleView:options perform:nil]; - } else { - [_customTitleView removeFromSuperview]; - _customTitleView = nil; } [self setTitleViewWithSubtitle:withDefault]; @@ -169,6 +166,13 @@ - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigat } } +- (void)removeTitleComponentIfNeeded:(RNNNavigationOptions *)options { + if (options.topBar.title.text.hasValue && !options.topBar.component.hasValue) { + [_customTitleView removeFromSuperview]; + _customTitleView = nil; + } +} + - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock { [self setCustomNavigationTitleView:options perform:readyBlock]; } diff --git a/lib/ios/RNNSideMenuController.m b/lib/ios/RNNSideMenuController.m index 3c89c9263e5..3b7e0a92597 100644 --- a/lib/ios/RNNSideMenuController.m +++ b/lib/ios/RNNSideMenuController.m @@ -16,7 +16,7 @@ - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo creator:(id