Browse Source

Fixes bottomTabs visibility issues - #4071 #4161

yogevbd 6 years ago
parent
commit
7a75a2d7b3

+ 0
- 8
lib/ios/RNNRootViewController.m View File

263
 	return self.optionsWithDefault.layout.supportedOrientations;
263
 	return self.optionsWithDefault.layout.supportedOrientations;
264
 }
264
 }
265
 
265
 
266
-- (BOOL)hidesBottomBarWhenPushed
267
-{
268
-	if (self.optionsWithDefault.bottomTabs.visible.hasValue) {
269
-		return !self.optionsWithDefault.bottomTabs.visible.get;
270
-	}
271
-	return NO;
272
-}
273
-
274
 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
266
 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
275
 	RNNRootViewController* vc =  (RNNRootViewController*)viewController;
267
 	RNNRootViewController* vc =  (RNNRootViewController*)viewController;
276
 	if (![[vc.optionsWithDefault.topBar.backButton.transition getWithDefaultValue:@""] isEqualToString:@"custom"]){
268
 	if (![[vc.optionsWithDefault.topBar.backButton.transition getWithDefaultValue:@""] isEqualToString:@"custom"]){

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

15
 	[tabBarController rnn_setTabBarTranslucent:[options.bottomTabs.translucent getWithDefaultValue:YES]];
15
 	[tabBarController rnn_setTabBarTranslucent:[options.bottomTabs.translucent getWithDefaultValue:YES]];
16
 	[tabBarController rnn_setTabBarHideShadow:[options.bottomTabs.hideShadow getWithDefaultValue:NO]];
16
 	[tabBarController rnn_setTabBarHideShadow:[options.bottomTabs.hideShadow getWithDefaultValue:NO]];
17
 	[tabBarController rnn_setTabBarStyle:[RCTConvert UIBarStyle:[options.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
17
 	[tabBarController rnn_setTabBarStyle:[RCTConvert UIBarStyle:[options.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
18
+	[tabBarController rnn_setTabBarVisible:[options.bottomTabs.visible getWithDefaultValue:YES]];
18
 }
19
 }
19
 
20
 
20
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
21
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
51
 	if (options.bottomTabs.hideShadow.hasValue) {
52
 	if (options.bottomTabs.hideShadow.hasValue) {
52
 		[tabBarController rnn_setTabBarHideShadow:options.bottomTabs.hideShadow.get];
53
 		[tabBarController rnn_setTabBarHideShadow:options.bottomTabs.hideShadow.get];
53
 	}
54
 	}
55
+	
56
+	if (options.bottomTabs.visible.hasValue) {
57
+		[tabBarController rnn_setTabBarVisible:options.bottomTabs.visible.get];
58
+	}
54
 }
59
 }
55
 
60
 
56
 @end
61
 @end

+ 0
- 8
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

509
 	XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
509
 	XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
510
 }
510
 }
511
 
511
 
512
-
513
-- (void)testTabBarHidden_true {
514
-	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
515
-	[self.uut viewWillAppear:false];
516
-
517
-	XCTAssertTrue([self.uut hidesBottomBarWhenPushed]);
518
-}
519
-
520
 - (void)testTabBarHidden_false {
512
 - (void)testTabBarHidden_false {
521
 	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(1)];
513
 	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(1)];
522
 	[self.uut viewWillAppear:false];
514
 	[self.uut viewWillAppear:false];

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

28
 	[[self.bindedViewController expect] rnn_setTabBarTranslucent:YES];
28
 	[[self.bindedViewController expect] rnn_setTabBarTranslucent:YES];
29
 	[[self.bindedViewController expect] rnn_setTabBarHideShadow:NO];
29
 	[[self.bindedViewController expect] rnn_setTabBarHideShadow:NO];
30
     [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
30
     [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
31
+	[[self.bindedViewController expect] rnn_setTabBarVisible:YES];
31
 	[self.uut applyOptions:emptyOptions];
32
 	[self.uut applyOptions:emptyOptions];
32
 	[self.bindedViewController verify];
33
 	[self.bindedViewController verify];
33
 }
34
 }
38
 	initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
39
 	initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
39
 	initialOptions.bottomTabs.translucent = [[Bool alloc] initWithValue:@(0)];
40
 	initialOptions.bottomTabs.translucent = [[Bool alloc] initWithValue:@(0)];
40
 	initialOptions.bottomTabs.hideShadow = [[Bool alloc] initWithValue:@(1)];
41
 	initialOptions.bottomTabs.hideShadow = [[Bool alloc] initWithValue:@(1)];
42
+	initialOptions.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
41
 	initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
43
 	initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
42
 	
44
 	
43
 	[[self.bindedViewController expect] rnn_setTabBarTestID:@"testID"];
45
 	[[self.bindedViewController expect] rnn_setTabBarTestID:@"testID"];
45
 	[[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
47
 	[[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
46
 	[[self.bindedViewController expect] rnn_setTabBarHideShadow:YES];
48
 	[[self.bindedViewController expect] rnn_setTabBarHideShadow:YES];
47
 	[[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
49
 	[[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
50
+	[[self.bindedViewController expect] rnn_setTabBarVisible:NO];
48
 	
51
 	
49
 	[self.uut applyOptions:initialOptions];
52
 	[self.uut applyOptions:initialOptions];
50
 	[self.bindedViewController verify];
53
 	[self.bindedViewController verify];

+ 2
- 0
lib/ios/UITabBarController+RNNOptions.h View File

16
 
16
 
17
 - (void)rnn_setTabBarHideShadow:(BOOL)hideShadow;
17
 - (void)rnn_setTabBarHideShadow:(BOOL)hideShadow;
18
 
18
 
19
+- (void)rnn_setTabBarVisible:(BOOL)visible;
20
+
19
 @end
21
 @end

+ 4
- 0
lib/ios/UITabBarController+RNNOptions.m View File

31
 	self.tabBar.clipsToBounds = hideShadow;
31
 	self.tabBar.clipsToBounds = hideShadow;
32
 }
32
 }
33
 
33
 
34
+- (void)rnn_setTabBarVisible:(BOOL)visible {
35
+	self.tabBar.hidden = !visible;
36
+}
37
+
34
 @end
38
 @end