Parcourir la source

Fix bottomTabs.translucent option (#6025)

* Fix translucent bottomTabs

* Remove unnecessary safeAreaView from Root component

* Add bottomTabsPresenter base class

* Revert Root.js

* DrawBehind when largeTitle is visible

Co-authored-by: Guy Carmeli <guyca@users.noreply.github.com>
Yogev Ben David il y a 5 ans
Parent
révision
6edbbf512f
No account linked to committer's email address

+ 2
- 2
lib/ios/BottomTabsAppearancePresenter.h Voir le fichier

1
-#import "RNNBottomTabsPresenter.h"
1
+#import "BottomTabsBasePresenter.h"
2
 
2
 
3
 API_AVAILABLE(ios(13.0))
3
 API_AVAILABLE(ios(13.0))
4
-@interface BottomTabsAppearancePresenter : RNNBottomTabsPresenter
4
+@interface BottomTabsAppearancePresenter : BottomTabsBasePresenter
5
 
5
 
6
 
6
 
7
 @end
7
 @end

+ 38
- 3
lib/ios/BottomTabsAppearancePresenter.m Voir le fichier

1
 #import "BottomTabsAppearancePresenter.h"
1
 #import "BottomTabsAppearancePresenter.h"
2
+#import "UIColor+RNNUtils.h"
2
 
3
 
3
 @implementation BottomTabsAppearancePresenter
4
 @implementation BottomTabsAppearancePresenter
4
 
5
 
6
+# pragma mark - public
7
+
8
+- (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
9
+    if (translucent) [self setTabBarTranslucent:YES];
10
+    else if (backgroundColor.isTransparent) [self setTabBarTransparentBackground];
11
+    else if (backgroundColor) [self setTabBarBackgroundColor:backgroundColor];
12
+    else [self setTabBarDefaultBackground];
13
+}
14
+
5
 - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
15
 - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
6
-    UITabBarController *bottomTabs = self.tabBarController;
7
-    for (UIViewController* childViewController in bottomTabs.childViewControllers) {
16
+    [self setTabBarOpaqueBackground];
17
+    for (UIViewController* childViewController in self.tabBarController.childViewControllers)
8
         childViewController.tabBarItem.standardAppearance.backgroundColor = backgroundColor;
18
         childViewController.tabBarItem.standardAppearance.backgroundColor = backgroundColor;
9
-    }
19
+}
20
+
21
+- (void)setTabBarTranslucent:(BOOL)translucent {
22
+    if (translucent) [self setTabBarTranslucentBackground];
23
+    else [self setTabBarOpaqueBackground];
24
+}
25
+
26
+# pragma mark - private
27
+
28
+- (void)setTabBarDefaultBackground {
29
+    [self setTabBarOpaqueBackground];
30
+}
31
+
32
+- (void)setTabBarTranslucentBackground {
33
+    for (UIViewController* childViewController in self.tabBarController.childViewControllers)
34
+        [childViewController.tabBarItem.standardAppearance configureWithDefaultBackground];
35
+}
36
+
37
+- (void)setTabBarTransparentBackground {
38
+    for (UIViewController* childViewController in self.tabBarController.childViewControllers)
39
+        [childViewController.tabBarItem.standardAppearance configureWithTransparentBackground];
40
+}
41
+
42
+- (void)setTabBarOpaqueBackground {
43
+    for (UIViewController* childViewController in self.tabBarController.childViewControllers)
44
+        [childViewController.tabBarItem.standardAppearance configureWithOpaqueBackground];
10
 }
45
 }
11
 
46
 
12
 @end
47
 @end

+ 20
- 0
lib/ios/BottomTabsBasePresenter.h Voir le fichier

1
+#import <Foundation/Foundation.h>
2
+#import "RNNBasePresenter.h"
3
+#import "UITabBarController+RNNOptions.h"
4
+#import "UIViewController+LayoutProtocol.h"
5
+#import "UIViewController+Utils.h"
6
+#import "UIColor+RNNUtils.h"
7
+
8
+@interface BottomTabsBasePresenter : RNNBasePresenter
9
+
10
+- (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent;
11
+
12
+- (void)setTabBarBackgroundColor:(UIColor *)backgroundColor;
13
+
14
+- (void)setTabBarTranslucent:(BOOL)translucent;
15
+
16
+- (UITabBarController *)tabBarController;
17
+
18
+- (UITabBar *)tabBar;
19
+
20
+@end

+ 95
- 0
lib/ios/BottomTabsBasePresenter.m Voir le fichier

1
+#import "BottomTabsBasePresenter.h"
2
+
3
+@implementation BottomTabsBasePresenter
4
+
5
+- (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
6
+    [super applyOptionsOnInit:options];
7
+    UITabBarController *bottomTabs = self.tabBarController;
8
+    RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
9
+    [bottomTabs setCurrentTabIndex:[withDefault.bottomTabs.currentTabIndex getWithDefaultValue:0]];
10
+    if ([[withDefault.bottomTabs.titleDisplayMode getWithDefaultValue:@"alwaysShow"] isEqualToString:@"alwaysHide"]) {
11
+        [bottomTabs centerTabItems];
12
+    }
13
+}
14
+
15
+- (void)applyOptions:(RNNNavigationOptions *)options {
16
+    UITabBarController *bottomTabs = self.tabBarController;
17
+    RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
18
+
19
+    [bottomTabs setTabBarTestID:[withDefault.bottomTabs.testID getWithDefaultValue:nil]];
20
+    [bottomTabs setTabBarVisible:[withDefault.bottomTabs.visible getWithDefaultValue:YES] animated:[withDefault.bottomTabs.animate getWithDefaultValue:NO]];
21
+    
22
+    [bottomTabs.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
23
+    [self applyBackgroundColor:[withDefault.bottomTabs.backgroundColor getWithDefaultValue:nil] translucent:[withDefault.bottomTabs.translucent getWithDefaultValue:NO]];
24
+    [bottomTabs setTabBarHideShadow:[withDefault.bottomTabs.hideShadow getWithDefaultValue:NO]];
25
+    [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:[withDefault.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
26
+}
27
+
28
+- (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
29
+    [super mergeOptions:options resolvedOptions:currentOptions];
30
+    UITabBarController *bottomTabs = self.tabBarController;
31
+
32
+    if (options.bottomTabs.currentTabIndex.hasValue) {
33
+        [bottomTabs setCurrentTabIndex:options.bottomTabs.currentTabIndex.get];
34
+        [options.bottomTabs.currentTabIndex consume];
35
+    }
36
+
37
+    if (options.bottomTabs.currentTabId.hasValue) {
38
+        [bottomTabs setCurrentTabID:options.bottomTabs.currentTabId.get];
39
+        [options.bottomTabs.currentTabId consume];
40
+    }
41
+
42
+    if (options.bottomTabs.testID.hasValue) {
43
+        [bottomTabs setTabBarTestID:options.bottomTabs.testID.get];
44
+    }
45
+
46
+    if (options.bottomTabs.backgroundColor.hasValue) {
47
+        [self setTabBarBackgroundColor:options.bottomTabs.backgroundColor.get];
48
+    }
49
+
50
+    if (options.bottomTabs.barStyle.hasValue) {
51
+        [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:options.bottomTabs.barStyle.get]];
52
+    }
53
+
54
+    if (options.bottomTabs.translucent.hasValue) {
55
+        [bottomTabs setTabBarTranslucent:options.bottomTabs.translucent.get];
56
+    }
57
+
58
+    if (options.bottomTabs.hideShadow.hasValue) {
59
+        [bottomTabs setTabBarHideShadow:options.bottomTabs.hideShadow.get];
60
+    }
61
+
62
+    if (options.bottomTabs.visible.hasValue) {
63
+        if (options.bottomTabs.animate.hasValue) {
64
+            [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
65
+        } else {
66
+            [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:NO];
67
+        }
68
+    }
69
+    
70
+    if (options.layout.backgroundColor.hasValue) {
71
+        [bottomTabs.view setBackgroundColor:options.layout.backgroundColor.get];
72
+    }
73
+}
74
+
75
+- (UITabBarController *)tabBarController {
76
+    return (UITabBarController *)self.boundViewController;
77
+}
78
+
79
+- (UITabBar *)tabBar {
80
+    return self.tabBarController.tabBar;
81
+}
82
+
83
+- (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
84
+    
85
+}
86
+
87
+- (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
88
+    
89
+}
90
+
91
+- (void)setTabBarTranslucent:(BOOL)translucent {
92
+    
93
+}
94
+
95
+@end

+ 2
- 0
lib/ios/RNNBottomTabsOptions.h Voir le fichier

21
 @property (nonatomic, strong) Text* titleDisplayMode;
21
 @property (nonatomic, strong) Text* titleDisplayMode;
22
 @property (nonatomic, strong) BottomTabsAttachMode* tabsAttachMode;
22
 @property (nonatomic, strong) BottomTabsAttachMode* tabsAttachMode;
23
 
23
 
24
+- (BOOL)shouldDrawBehind;
25
+
24
 @end
26
 @end

+ 6
- 0
lib/ios/RNNBottomTabsOptions.m Voir le fichier

25
 	return self;
25
 	return self;
26
 }
26
 }
27
 
27
 
28
+- (BOOL)shouldDrawBehind {
29
+    return [self.drawBehind getWithDefaultValue:NO] ||
30
+    [self.translucent getWithDefaultValue:NO] ||
31
+    ![self.visible getWithDefaultValue:YES];
32
+}
33
+
28
 @end
34
 @end

+ 2
- 8
lib/ios/RNNBottomTabsPresenter.h Voir le fichier

1
-#import "RNNBasePresenter.h"
1
+#import "BottomTabsBasePresenter.h"
2
 
2
 
3
-@interface RNNBottomTabsPresenter : RNNBasePresenter
4
-
5
-- (void)setTabBarBackgroundColor:(UIColor *)backgroundColor;
6
-
7
-- (UITabBarController *)tabBarController;
8
-
9
-- (UITabBar *)tabBar;
3
+@interface RNNBottomTabsPresenter : BottomTabsBasePresenter
10
 
4
 
11
 @end
5
 @end

+ 5
- 78
lib/ios/RNNBottomTabsPresenter.m Voir le fichier

1
 #import "RNNBottomTabsPresenter.h"
1
 #import "RNNBottomTabsPresenter.h"
2
-#import "UITabBarController+RNNOptions.h"
3
-#import "UIViewController+LayoutProtocol.h"
4
-#import "UIViewController+Utils.h"
5
 
2
 
6
 @implementation RNNBottomTabsPresenter
3
 @implementation RNNBottomTabsPresenter
7
 
4
 
8
-- (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
9
-    [super applyOptionsOnInit:options];
10
-    UITabBarController *bottomTabs = self.tabBarController;
11
-    RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
12
-    [bottomTabs setCurrentTabIndex:[withDefault.bottomTabs.currentTabIndex getWithDefaultValue:0]];
13
-	if ([[withDefault.bottomTabs.titleDisplayMode getWithDefaultValue:@"alwaysShow"] isEqualToString:@"alwaysHide"]) {
14
-		[bottomTabs centerTabItems];
15
-	}
16
-}
17
-
18
-- (void)applyOptions:(RNNNavigationOptions *)options {
19
-    UITabBarController *bottomTabs = self.tabBarController;
20
-    RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
21
-
22
-    [bottomTabs setTabBarTestID:[withDefault.bottomTabs.testID getWithDefaultValue:nil]];
23
-    [bottomTabs setTabBarVisible:[withDefault.bottomTabs.visible getWithDefaultValue:YES] animated:[withDefault.bottomTabs.animate getWithDefaultValue:NO]];
24
-    
25
-    [bottomTabs.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
26
-    [self setTabBarBackgroundColor:[withDefault.bottomTabs.backgroundColor getWithDefaultValue:UIColor.whiteColor]];
27
-    [bottomTabs setTabBarTranslucent:[withDefault.bottomTabs.translucent getWithDefaultValue:NO]];
28
-    [bottomTabs setTabBarHideShadow:[withDefault.bottomTabs.hideShadow getWithDefaultValue:NO]];
29
-    [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:[withDefault.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
30
-}
31
-
32
-- (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
33
-    [super mergeOptions:options resolvedOptions:currentOptions];
34
-    UITabBarController *bottomTabs = self.tabBarController;
35
-
36
-    if (options.bottomTabs.currentTabIndex.hasValue) {
37
-        [bottomTabs setCurrentTabIndex:options.bottomTabs.currentTabIndex.get];
38
-        [options.bottomTabs.currentTabIndex consume];
39
-    }
40
-
41
-    if (options.bottomTabs.currentTabId.hasValue) {
42
-        [bottomTabs setCurrentTabID:options.bottomTabs.currentTabId.get];
43
-        [options.bottomTabs.currentTabId consume];
44
-    }
45
-
46
-    if (options.bottomTabs.testID.hasValue) {
47
-        [bottomTabs setTabBarTestID:options.bottomTabs.testID.get];
48
-    }
49
-
50
-    if (options.bottomTabs.backgroundColor.hasValue) {
51
-        [self setTabBarBackgroundColor:options.bottomTabs.backgroundColor.get];
52
-    }
53
-
54
-    if (options.bottomTabs.barStyle.hasValue) {
55
-        [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:options.bottomTabs.barStyle.get]];
56
-    }
57
-
58
-    if (options.bottomTabs.translucent.hasValue) {
59
-        [bottomTabs setTabBarTranslucent:options.bottomTabs.translucent.get];
60
-    }
61
-
62
-    if (options.bottomTabs.hideShadow.hasValue) {
63
-        [bottomTabs setTabBarHideShadow:options.bottomTabs.hideShadow.get];
64
-    }
65
-
66
-    if (options.bottomTabs.visible.hasValue) {
67
-        if (options.bottomTabs.animate.hasValue) {
68
-            [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
69
-        } else {
70
-            [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:NO];
71
-        }
72
-    }
73
-    
74
-    if (options.layout.backgroundColor.hasValue) {
75
-        [bottomTabs.view setBackgroundColor:options.layout.backgroundColor.get];
76
-    }
5
+- (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
6
+    [self setTabBarTranslucent:translucent];
7
+    [self setTabBarBackgroundColor:backgroundColor];
77
 }
8
 }
78
 
9
 
79
 - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
10
 - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
80
     self.tabBar.barTintColor = backgroundColor;
11
     self.tabBar.barTintColor = backgroundColor;
81
 }
12
 }
82
 
13
 
83
-- (UITabBarController *)tabBarController {
84
-    return (UITabBarController *)self.boundViewController;
85
-}
86
-
87
-- (UITabBar *)tabBar {
88
-    return self.tabBarController.tabBar;
14
+- (void)setTabBarTranslucent:(BOOL)translucent {
15
+    self.tabBar.translucent = translucent;
89
 }
16
 }
90
 
17
 
91
 @end
18
 @end

+ 9
- 9
lib/ios/RNNComponentPresenter.m Voir le fichier

77
 }
77
 }
78
 
78
 
79
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
79
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
80
-	[super applyOptionsOnInit:options];
81
-	
82
-	UIViewController* viewController = self.boundViewController;
83
-	RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
80
+    [super applyOptionsOnInit:options];
84
     
81
     
85
-	[viewController setDrawBehindTopBar:[withDefault.topBar.drawBehind getWithDefaultValue:NO]];
86
-    [viewController setDrawBehindTabBar:[withDefault.bottomTabs.drawBehind getWithDefaultValue:NO] || ![withDefault.bottomTabs.visible getWithDefaultValue:YES]];
82
+    UIViewController* viewController = self.boundViewController;
83
+    RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
87
     
84
     
88
-	if ((withDefault.topBar.leftButtons || withDefault.topBar.rightButtons)) {
89
-		[_navigationButtons applyLeftButtons:withDefault.topBar.leftButtons rightButtons:withDefault.topBar.rightButtons defaultLeftButtonStyle:withDefault.topBar.leftButtonStyle defaultRightButtonStyle:withDefault.topBar.rightButtonStyle];
90
-	}
85
+    [viewController setDrawBehindTopBar:[withDefault.topBar shouldDrawBehind]];
86
+    [viewController setDrawBehindTabBar:[withDefault.bottomTabs shouldDrawBehind]];
87
+    
88
+    if ((withDefault.topBar.leftButtons || withDefault.topBar.rightButtons)) {
89
+        [_navigationButtons applyLeftButtons:withDefault.topBar.leftButtons rightButtons:withDefault.topBar.rightButtons defaultLeftButtonStyle:withDefault.topBar.leftButtonStyle defaultRightButtonStyle:withDefault.topBar.rightButtonStyle];
90
+    }
91
 }
91
 }
92
 
92
 
93
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
93
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {

+ 2
- 0
lib/ios/RNNTopBarOptions.h Voir le fichier

35
 @property (nonatomic, strong) RNNButtonOptions* leftButtonStyle;
35
 @property (nonatomic, strong) RNNButtonOptions* leftButtonStyle;
36
 @property (nonatomic, strong) RNNButtonOptions* rightButtonStyle;
36
 @property (nonatomic, strong) RNNButtonOptions* rightButtonStyle;
37
 
37
 
38
+- (BOOL)shouldDrawBehind;
39
+
38
 @end
40
 @end

+ 6
- 0
lib/ios/RNNTopBarOptions.m Voir le fichier

60
 	return self;
60
 	return self;
61
 }
61
 }
62
 
62
 
63
+- (BOOL)shouldDrawBehind {
64
+    return [self.drawBehind getWithDefaultValue:NO] ||
65
+    [self.background.translucent getWithDefaultValue:NO] ||
66
+    ![self.visible getWithDefaultValue:YES] ||
67
+    [self.largeTitle.visible getWithDefaultValue:NO];
68
+}
63
 
69
 
64
 @end
70
 @end

+ 8
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj Voir le fichier

167
 		503A8A2623BD04410094D1C4 /* ElementTransitionsCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 503A8A2423BD04410094D1C4 /* ElementTransitionsCreator.m */; };
167
 		503A8A2623BD04410094D1C4 /* ElementTransitionsCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 503A8A2423BD04410094D1C4 /* ElementTransitionsCreator.m */; };
168
 		50415CBA20553B8E00BB682E /* RNNScreenTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50415CB820553B8E00BB682E /* RNNScreenTransition.h */; };
168
 		50415CBA20553B8E00BB682E /* RNNScreenTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50415CB820553B8E00BB682E /* RNNScreenTransition.h */; };
169
 		50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50415CB920553B8E00BB682E /* RNNScreenTransition.m */; };
169
 		50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50415CB920553B8E00BB682E /* RNNScreenTransition.m */; };
170
+		5041DC3E2417BBBA0033312F /* BottomTabsBasePresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5041DC3C2417BBBA0033312F /* BottomTabsBasePresenter.h */; };
171
+		5041DC3F2417BBBA0033312F /* BottomTabsBasePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 5041DC3D2417BBBA0033312F /* BottomTabsBasePresenter.m */; };
170
 		50451D052042DAEB00695F00 /* RNNPushAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D032042DAEB00695F00 /* RNNPushAnimation.h */; };
172
 		50451D052042DAEB00695F00 /* RNNPushAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D032042DAEB00695F00 /* RNNPushAnimation.h */; };
171
 		50451D062042DAEB00695F00 /* RNNPushAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D042042DAEB00695F00 /* RNNPushAnimation.m */; };
173
 		50451D062042DAEB00695F00 /* RNNPushAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D042042DAEB00695F00 /* RNNPushAnimation.m */; };
172
 		50451D092042E20600695F00 /* RNNAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D072042E20600695F00 /* RNNAnimationsOptions.h */; };
174
 		50451D092042E20600695F00 /* RNNAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D072042E20600695F00 /* RNNAnimationsOptions.h */; };
653
 		503A8A2423BD04410094D1C4 /* ElementTransitionsCreator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ElementTransitionsCreator.m; sourceTree = "<group>"; };
655
 		503A8A2423BD04410094D1C4 /* ElementTransitionsCreator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ElementTransitionsCreator.m; sourceTree = "<group>"; };
654
 		50415CB820553B8E00BB682E /* RNNScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNScreenTransition.h; sourceTree = "<group>"; };
656
 		50415CB820553B8E00BB682E /* RNNScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNScreenTransition.h; sourceTree = "<group>"; };
655
 		50415CB920553B8E00BB682E /* RNNScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNScreenTransition.m; sourceTree = "<group>"; };
657
 		50415CB920553B8E00BB682E /* RNNScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNScreenTransition.m; sourceTree = "<group>"; };
658
+		5041DC3C2417BBBA0033312F /* BottomTabsBasePresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BottomTabsBasePresenter.h; sourceTree = "<group>"; };
659
+		5041DC3D2417BBBA0033312F /* BottomTabsBasePresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BottomTabsBasePresenter.m; sourceTree = "<group>"; };
656
 		50451D032042DAEB00695F00 /* RNNPushAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNPushAnimation.h; sourceTree = "<group>"; };
660
 		50451D032042DAEB00695F00 /* RNNPushAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNPushAnimation.h; sourceTree = "<group>"; };
657
 		50451D042042DAEB00695F00 /* RNNPushAnimation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNPushAnimation.m; sourceTree = "<group>"; };
661
 		50451D042042DAEB00695F00 /* RNNPushAnimation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNPushAnimation.m; sourceTree = "<group>"; };
658
 		50451D072042E20600695F00 /* RNNAnimationsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNAnimationsOptions.h; sourceTree = "<group>"; };
662
 		50451D072042E20600695F00 /* RNNAnimationsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNAnimationsOptions.h; sourceTree = "<group>"; };
1395
 				5022EDB82405226800852BA6 /* BottomTabAppearancePresenter.m */,
1399
 				5022EDB82405226800852BA6 /* BottomTabAppearancePresenter.m */,
1396
 				5022EDC324054C6100852BA6 /* BottomTabsAppearancePresenter.h */,
1400
 				5022EDC324054C6100852BA6 /* BottomTabsAppearancePresenter.h */,
1397
 				5022EDC424054C6100852BA6 /* BottomTabsAppearancePresenter.m */,
1401
 				5022EDC424054C6100852BA6 /* BottomTabsAppearancePresenter.m */,
1402
+				5041DC3C2417BBBA0033312F /* BottomTabsBasePresenter.h */,
1403
+				5041DC3D2417BBBA0033312F /* BottomTabsBasePresenter.m */,
1398
 				5022EDBB2405237100852BA6 /* BottomTabPresenterCreator.h */,
1404
 				5022EDBB2405237100852BA6 /* BottomTabPresenterCreator.h */,
1399
 				5022EDBC2405237100852BA6 /* BottomTabPresenterCreator.m */,
1405
 				5022EDBC2405237100852BA6 /* BottomTabPresenterCreator.m */,
1400
 				5022EDC724054C8A00852BA6 /* BottomTabsPresenterCreator.h */,
1406
 				5022EDC724054C8A00852BA6 /* BottomTabsPresenterCreator.h */,
1705
 				50E38DDD23A7A306009817F6 /* AnimatedImageView.h in Headers */,
1711
 				50E38DDD23A7A306009817F6 /* AnimatedImageView.h in Headers */,
1706
 				7B4928081E70415400555040 /* RNNCommandsHandler.h in Headers */,
1712
 				7B4928081E70415400555040 /* RNNCommandsHandler.h in Headers */,
1707
 				50495942216F5E5D006D2B81 /* NullBool.h in Headers */,
1713
 				50495942216F5E5D006D2B81 /* NullBool.h in Headers */,
1714
+				5041DC3E2417BBBA0033312F /* BottomTabsBasePresenter.h in Headers */,
1708
 				263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */,
1715
 				263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */,
1709
 				5012241621736667000F5F98 /* Color.h in Headers */,
1716
 				5012241621736667000F5F98 /* Color.h in Headers */,
1710
 				7365071121E4B16F004E020F /* RCTConvert+UIBarButtonSystemItem.h in Headers */,
1717
 				7365071121E4B16F004E020F /* RCTConvert+UIBarButtonSystemItem.h in Headers */,
2199
 				30987D71FB4FEEAC8D8978E8 /* DotIndicatorParser.m in Sources */,
2206
 				30987D71FB4FEEAC8D8978E8 /* DotIndicatorParser.m in Sources */,
2200
 				50CED44E239EA78700C42EE2 /* TopBarAppearancePresenter.m in Sources */,
2207
 				50CED44E239EA78700C42EE2 /* TopBarAppearancePresenter.m in Sources */,
2201
 				30987B23F288EB3A78B7F27C /* RNNDotIndicatorPresenter.m in Sources */,
2208
 				30987B23F288EB3A78B7F27C /* RNNDotIndicatorPresenter.m in Sources */,
2209
+				5041DC3F2417BBBA0033312F /* BottomTabsBasePresenter.m in Sources */,
2202
 				5022EDC224053C9F00852BA6 /* TabBarItemAppearanceCreator.m in Sources */,
2210
 				5022EDC224053C9F00852BA6 /* TabBarItemAppearanceCreator.m in Sources */,
2203
 				507ACB1223F44D1E00829911 /* RNNComponentView.m in Sources */,
2211
 				507ACB1223F44D1E00829911 /* RNNComponentView.m in Sources */,
2204
 				5017D9F3239D2FCB00B74047 /* BottomTabsOnSwitchToTabAttacher.m in Sources */,
2212
 				5017D9F3239D2FCB00B74047 /* BottomTabsOnSwitchToTabAttacher.m in Sources */,

+ 2
- 1
lib/ios/TopBarPresenter.m Voir le fichier

1
 #import "TopBarPresenter.h"
1
 #import "TopBarPresenter.h"
2
 #import "UIImage+tint.h"
2
 #import "UIImage+tint.h"
3
 #import "RNNFontAttributesCreator.h"
3
 #import "RNNFontAttributesCreator.h"
4
+#import "UIColor+RNNUtils.h"
4
 
5
 
5
 @implementation TopBarPresenter
6
 @implementation TopBarPresenter
6
 
7
 
148
 }
149
 }
149
 
150
 
150
 - (BOOL)transparent {
151
 - (BOOL)transparent {
151
-    return (self.backgroundColor && CGColorGetAlpha(self.backgroundColor.CGColor) == 0.0);
152
+    return self.backgroundColor.isTransparent;
152
 }
153
 }
153
 
154
 
154
 @end
155
 @end

+ 2
- 1
lib/ios/Utils/UIColor+RNNUtils.h Voir le fichier

2
 
2
 
3
 @interface UIColor (RNNUtils)
3
 @interface UIColor (RNNUtils)
4
 - (NSString *)toHex;
4
 - (NSString *)toHex;
5
-@end
5
+- (BOOL)isTransparent;
6
+@end

+ 5
- 0
lib/ios/Utils/UIColor+RNNUtils.m Voir le fichier

8
 @implementation UIColor (RNNUtils)
8
 @implementation UIColor (RNNUtils)
9
 
9
 
10
 #pragma mark Public
10
 #pragma mark Public
11
+
12
+- (BOOL)isTransparent {
13
+    return (CGColorGetAlpha(self.CGColor) == 0.0);
14
+}
15
+
11
 - (NSString *)toHex {
16
 - (NSString *)toHex {
12
     const CGFloat *components = CGColorGetComponents([self CGColor]);
17
     const CGFloat *components = CGColorGetComponents([self CGColor]);
13
 
18
 

+ 2
- 4
playground/ios/NavigationIOS12Tests/RNNBottomTabsPresenterTest.m Voir le fichier

25
 - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
25
 - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
26
     RNNNavigationOptions *emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
26
     RNNNavigationOptions *emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
27
     [[self.boundViewController expect] setTabBarTestID:nil];
27
     [[self.boundViewController expect] setTabBarTestID:nil];
28
-    [self.uut setTabBarBackgroundColor:nil];
29
-    [[self.boundViewController expect] setTabBarTranslucent:NO];
28
+	[[(id)self.uut expect] applyBackgroundColor:nil translucent:NO];
30
     [[self.boundViewController expect] setTabBarHideShadow:NO];
29
     [[self.boundViewController expect] setTabBarHideShadow:NO];
31
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
30
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
32
     [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
31
     [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
44
     initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
43
     initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
45
 
44
 
46
     [[self.boundViewController expect] setTabBarTestID:@"testID"];
45
     [[self.boundViewController expect] setTabBarTestID:@"testID"];
47
-    [self.uut setTabBarBackgroundColor:[UIColor redColor]];
48
-    [[self.boundViewController expect] setTabBarTranslucent:NO];
46
+    [[(id)self.uut expect] applyBackgroundColor:nil translucent:[UIColor redColor]];
49
     [[self.boundViewController expect] setTabBarHideShadow:YES];
47
     [[self.boundViewController expect] setTabBarHideShadow:YES];
50
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
48
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
51
     [[self.boundViewController expect] setTabBarVisible:NO animated:NO];
49
     [[self.boundViewController expect] setTabBarVisible:NO animated:NO];

+ 2
- 4
playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.m Voir le fichier

33
 - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
33
 - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
34
     RNNNavigationOptions *emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
34
     RNNNavigationOptions *emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
35
     [[self.boundViewController expect] setTabBarTestID:nil];
35
     [[self.boundViewController expect] setTabBarTestID:nil];
36
-    [self.uut setTabBarBackgroundColor:nil];
37
-    [[self.boundViewController expect] setTabBarTranslucent:NO];
36
+    [[(id)self.uut expect] applyBackgroundColor:nil translucent:NO];
38
     [[self.boundViewController expect] setTabBarHideShadow:NO];
37
     [[self.boundViewController expect] setTabBarHideShadow:NO];
39
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
38
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
40
     [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
39
     [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
52
     initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
51
     initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
53
 
52
 
54
     [[self.boundViewController expect] setTabBarTestID:@"testID"];
53
     [[self.boundViewController expect] setTabBarTestID:@"testID"];
55
-    [self.uut setTabBarBackgroundColor:[UIColor redColor]];
56
-    [[self.boundViewController expect] setTabBarTranslucent:NO];
54
+    [[(id)self.uut expect] applyBackgroundColor:nil translucent:[UIColor redColor]];
57
     [[self.boundViewController expect] setTabBarHideShadow:YES];
55
     [[self.boundViewController expect] setTabBarHideShadow:YES];
58
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
56
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
59
     [[self.boundViewController expect] setTabBarVisible:NO animated:NO];
57
     [[self.boundViewController expect] setTabBarVisible:NO animated:NO];