-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bottom tabs appearance iOS 13 support (#5966)
This commit fixes issues with BottomTabs text color on iOS 13 * Extract bottomTab options from base presenter * Add iOS 13 appearance support for bottomTabs and bottomTab
- Loading branch information
Showing
29 changed files
with
456 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import "BottomTabPresenter.h" | ||
|
||
API_AVAILABLE(ios(13.0)) | ||
@interface BottomTabAppearancePresenter : BottomTabPresenter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#import "BottomTabAppearancePresenter.h" | ||
#import "TabBarItemAppearanceCreator.h" | ||
|
||
@implementation BottomTabAppearancePresenter | ||
|
||
- (void)bindViewController:(UIViewController *)boundViewController { | ||
[super bindViewController:boundViewController]; | ||
boundViewController.tabBarItem.standardAppearance = [[UITabBarAppearance alloc] init]; | ||
} | ||
|
||
- (void)updateTabBarItem:(UITabBarItem *)tabItem bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions { | ||
self.boundViewController.tabBarItem = [TabBarItemAppearanceCreator updateTabBarItem:self.boundViewController.tabBarItem bottomTabOptions:bottomTabOptions]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import "RNNBasePresenter.h" | ||
|
||
@interface BottomTabPresenter : RNNBasePresenter | ||
|
||
- (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; | ||
|
||
- (void)applyDotIndicator:(UIViewController *)child; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#import "BottomTabPresenter.h" | ||
#import "RNNTabBarItemCreator.h" | ||
#import "UIViewController+RNNOptions.h" | ||
#import "RNNDotIndicatorPresenter.h" | ||
#import "UIViewController+LayoutProtocol.h" | ||
|
||
@interface BottomTabPresenter () | ||
@property(nonatomic, strong) RNNDotIndicatorPresenter* dotIndicatorPresenter; | ||
@end | ||
|
||
@implementation BottomTabPresenter | ||
|
||
- (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { | ||
self = [super init]; | ||
self.defaultOptions = defaultOptions; | ||
self.dotIndicatorPresenter = [[RNNDotIndicatorPresenter alloc] initWithDefaultOptions:defaultOptions]; | ||
return self; | ||
} | ||
|
||
- (void)applyOptions:(RNNNavigationOptions *)options { | ||
RNNNavigationOptions * withDefault = [options withDefault:self.defaultOptions]; | ||
|
||
if (withDefault.bottomTab.badge.hasValue && [self.boundViewController.parentViewController isKindOfClass:[UITabBarController class]]) { | ||
[self.boundViewController setTabBarItemBadge:withDefault.bottomTab.badge.get]; | ||
} | ||
|
||
if (withDefault.bottomTab.badgeColor.hasValue && [self.boundViewController.parentViewController isKindOfClass:[UITabBarController class]]) { | ||
[self.boundViewController setTabBarItemBadgeColor:withDefault.bottomTab.badgeColor.get]; | ||
} | ||
} | ||
|
||
- (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options { | ||
RNNNavigationOptions * withDefault = [options withDefault:self.defaultOptions]; | ||
|
||
if (withDefault.bottomTab.hasValue) { | ||
[self updateTabBarItem:self.boundViewController.tabBarItem bottomTabOptions:withDefault.bottomTab]; | ||
} | ||
} | ||
|
||
- (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions { | ||
RNNNavigationOptions* withDefault = (RNNNavigationOptions *) [[resolvedOptions withDefault:self.defaultOptions] overrideOptions:options]; | ||
|
||
if (options.bottomTab.badge.hasValue) { | ||
[self.boundViewController setTabBarItemBadge:options.bottomTab.badge.get]; | ||
} | ||
|
||
if (options.bottomTab.badgeColor.hasValue && [self.boundViewController.parentViewController isKindOfClass:[UITabBarController class]]) { | ||
[self.boundViewController setTabBarItemBadgeColor:options.bottomTab.badgeColor.get]; | ||
} | ||
|
||
if ([options.bottomTab.dotIndicator hasValue] && [self.boundViewController.parentViewController isKindOfClass:[UITabBarController class]]) { | ||
[[self dotIndicatorPresenter] apply:self.boundViewController:options.bottomTab.dotIndicator]; | ||
} | ||
|
||
if (options.bottomTab.hasValue) { | ||
[self updateTabBarItem:self.boundViewController.tabBarItem bottomTabOptions:withDefault.bottomTab]; | ||
} | ||
} | ||
|
||
- (void)updateTabBarItem:(UITabBarItem *)tabItem bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions { | ||
self.boundViewController.tabBarItem = [RNNTabBarItemCreator updateTabBarItem:self.boundViewController.tabBarItem bottomTabOptions:bottomTabOptions]; | ||
} | ||
|
||
- (void)applyDotIndicator:(UIViewController *)child { | ||
[_dotIndicatorPresenter apply:child:[child resolveOptions].bottomTab.dotIndicator]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "BottomTabPresenter.h" | ||
|
||
@interface BottomTabPresenterCreator : NSObject | ||
|
||
+ (BottomTabPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import "BottomTabPresenterCreator.h" | ||
#import "BottomTabAppearancePresenter.h" | ||
|
||
@implementation BottomTabPresenterCreator | ||
|
||
+ (BottomTabPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { | ||
if (@available(iOS 13.0, *)) { | ||
return [[BottomTabAppearancePresenter alloc] initWithDefaultOptions:defaultOptions]; | ||
} else { | ||
return [[BottomTabPresenter alloc] initWithDefaultOptions:defaultOptions]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import "RNNBottomTabsPresenter.h" | ||
|
||
API_AVAILABLE(ios(13.0)) | ||
@interface BottomTabsAppearancePresenter : RNNBottomTabsPresenter | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import "BottomTabsAppearancePresenter.h" | ||
|
||
@implementation BottomTabsAppearancePresenter | ||
|
||
- (void)applyOptionsOnInit:(RNNNavigationOptions *)options { | ||
[super applyOptionsOnInit:options]; | ||
UITabBarController *bottomTabs = self.tabBarController; | ||
bottomTabs.tabBar.standardAppearance = [UITabBarAppearance new]; | ||
} | ||
|
||
- (void)setTabBarBackgroundColor:(UIColor *)backgroundColor { | ||
UITabBarController *bottomTabs = self.tabBarController; | ||
for (UIViewController* childViewController in bottomTabs.childViewControllers) { | ||
childViewController.tabBarItem.standardAppearance.backgroundColor = backgroundColor; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "RNNBottomTabsPresenter.h" | ||
|
||
@interface BottomTabsPresenterCreator : NSObject | ||
|
||
+ (RNNBottomTabsPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import "BottomTabsPresenterCreator.h" | ||
#import "BottomTabsAppearancePresenter.h" | ||
|
||
@implementation BottomTabsPresenterCreator | ||
|
||
+ (RNNBottomTabsPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { | ||
if (@available(iOS 13.0, *)) { | ||
return [[BottomTabsAppearancePresenter alloc] initWithDefaultOptions:defaultOptions]; | ||
} else { | ||
return [[RNNBottomTabsPresenter alloc] initWithDefaultOptions:defaultOptions]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
#import "RNNBasePresenter.h" | ||
|
||
@interface RNNBottomTabsPresenter : RNNBasePresenter | ||
|
||
- (void)applyDotIndicator; | ||
|
||
- (void)setTabBarBackgroundColor:(UIColor *)backgroundColor; | ||
|
||
- (UITabBarController *)tabBarController; | ||
|
||
- (UITabBar *)tabBar; | ||
|
||
@end |
Oops, something went wrong.