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
 | translucent         |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
86
 | translucent         |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
87
 | transparent         |  ✅        |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
87
 | transparent         |  ✅        |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
88
 | noBorder             |    ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |  @gtchance|
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
 | blur               |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
90
 | blur               |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
91
 | custom          |     WIP @gran33     | [Contribute](/docs/docs/CONTRIBUTING.md)|
91
 | custom          |     WIP @gran33     | [Contribute](/docs/docs/CONTRIBUTING.md)|
92
 | subtitleColor            |   [Contribute](/docs/docs/CONTRIBUTING.md)     |      [Contribute](/docs/docs/CONTRIBUTING.md)      |
92
 | subtitleColor            |   [Contribute](/docs/docs/CONTRIBUTING.md)     |      [Contribute](/docs/docs/CONTRIBUTING.md)      |
95
 
95
 
96
 |       tabBar         | iOS  | Android | contributors|
96
 |       tabBar         | iOS  | Android | contributors|
97
 |--------------------|-----|----|-----|
97
 |--------------------|-----|----|-----|
98
-| drawUnder          |    WIP @gran33     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
98
+| drawUnder          |         |      [Contribute](/docs/docs/CONTRIBUTING.md)       | |
99
 | hidden   |   ✅     |    ✅        | @gtchance |
99
 | hidden   |   ✅     |    ✅        | @gtchance |
100
 | tabBadge          |       ✅    | [Contribute](/docs/docs/CONTRIBUTING.md)| Wix|
100
 | tabBadge          |       ✅    | [Contribute](/docs/docs/CONTRIBUTING.md)| Wix|
101
 | currentTab by Index          |       ✅    | ✅ | Wix |
101
 | currentTab by Index          |       ✅    | ✅ | Wix |
179
 | topBarTranslucent     |  ✅     |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
179
 | topBarTranslucent     |  ✅     |   ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        | Wix|
180
 | topBarTransparent     | ✅      |   WIP @bogobogo     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
180
 | topBarTransparent     | ✅      |   WIP @bogobogo     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |
181
 | topBarNoBorder        |  ✅     |    ✅     |     [Contribute](/docs/docs/CONTRIBUTING.md)        |  @gtchance|
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
 | statusBarBlur         |  ✅     |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
184
 | statusBarBlur         |  ✅     |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
185
 | topBarBlur            | ✅      |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
185
 | topBarBlur            | ✅      |    ✅     |      [Contribute](/docs/docs/CONTRIBUTING.md)       | @gtchance|
186
 | tabBarHidden  |   ✅  |   ✅     |    [Contribute](/docs/docs/CONTRIBUTING.md)        | @gtchance|
186
 | tabBarHidden  |   ✅  |   ✅     |    [Contribute](/docs/docs/CONTRIBUTING.md)        | @gtchance|

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

159
 		if (self.topBar.translucent) {
159
 		if (self.topBar.translucent) {
160
 			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
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
 		if (self.topBar.noBorder) {
171
 		if (self.topBar.noBorder) {
164
 			if ([self.topBar.noBorder boolValue]) {
172
 			if ([self.topBar.noBorder boolValue]) {
203
 		if (self.bottomTabs.testID) {
211
 		if (self.bottomTabs.testID) {
204
 			viewController.tabBarController.tabBar.accessibilityIdentifier = self.bottomTabs.testID;
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
 	if (self.statusBarBlur) {
224
 	if (self.statusBarBlur) {

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

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

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

13
 @property (nonatomic, strong) NSNumber* buttonColor;
13
 @property (nonatomic, strong) NSNumber* buttonColor;
14
 @property (nonatomic, strong) NSNumber* translucent;
14
 @property (nonatomic, strong) NSNumber* translucent;
15
 @property (nonatomic, strong) NSNumber* transparent;
15
 @property (nonatomic, strong) NSNumber* transparent;
16
+@property (nonatomic, strong) NSNumber* drawUnder;
16
 @property (nonatomic, strong) NSNumber* textFontSize;
17
 @property (nonatomic, strong) NSNumber* textFontSize;
17
 @property (nonatomic, strong) NSNumber* noBorder;
18
 @property (nonatomic, strong) NSNumber* noBorder;
18
 @property (nonatomic, strong) NSNumber* blur;
19
 @property (nonatomic, strong) NSNumber* blur;

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

491
 	XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways);
491
 	XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways);
492
 }
492
 }
493
 -(void)testTopBarLargeTitle_false {
493
 -(void)testTopBarLargeTitle_false {
494
-	self.options.tabBar.hidden = @(0);
494
+	self.options.topBar.largeTitle  = @(0);
495
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
495
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
496
 	[self.uut viewWillAppear:false];
496
 	[self.uut viewWillAppear:false];
497
 	
497
 	
513
 	XCTAssertNotNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
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
 @end
548
 @end