Sfoglia il codice sorgente

Fixes bottomTabs visibility issues - #4071 #4161

yogevbd 6 anni fa
parent
commit
7a75a2d7b3

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

@@ -263,14 +263,6 @@
263 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 266
 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
275 267
 	RNNRootViewController* vc =  (RNNRootViewController*)viewController;
276 268
 	if (![[vc.optionsWithDefault.topBar.backButton.transition getWithDefaultValue:@""] isEqualToString:@"custom"]){

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

@@ -15,6 +15,7 @@
15 15
 	[tabBarController rnn_setTabBarTranslucent:[options.bottomTabs.translucent getWithDefaultValue:YES]];
16 16
 	[tabBarController rnn_setTabBarHideShadow:[options.bottomTabs.hideShadow getWithDefaultValue:NO]];
17 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 21
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
@@ -51,6 +52,10 @@
51 52
 	if (options.bottomTabs.hideShadow.hasValue) {
52 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 61
 @end

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

@@ -509,14 +509,6 @@
509 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 512
 - (void)testTabBarHidden_false {
521 513
 	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(1)];
522 514
 	[self.uut viewWillAppear:false];

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

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

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

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

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

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