Browse Source

Fixes bottomTabs initial options - #4148

yogevbd 6 years ago
parent
commit
d6a4314280

+ 4
- 0
lib/ios/RNNTabBarPresenter.m View File

@@ -11,6 +11,10 @@
11 11
 	UITabBarController* tabBarController = self.bindedViewController;
12 12
 	
13 13
 	[tabBarController rnn_setTabBarTestID:[options.bottomTabs.testID getWithDefaultValue:nil]];
14
+	[tabBarController rnn_setTabBarBackgroundColor:[options.bottomTabs.backgroundColor getWithDefaultValue:nil]];
15
+	[tabBarController rnn_setTabBarTranslucent:[options.bottomTabs.translucent getWithDefaultValue:YES]];
16
+	[tabBarController rnn_setTabBarHideShadow:[options.bottomTabs.hideShadow getWithDefaultValue:NO]];
17
+	[tabBarController rnn_setTabBarStyle:[RCTConvert UIBarStyle:[options.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
14 18
 }
15 19
 
16 20
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {

+ 4
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

@@ -101,6 +101,7 @@
101 101
 		502CB46F20CD1DDA0019B2FE /* RNNBackButtonOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 502CB46D20CD1DDA0019B2FE /* RNNBackButtonOptions.m */; };
102 102
 		502F0E142178CF8200367CC3 /* UIViewController+RNNOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 502F0E132178CF8200367CC3 /* UIViewController+RNNOptionsTest.m */; };
103 103
 		502F0E162178D09600367CC3 /* RNNBottomTabPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 502F0E152178D09600367CC3 /* RNNBottomTabPresenterTest.m */; };
104
+		502F0E182179C39900367CC3 /* RNNTabBarPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */; };
104 105
 		5038A374216CDDB6009280BC /* UIViewController+SideMenuController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5038A372216CDDB6009280BC /* UIViewController+SideMenuController.h */; };
105 106
 		5038A375216CDDB6009280BC /* UIViewController+SideMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5038A373216CDDB6009280BC /* UIViewController+SideMenuController.m */; };
106 107
 		5038A377216CF252009280BC /* UITabBarController+RNNOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5038A376216CF252009280BC /* UITabBarController+RNNOptionsTest.m */; };
@@ -419,6 +420,7 @@
419 420
 		502CB46D20CD1DDA0019B2FE /* RNNBackButtonOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBackButtonOptions.m; sourceTree = "<group>"; };
420 421
 		502F0E132178CF8200367CC3 /* UIViewController+RNNOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+RNNOptionsTest.m"; sourceTree = "<group>"; };
421 422
 		502F0E152178D09600367CC3 /* RNNBottomTabPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBottomTabPresenterTest.m; sourceTree = "<group>"; };
423
+		502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabBarPresenterTest.m; sourceTree = "<group>"; };
422 424
 		5038A372216CDDB6009280BC /* UIViewController+SideMenuController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIViewController+SideMenuController.h"; sourceTree = "<group>"; };
423 425
 		5038A373216CDDB6009280BC /* UIViewController+SideMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+SideMenuController.m"; sourceTree = "<group>"; };
424 426
 		5038A376216CF252009280BC /* UITabBarController+RNNOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITabBarController+RNNOptionsTest.m"; sourceTree = "<group>"; };
@@ -1001,6 +1003,7 @@
1001 1003
 				506F630C216A599300AD0D0A /* RNNTabBarControllerTest.m */,
1002 1004
 				506F630E216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m */,
1003 1005
 				509B258E2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m */,
1006
+				502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */,
1004 1007
 				502F0E152178D09600367CC3 /* RNNBottomTabPresenterTest.m */,
1005 1008
 				5038A378216D01F6009280BC /* RNNBottomTabOptionsTest.m */,
1006 1009
 				7B49FEBF1E95090800DEB3EA /* Info.plist */,
@@ -1367,6 +1370,7 @@
1367 1370
 				E83BAD7C1F27643000A9F3DD /* RNNTestRootViewCreator.m in Sources */,
1368 1371
 				502F0E162178D09600367CC3 /* RNNBottomTabPresenterTest.m in Sources */,
1369 1372
 				504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */,
1373
+				502F0E182179C39900367CC3 /* RNNTabBarPresenterTest.m in Sources */,
1370 1374
 				506F630F216A5AD700AD0D0A /* RNNViewControllerPresenterTest.m in Sources */,
1371 1375
 				7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */,
1372 1376
 				5038A379216D01F6009280BC /* RNNBottomTabOptionsTest.m in Sources */,

+ 53
- 0
lib/ios/ReactNativeNavigationTests/RNNTabBarPresenterTest.m View File

@@ -0,0 +1,53 @@
1
+#import <XCTest/XCTest.h>
2
+#import <OCMock/OCMock.h>
3
+#import "RNNTabBarPresenter.h"
4
+#import "UITabBarController+RNNOptions.h"
5
+
6
+@interface RNNTabBarPresenterTest : XCTestCase
7
+
8
+@property (nonatomic, strong) RNNTabBarPresenter *uut;
9
+@property (nonatomic, strong) RNNNavigationOptions *options;
10
+@property (nonatomic, strong) id bindedViewController;
11
+
12
+@end
13
+
14
+@implementation RNNTabBarPresenterTest
15
+
16
+- (void)setUp {
17
+    [super setUp];
18
+	self.uut = [[RNNTabBarPresenter alloc] init];
19
+	self.bindedViewController = [OCMockObject partialMockForObject:[UITabBarController new]];
20
+	[self.uut bindViewController:self.bindedViewController];
21
+	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
+}
23
+
24
+- (void)testApplyOptions_shouldSetDefaultEmptyOptions {
25
+	RNNNavigationOptions* emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
26
+	[[self.bindedViewController expect] rnn_setTabBarTestID:nil];
27
+	[[self.bindedViewController expect] rnn_setTabBarBackgroundColor:nil];
28
+	[[self.bindedViewController expect] rnn_setTabBarTranslucent:YES];
29
+	[[self.bindedViewController expect] rnn_setTabBarHideShadow:NO];
30
+    [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
31
+	[self.uut applyOptions:emptyOptions];
32
+	[self.bindedViewController verify];
33
+}
34
+
35
+- (void)testApplyOptions_shouldSetInitialOptions {
36
+	RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
37
+	initialOptions.bottomTabs.testID = [[Text alloc] initWithValue:@"testID"];
38
+	initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
39
+	initialOptions.bottomTabs.translucent = [[Bool alloc] initWithValue:@(0)];
40
+	initialOptions.bottomTabs.hideShadow = [[Bool alloc] initWithValue:@(1)];
41
+	initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
42
+	
43
+	[[self.bindedViewController expect] rnn_setTabBarTestID:@"testID"];
44
+	[[self.bindedViewController expect] rnn_setTabBarBackgroundColor:[UIColor redColor]];
45
+	[[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
46
+	[[self.bindedViewController expect] rnn_setTabBarHideShadow:YES];
47
+	[[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
48
+	
49
+	[self.uut applyOptions:initialOptions];
50
+	[self.bindedViewController verify];
51
+}
52
+
53
+@end