Browse Source

Fix bottomTabs visible false wrong layout (#6095)

* Use viewController hidesBottomBarWhenPushed method for bottomTabs visibility
Yogev Ben David 4 years ago
parent
commit
21cafcdecc
No account linked to committer's email address

+ 0
- 1
lib/ios/BottomTabsBasePresenter.m View File

@@ -17,7 +17,6 @@
17 17
     RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
18 18
 
19 19
     [bottomTabs setTabBarTestID:[withDefault.bottomTabs.testID getWithDefaultValue:nil]];
20
-    [bottomTabs setTabBarVisible:[withDefault.bottomTabs.visible getWithDefaultValue:YES] animated:[withDefault.bottomTabs.animate getWithDefaultValue:NO]];
21 20
     
22 21
     [bottomTabs.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
23 22
     [self applyBackgroundColor:[withDefault.bottomTabs.backgroundColor getWithDefaultValue:nil] translucent:[withDefault.bottomTabs.translucent getWithDefaultValue:NO]];

+ 2
- 0
lib/ios/RNNBasePresenter.h View File

@@ -47,4 +47,6 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
47 47
 
48 48
 - (BOOL)getStatusBarVisibility;
49 49
 
50
+- (BOOL)hidesBottomBarWhenPushed;
51
+
50 52
 @end

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

@@ -119,5 +119,9 @@
119 119
     return NO;
120 120
 }
121 121
 
122
+- (BOOL)hidesBottomBarWhenPushed {
123
+    RNNNavigationOptions *withDefault = [self.boundViewController.topMostViewController.resolveOptions withDefault:self.defaultOptions];
124
+    return ![withDefault.bottomTabs.visible getWithDefaultValue:YES];
125
+}
122 126
 
123 127
 @end

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

@@ -131,5 +131,9 @@
131 131
     return [self.presenter getOrientation];
132 132
 }
133 133
 
134
+- (BOOL)hidesBottomBarWhenPushed {
135
+    return [self.presenter hidesBottomBarWhenPushed];
136
+}
137
+
134 138
 
135 139
 @end

+ 3
- 0
lib/ios/RNNComponentViewController.m View File

@@ -148,5 +148,8 @@
148 148
     return [self.presenter getOrientation];
149 149
 }
150 150
 
151
+- (BOOL)hidesBottomBarWhenPushed {
152
+    return [self.presenter hidesBottomBarWhenPushed];
153
+}
151 154
 
152 155
 @end

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

@@ -48,4 +48,8 @@
48 48
     return [self.presenter getOrientation];
49 49
 }
50 50
 
51
+- (BOOL)hidesBottomBarWhenPushed {
52
+    return [self.presenter hidesBottomBarWhenPushed];
53
+}
54
+
51 55
 @end

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

@@ -57,4 +57,8 @@
57 57
     return [self.presenter getOrientation];
58 58
 }
59 59
 
60
+- (BOOL)hidesBottomBarWhenPushed {
61
+    return [self.presenter hidesBottomBarWhenPushed];
62
+}
63
+
60 64
 @end

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

@@ -173,4 +173,8 @@
173 173
     return [self.presenter getOrientation];
174 174
 }
175 175
 
176
+- (BOOL)hidesBottomBarWhenPushed {
177
+    return [self.presenter hidesBottomBarWhenPushed];
178
+}
179
+
176 180
 @end

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

@@ -31,4 +31,8 @@
31 31
     return [self.presenter getOrientation];
32 32
 }
33 33
 
34
+- (BOOL)hidesBottomBarWhenPushed {
35
+    return [self.presenter hidesBottomBarWhenPushed];
36
+}
37
+
34 38
 @end

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

@@ -72,4 +72,8 @@
72 72
     return [self.presenter getOrientation];
73 73
 }
74 74
 
75
+- (BOOL)hidesBottomBarWhenPushed {
76
+    return [self.presenter hidesBottomBarWhenPushed];
77
+}
78
+
75 79
 @end

+ 0
- 2
playground/ios/NavigationIOS12Tests/RNNBottomTabsPresenterTest.m View File

@@ -28,7 +28,6 @@
28 28
 	[[(id)self.uut expect] applyBackgroundColor:nil translucent:NO];
29 29
     [[self.boundViewController expect] setTabBarHideShadow:NO];
30 30
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
31
-    [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
32 31
     [self.uut applyOptions:emptyOptions];
33 32
     [self.boundViewController verify];
34 33
 }
@@ -46,7 +45,6 @@
46 45
     [[(id)self.uut expect] applyBackgroundColor:nil translucent:[UIColor redColor]];
47 46
     [[self.boundViewController expect] setTabBarHideShadow:YES];
48 47
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
49
-    [[self.boundViewController expect] setTabBarVisible:NO animated:NO];
50 48
 
51 49
     [self.uut applyOptions:initialOptions];
52 50
     [self.boundViewController verify];

+ 39
- 0
playground/ios/NavigationTests/RNNBasePresenterTest.m View File

@@ -84,4 +84,43 @@
84 84
 	XCTAssertTrue(_boundViewController.modalInPresentation);
85 85
 }
86 86
 
87
+- (void)testHidesBottomBarWhenPushed_showsBar {
88
+	_boundViewController.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:NO];
89
+	XCTAssertTrue(_boundViewController.hidesBottomBarWhenPushed);
90
+}
91
+
92
+- (void)testHidesBottomBarWhenPushed_hidesBar {
93
+	_boundViewController.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:YES];
94
+	XCTAssertFalse(_boundViewController.hidesBottomBarWhenPushed);
95
+}
96
+
97
+- (void)testHidesBottomBarWhenPushed_resolveParentShowsBar {
98
+	UINavigationController* nvc = [[UINavigationController alloc] initWithRootViewController:self.boundViewController];
99
+	nvc.options = [RNNNavigationOptions emptyOptions];
100
+	nvc.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:NO];
101
+	XCTAssertTrue(_boundViewController.hidesBottomBarWhenPushed);
102
+}
103
+
104
+- (void)testHidesBottomBarWhenPushed_resolveParentHidesBar {
105
+	UINavigationController* nvc = [[UINavigationController alloc] initWithRootViewController:self.boundViewController];
106
+	nvc.options = [RNNNavigationOptions emptyOptions];
107
+	nvc.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:YES];
108
+	XCTAssertFalse(_boundViewController.hidesBottomBarWhenPushed);
109
+}
110
+
111
+- (void)testHidesBottomBarWhenPushed_resolveChildShowsBarBeforeParent {
112
+	UINavigationController* nvc = [[UINavigationController alloc] initWithRootViewController:self.boundViewController];
113
+	nvc.options = [RNNNavigationOptions emptyOptions];
114
+	nvc.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:NO];
115
+	XCTAssertTrue(_boundViewController.hidesBottomBarWhenPushed);
116
+}
117
+
118
+- (void)testHidesBottomBarWhenPushed_resolveChildHidesBarBeforeParent {
119
+	UINavigationController* nvc = [[UINavigationController alloc] initWithRootViewController:self.boundViewController];
120
+	nvc.options = [RNNNavigationOptions emptyOptions];
121
+	self.boundViewController.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:NO];
122
+	nvc.options.bottomTabs.visible = [[Bool alloc] initWithBOOL:YES];
123
+	XCTAssertTrue(_boundViewController.hidesBottomBarWhenPushed);
124
+}
125
+
87 126
 @end

+ 0
- 2
playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.m View File

@@ -36,7 +36,6 @@
36 36
     [[(id)self.uut expect] applyBackgroundColor:nil translucent:NO];
37 37
     [[self.boundViewController expect] setTabBarHideShadow:NO];
38 38
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleDefault];
39
-    [[self.boundViewController expect] setTabBarVisible:YES animated:NO];
40 39
     [self.uut applyOptions:emptyOptions];
41 40
     [self.boundViewController verify];
42 41
 }
@@ -54,7 +53,6 @@
54 53
     [[(id)self.uut expect] applyBackgroundColor:nil translucent:[UIColor redColor]];
55 54
     [[self.boundViewController expect] setTabBarHideShadow:YES];
56 55
     [[self.boundViewController expect] setTabBarStyle:UIBarStyleBlack];
57
-    [[self.boundViewController expect] setTabBarVisible:NO animated:NO];
58 56
 
59 57
     [self.uut applyOptions:initialOptions];
60 58
     [self.boundViewController verify];