Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/ios/BottomTabPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)opt
[child setTabBarItemBadgeColor:[withDefault.bottomTab.badgeColor getWithDefaultValue:nil]];
}

- (void)mergeOptions:(RNNNavigationOptions *)options
- (void)mergeOptions:(RNNNavigationOptions *)mergeOptions
resolvedOptions:(RNNNavigationOptions *)resolvedOptions
child:(UIViewController *)child {
RNNNavigationOptions *withDefault = (RNNNavigationOptions *)[[resolvedOptions
withDefault:self.defaultOptions] overrideOptions:options];
withDefault:self.defaultOptions] mergeOptions:mergeOptions];

if (options.bottomTab.hasValue)
if (mergeOptions.bottomTab.hasValue)
[self createTabBarItem:child bottomTabOptions:withDefault.bottomTab];
if (options.bottomTab.badge.hasValue)
[child setTabBarItemBadge:options.bottomTab.badge.get];
if (options.bottomTab.badgeColor.hasValue)
[child setTabBarItemBadgeColor:options.bottomTab.badgeColor.get];
if (mergeOptions.bottomTab.badge.hasValue)
[child setTabBarItemBadge:mergeOptions.bottomTab.badge.get];
if (mergeOptions.bottomTab.badgeColor.hasValue)
[child setTabBarItemBadgeColor:mergeOptions.bottomTab.badgeColor.get];
}

- (void)createTabBarItem:(UIViewController *)child
Expand Down
50 changes: 25 additions & 25 deletions lib/ios/BottomTabsBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,52 +33,52 @@ - (void)applyOptions:(RNNNavigationOptions *)options {
getWithDefaultValue:@"default"]]];
}

- (void)mergeOptions:(RNNNavigationOptions *)options
- (void)mergeOptions:(RNNNavigationOptions *)mergeOptions
resolvedOptions:(RNNNavigationOptions *)currentOptions {
[super mergeOptions:options resolvedOptions:currentOptions];
[super mergeOptions:mergeOptions resolvedOptions:currentOptions];
RNNBottomTabsController *bottomTabs = self.tabBarController;

if (options.bottomTabs.currentTabIndex.hasValue) {
[bottomTabs setCurrentTabIndex:options.bottomTabs.currentTabIndex.get];
[options.bottomTabs.currentTabIndex consume];
if (mergeOptions.bottomTabs.currentTabIndex.hasValue) {
[bottomTabs setCurrentTabIndex:mergeOptions.bottomTabs.currentTabIndex.get];
[mergeOptions.bottomTabs.currentTabIndex consume];
}

if (options.bottomTabs.currentTabId.hasValue) {
[bottomTabs setCurrentTabID:options.bottomTabs.currentTabId.get];
[options.bottomTabs.currentTabId consume];
if (mergeOptions.bottomTabs.currentTabId.hasValue) {
[bottomTabs setCurrentTabID:mergeOptions.bottomTabs.currentTabId.get];
[mergeOptions.bottomTabs.currentTabId consume];
}

if (options.bottomTabs.testID.hasValue) {
[bottomTabs setTabBarTestID:options.bottomTabs.testID.get];
if (mergeOptions.bottomTabs.testID.hasValue) {
[bottomTabs setTabBarTestID:mergeOptions.bottomTabs.testID.get];
}

if (options.bottomTabs.backgroundColor.hasValue) {
[self setTabBarBackgroundColor:options.bottomTabs.backgroundColor.get];
if (mergeOptions.bottomTabs.backgroundColor.hasValue) {
[self setTabBarBackgroundColor:mergeOptions.bottomTabs.backgroundColor.get];
}

if (options.bottomTabs.barStyle.hasValue) {
[bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:options.bottomTabs.barStyle.get]];
if (mergeOptions.bottomTabs.barStyle.hasValue) {
[bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:mergeOptions.bottomTabs.barStyle.get]];
}

if (options.bottomTabs.translucent.hasValue) {
[bottomTabs setTabBarTranslucent:options.bottomTabs.translucent.get];
if (mergeOptions.bottomTabs.translucent.hasValue) {
[bottomTabs setTabBarTranslucent:mergeOptions.bottomTabs.translucent.get];
}

if (options.bottomTabs.hideShadow.hasValue) {
[bottomTabs setTabBarHideShadow:options.bottomTabs.hideShadow.get];
if (mergeOptions.bottomTabs.hideShadow.hasValue) {
[bottomTabs setTabBarHideShadow:mergeOptions.bottomTabs.hideShadow.get];
}

if (options.bottomTabs.visible.hasValue) {
if (options.bottomTabs.animate.hasValue) {
[bottomTabs setTabBarVisible:options.bottomTabs.visible.get
animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
if (mergeOptions.bottomTabs.visible.hasValue) {
if (mergeOptions.bottomTabs.animate.hasValue) {
[bottomTabs setTabBarVisible:mergeOptions.bottomTabs.visible.get
animated:[mergeOptions.bottomTabs.animate getWithDefaultValue:NO]];
} else {
[bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:NO];
[bottomTabs setTabBarVisible:mergeOptions.bottomTabs.visible.get animated:NO];
}
}

if (options.layout.backgroundColor.hasValue) {
[bottomTabs.view setBackgroundColor:options.layout.backgroundColor.get];
if (mergeOptions.layout.backgroundColor.hasValue) {
[bottomTabs.view setBackgroundColor:mergeOptions.layout.backgroundColor.get];
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/ios/DeprecationOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
@implementation DeprecationOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];
return self;
}

- (void)mergeOptions:(DeprecationOptions *)options {
}

@end
13 changes: 11 additions & 2 deletions lib/ios/DotIndicatorOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@implementation DotIndicatorOptions
- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];

self.color = [ColorParser parse:dict key:@"color"];
self.size = [NumberParser parse:dict key:@"size"];
Expand All @@ -20,8 +20,17 @@ - (instancetype)init {
return self;
}

- (void)mergeOptions:(DotIndicatorOptions *)options {
if (options.color.hasValue)
self.color = options.color;
if (options.size.hasValue)
self.size = options.size;
if (options.visible.hasValue)
self.visible = options.visible;
}

- (bool)hasValue {
return [self.visible hasValue];
}

@end
@end
7 changes: 0 additions & 7 deletions lib/ios/NSObject+Utils.h

This file was deleted.

25 changes: 0 additions & 25 deletions lib/ios/NSObject+Utils.m

This file was deleted.

11 changes: 10 additions & 1 deletion lib/ios/RNNAnimationsOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@implementation RNNAnimationsOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];

self.push = [[RNNScreenTransition alloc] initWithDict:dict[@"push"]];
self.pop = [[RNNScreenTransition alloc] initWithDict:dict[@"pop"]];
Expand All @@ -15,4 +15,13 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
return self;
}

- (void)mergeOptions:(RNNAnimationsOptions *)options {
[self.push mergeOptions:options.push];
[self.pop mergeOptions:options.pop];
[self.showModal mergeOptions:options.showModal];
[self.dismissModal mergeOptions:options.dismissModal];
[self.setStackRoot mergeOptions:options.setStackRoot];
[self.setRoot mergeOptions:options.setRoot];
}

@end
23 changes: 22 additions & 1 deletion lib/ios/RNNBackButtonOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@implementation RNNBackButtonOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];

self.icon = [ImageParser parse:dict key:@"icon"];
self.title = [TextParser parse:dict key:@"title"];
Expand All @@ -18,6 +18,27 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
return self;
}

- (void)mergeOptions:(RNNBackButtonOptions *)options {
if (options.icon.hasValue)
self.icon = options.icon;
if (options.title.hasValue)
self.title = options.title;
if (options.transition.hasValue)
self.transition = options.transition;
if (options.color.hasValue)
self.color = options.color;
if (options.showTitle.hasValue)
self.showTitle = options.showTitle;
if (options.visible.hasValue)
self.visible = options.visible;
if (options.testID.hasValue)
self.testID = options.testID;
if (options.fontFamily.hasValue)
self.fontFamily = options.fontFamily;
if (options.fontSize.hasValue)
self.fontSize = options.fontSize;
}

- (BOOL)hasValue {
return self.icon.hasValue || self.showTitle.hasValue || self.color.hasValue ||
self.fontFamily.hasValue || self.fontSize.hasValue || self.title.hasValue;
Expand Down
15 changes: 14 additions & 1 deletion lib/ios/RNNBackgroundOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@implementation RNNBackgroundOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];

self.color = [ColorParser parse:dict key:@"color"];
self.translucent = [BoolParser parse:dict key:@"translucent"];
Expand All @@ -14,4 +14,17 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
return self;
}

- (void)mergeOptions:(RNNBackgroundOptions *)options {
[self.component mergeOptions:options.component];

if (options.color.hasValue)
self.color = options.color;
if (options.translucent.hasValue)
self.translucent = options.translucent;
if (options.blur.hasValue)
self.blur = options.blur;
if (options.clipToBounds.hasValue)
self.clipToBounds = options.clipToBounds;
}

@end
26 changes: 14 additions & 12 deletions lib/ios/RNNBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ - (void)componentDidDisappear {

- (void)willMoveToParentViewController:(UIViewController *)parent {
if (parent) {
[self applyOptionsOnWillMoveToParentViewController:self.boundViewController.resolveOptions];
RNNNavigationOptions *resolvedOptions = [self.boundViewController resolveOptions];
[self applyOptionsOnWillMoveToParentViewController:resolvedOptions];
[self.boundViewController onChildAddToParent:self.boundViewController
options:self.boundViewController.resolveOptions];
options:resolvedOptions];
}
}

Expand Down Expand Up @@ -70,27 +71,27 @@ - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)opt
- (void)applyOptions:(RNNNavigationOptions *)options {
}

- (void)mergeOptions:(RNNNavigationOptions *)options
- (void)mergeOptions:(RNNNavigationOptions *)mergeOptions
resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
RNNNavigationOptions *withDefault = (RNNNavigationOptions *)[[resolvedOptions
withDefault:_defaultOptions] overrideOptions:options];
withDefault:_defaultOptions] mergeOptions:mergeOptions];
if (@available(iOS 13.0, *)) {
if (withDefault.modal.swipeToDismiss.hasValue)
self.boundViewController.modalInPresentation = !withDefault.modal.swipeToDismiss.get;
}

if (options.window.backgroundColor.hasValue) {
if (mergeOptions.window.backgroundColor.hasValue) {
UIApplication.sharedApplication.delegate.window.backgroundColor =
withDefault.window.backgroundColor.get;
}

if (options.statusBar.visible.hasValue) {
if (mergeOptions.statusBar.visible.hasValue) {
[self.boundViewController setNeedsStatusBarAppearanceUpdate];
}

if (options.layout.autoHideHomeIndicator.hasValue &&
options.layout.autoHideHomeIndicator.get != _prefersHomeIndicatorAutoHidden) {
_prefersHomeIndicatorAutoHidden = options.layout.autoHideHomeIndicator.get;
if (mergeOptions.layout.autoHideHomeIndicator.hasValue &&
mergeOptions.layout.autoHideHomeIndicator.get != _prefersHomeIndicatorAutoHidden) {
_prefersHomeIndicatorAutoHidden = mergeOptions.layout.autoHideHomeIndicator.get;
[self.boundViewController setNeedsUpdateOfHomeIndicatorAutoHidden];
}
}
Expand Down Expand Up @@ -130,9 +131,10 @@ - (BOOL)getStatusBarVisibility {
}

- (RNNStatusBarOptions *)resolveStatusBarOptions {
return (RNNStatusBarOptions *)[[self.boundViewController.options.statusBar
mergeInOptions:self.boundViewController.getCurrentChild.presenter.resolveStatusBarOptions]
withDefault:self.defaultOptions.statusBar];
RNNNavigationOptions *options = self.boundViewController.options.copy;
[options.statusBar
mergeOptions:self.boundViewController.getCurrentChild.presenter.resolveStatusBarOptions];
return [[options withDefault:self.defaultOptions] statusBar];
}

- (UINavigationItem *)currentNavigationItem {
Expand Down
41 changes: 39 additions & 2 deletions lib/ios/RNNBottomTabOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
@implementation RNNBottomTabOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self = [super initWithDict:dict];
self.tag = arc4random();

self.text = [TextParser parse:dict key:@"text"];
self.badge = [TextParser parse:dict key:@"badge"];
self.badgeColor = [ColorParser parse:dict key:@"badgeColor"];
self.fontFamily = [TextParser parse:dict key:@"fontFamily"];
self.fontWeight = [TextParser parse:dict key:@"fontWeight"];
self.testID = [TextParser parse:dict key:@"testID"];
self.badgeColor = [ColorParser parse:dict key:@"badgeColor"];

self.dotIndicator = [DotIndicatorParser parse:dict];

Expand All @@ -32,6 +32,43 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
return self;
}

- (void)mergeOptions:(RNNBottomTabOptions *)options {
[self.dotIndicator mergeOptions:options.dotIndicator];

if (options.text.hasValue)
self.text = options.text;
if (options.badge.hasValue)
self.badge = options.badge;
if (options.fontFamily.hasValue)
self.fontFamily = options.fontFamily;
if (options.fontWeight.hasValue)
self.fontWeight = options.fontWeight;
if (options.testID.hasValue)
self.testID = options.testID;
if (options.badgeColor.hasValue)
self.badgeColor = options.badgeColor;
if (options.icon.hasValue)
self.icon = options.icon;
if (options.selectedIcon.hasValue)
self.selectedIcon = options.selectedIcon;
if (options.iconColor.hasValue)
self.iconColor = options.iconColor;
if (options.selectedIconColor.hasValue)
self.selectedIconColor = options.selectedIconColor;
if (options.selectedTextColor.hasValue)
self.selectedTextColor = options.selectedTextColor;
if (options.iconInsets.hasValue)
self.iconInsets = options.iconInsets;
if (options.textColor.hasValue)
self.textColor = options.textColor;
if (options.fontSize.hasValue)
self.fontSize = options.fontSize;
if (options.visible.hasValue)
self.visible = options.visible;
if (options.selectTabOnPress.hasValue)
self.selectTabOnPress = options.selectTabOnPress;
}

- (BOOL)hasValue {
return self.text.hasValue || self.badge.hasValue || self.badgeColor.hasValue ||
self.fontFamily.hasValue || self.fontWeight.hasValue || self.fontSize.hasValue ||
Expand Down
Loading