Browse Source

V2 drawUnder for topBar and bottomTabs (#2376)

* drawUnder for topBar and bottomTabs

* test fix
yogevbd 6 years ago
parent
commit
17e51cbb80

+ 4
- 4
README.md View File

@@ -86,7 +86,7 @@ v2 is written in Test Driven Development. We have a test for every feature inclu
86 86
 | translucent         |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
87 87
 | transparent         |  ✅        |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
88 88
 | noBorder             |    ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |  @gtchance|
89
-| drawUnder         |    WIP @gran33     |      [Contribute](/docs/docs/CONTRIBUTING.md)       ||
89
+| drawUnder         |         |      [Contribute](/docs/docs/CONTRIBUTING.md)       ||
90 90
 | blur               |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
91 91
 | custom          |     WIP @gran33     | [Contribute](/docs/docs/CONTRIBUTING.md)|
92 92
 | subtitleColor            |   [Contribute](/docs/docs/CONTRIBUTING.md)     |      [Contribute](/docs/docs/CONTRIBUTING.md)      |
@@ -95,7 +95,7 @@ v2 is written in Test Driven Development. We have a test for every feature inclu
95 95
 
96 96
 |       tabBar         | iOS  | Android | contributors|
97 97
 |--------------------|-----|----|-----|
98
-| drawUnder          |    WIP @gran33     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
98
+| drawUnder          |         |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
99 99
 | hidden   |   ✅     |    ✅        | @gtchance |
100 100
 | tabBadge          |       ✅    | [Contribute](/docs/docs/CONTRIBUTING.md)| Wix|
101 101
 | currentTab by Index          |       ✅    | ✅ | Wix |
@@ -179,8 +179,8 @@ Note:  v1 properties with names beginning with 'navBar' are replaced in v2 with
179 179
 | topBarTranslucent     |  ✅     |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
180 180
 | topBarTransparent     | ✅      |   WIP @bogobogo     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
181 181
 | topBarNoBorder        |  ✅     |    ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |  @gtchance|
182
-| drawUnderTabBar       |  ✅     |    WIP @gran33     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
183
-| drawUnderTopBar       |  ✅     |    WIP @gran33     |      [Contribute](/docs/docs/CONTRIBUTING.md)       ||
182
+| drawUnderTabBar       |  ✅     |         |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
183
+| drawUnderTopBar       |  ✅     |         |      [Contribute](/docs/docs/CONTRIBUTING.md)       ||
184 184
 | statusBarBlur         |  ✅     |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
185 185
 | topBarBlur            | ✅      |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
186 186
 | tabBarHidden  |   ✅  |   ✅     |    [Contribute](/docs/docs/CONTRIBUTING.md)        | @gtchance|

+ 16
- 0
lib/ios/RNNNavigationOptions.m View File

@@ -159,6 +159,14 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
159 159
 		if (self.topBar.translucent) {
160 160
 			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
161 161
 		}
162
+
163
+		if (self.topBar.drawUnder) {
164
+			if ([self.topBar.drawUnder boolValue]) {
165
+				viewController.edgesForExtendedLayout |= UIRectEdgeTop;
166
+			} else {
167
+				viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;
168
+			}
169
+		}
162 170
 		
163 171
 		if (self.topBar.noBorder) {
164 172
 			if ([self.topBar.noBorder boolValue]) {
@@ -203,6 +211,14 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
203 211
 		if (self.bottomTabs.testID) {
204 212
 			viewController.tabBarController.tabBar.accessibilityIdentifier = self.bottomTabs.testID;
205 213
 		}
214
+		
215
+		if (self.bottomTabs.drawUnder) {
216
+			if ([self.bottomTabs.drawUnder boolValue]) {
217
+				viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
218
+			} else {
219
+				viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
220
+			}
221
+		}
206 222
 	}
207 223
 	
208 224
 	if (self.statusBarBlur) {

+ 1
- 0
lib/ios/RNNTabBarOptions.h View File

@@ -9,6 +9,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
9 9
 @property (nonatomic, strong) NSString* tabBadge;
10 10
 @property (nonatomic, strong) NSNumber* currentTabIndex;
11 11
 @property (nonatomic, strong) NSString* testID;
12
+@property (nonatomic, strong) NSNumber* drawUnder;
12 13
 
13 14
 -(instancetype)init;
14 15
 -(instancetype)initWithDict:(NSDictionary *)topBarOptions;

+ 1
- 0
lib/ios/RNNTopBarOptions.h View File

@@ -13,6 +13,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
13 13
 @property (nonatomic, strong) NSNumber* buttonColor;
14 14
 @property (nonatomic, strong) NSNumber* translucent;
15 15
 @property (nonatomic, strong) NSNumber* transparent;
16
+@property (nonatomic, strong) NSNumber* drawUnder;
16 17
 @property (nonatomic, strong) NSNumber* textFontSize;
17 18
 @property (nonatomic, strong) NSNumber* noBorder;
18 19
 @property (nonatomic, strong) NSNumber* blur;

+ 33
- 1
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

@@ -491,7 +491,7 @@
491 491
 	XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways);
492 492
 }
493 493
 -(void)testTopBarLargeTitle_false {
494
-	self.options.tabBar.hidden = @(0);
494
+	self.options.topBar.largeTitle  = @(0);
495 495
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
496 496
 	[self.uut viewWillAppear:false];
497 497
 	
@@ -513,4 +513,36 @@
513 513
 	XCTAssertNotNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
514 514
 }
515 515
 
516
+-(void)testTopBarDrawUnder_true {
517
+	self.options.topBar.drawUnder = @(1);
518
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
519
+	[self.uut viewWillAppear:false];
520
+	
521
+	XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
522
+}
523
+
524
+-(void)testTopBarDrawUnder_false {
525
+	self.options.topBar.drawUnder = @(0);
526
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
527
+	[self.uut viewWillAppear:false];
528
+	
529
+	XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
530
+}
531
+
532
+-(void)testBottomTabsDrawUnder_true {
533
+	self.options.bottomTabs.drawUnder = @(1);
534
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
535
+	[self.uut viewWillAppear:false];
536
+	
537
+	XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
538
+}
539
+
540
+-(void)testBottomTabsDrawUnder_false {
541
+	self.options.bottomTabs.drawUnder = @(0);
542
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
543
+	[self.uut viewWillAppear:false];
544
+	
545
+	XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
546
+}
547
+
516 548
 @end