From 521a15100760767a8f184c879f3fa41188f4c38b Mon Sep 17 00:00:00 2001 From: yogevbd Date: Mon, 18 Dec 2017 15:56:33 +0200 Subject: [PATCH 1/2] drawUnder for topBar and bottomTabs --- README.md | 8 ++--- lib/ios/RNNNavigationOptions.m | 16 +++++++++ lib/ios/RNNTabBarOptions.h | 1 + lib/ios/RNNTopBarOptions.h | 1 + .../RNNRootViewControllerTest.m | 34 ++++++++++++++++++- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5bc9b9cad81..4e983128331 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ v2 is written in Test Driven Development. We have a test for every feature inclu | translucent | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | Wix| | transparent | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | | noBorder | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| -| drawUnder | WIP @gran33 | [Contribute](/docs/docs/CONTRIBUTING.md) || +| drawUnder | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) || | blur | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| | custom | WIP @gran33 | [Contribute](/docs/docs/CONTRIBUTING.md)| | 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 | tabBar | iOS | Android | contributors| |--------------------|-----|----|-----| -| drawUnder | WIP @gran33 | [Contribute](/docs/docs/CONTRIBUTING.md) | | +| drawUnder | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | | | hidden | ✅ | ✅ | @gtchance | | tabBadge | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md)| Wix| | currentTab by Index | ✅ | ✅ | Wix | @@ -179,8 +179,8 @@ Note: v1 properties with names beginning with 'navBar' are replaced in v2 with | topBarTranslucent | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | Wix| | topBarTransparent | ✅ | WIP @bogobogo | [Contribute](/docs/docs/CONTRIBUTING.md) | | topBarNoBorder | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| -| drawUnderTabBar | ✅ | WIP @gran33 | [Contribute](/docs/docs/CONTRIBUTING.md) | | -| drawUnderTopBar | ✅ | WIP @gran33 | [Contribute](/docs/docs/CONTRIBUTING.md) || +| drawUnderTabBar | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | | +| drawUnderTopBar | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) || | statusBarBlur | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| | topBarBlur | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| | tabBarHidden | ✅ | ✅ | [Contribute](/docs/docs/CONTRIBUTING.md) | @gtchance| diff --git a/lib/ios/RNNNavigationOptions.m b/lib/ios/RNNNavigationOptions.m index 6b67823d5a6..33ee18050a4 100644 --- a/lib/ios/RNNNavigationOptions.m +++ b/lib/ios/RNNNavigationOptions.m @@ -159,6 +159,14 @@ -(void)applyOn:(UIViewController*)viewController { if (self.topBar.translucent) { viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue]; } + + if (self.topBar.drawUnder) { + if ([self.topBar.drawUnder boolValue]) { + viewController.edgesForExtendedLayout |= UIRectEdgeTop; + } else { + viewController.edgesForExtendedLayout &= ~UIRectEdgeTop; + } + } if (self.topBar.noBorder) { if ([self.topBar.noBorder boolValue]) { @@ -203,6 +211,14 @@ -(void)applyOn:(UIViewController*)viewController { if (self.bottomTabs.testID) { viewController.tabBarController.tabBar.accessibilityIdentifier = self.bottomTabs.testID; } + + if (self.bottomTabs.drawUnder) { + if ([self.bottomTabs.drawUnder boolValue]) { + viewController.edgesForExtendedLayout |= UIRectEdgeBottom; + } else { + viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom; + } + } } if (self.statusBarBlur) { diff --git a/lib/ios/RNNTabBarOptions.h b/lib/ios/RNNTabBarOptions.h index 90097201528..555a84a4b43 100644 --- a/lib/ios/RNNTabBarOptions.h +++ b/lib/ios/RNNTabBarOptions.h @@ -9,6 +9,7 @@ extern const NSInteger BLUR_TOPBAR_TAG; @property (nonatomic, strong) NSString* tabBadge; @property (nonatomic, strong) NSNumber* currentTabIndex; @property (nonatomic, strong) NSString* testID; +@property (nonatomic, strong) NSNumber* drawUnder; -(instancetype)init; -(instancetype)initWithDict:(NSDictionary *)topBarOptions; diff --git a/lib/ios/RNNTopBarOptions.h b/lib/ios/RNNTopBarOptions.h index f43dda7efed..342200b39f9 100644 --- a/lib/ios/RNNTopBarOptions.h +++ b/lib/ios/RNNTopBarOptions.h @@ -13,6 +13,7 @@ extern const NSInteger BLUR_TOPBAR_TAG; @property (nonatomic, strong) NSNumber* buttonColor; @property (nonatomic, strong) NSNumber* translucent; @property (nonatomic, strong) NSNumber* transparent; +@property (nonatomic, strong) NSNumber* drawUnder; @property (nonatomic, strong) NSNumber* textFontSize; @property (nonatomic, strong) NSNumber* noBorder; @property (nonatomic, strong) NSNumber* blur; diff --git a/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m b/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m index ce38e8fe3ac..c5e06248bd3 100644 --- a/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m +++ b/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m @@ -491,7 +491,7 @@ -(void)testTopBarLargeTitle_true { XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways); } -(void)testTopBarLargeTitle_false { - self.options.tabBar.hidden = @(0); + self.options.bottomTabs.hidden = @(0); __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; [self.uut viewWillAppear:false]; @@ -513,4 +513,36 @@ -(void)testTopBarBlur_true { XCTAssertNotNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]); } +-(void)testTopBarDrawUnder_true { + self.options.topBar.drawUnder = @(1); + __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; + [self.uut viewWillAppear:false]; + + XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeTop); +} + +-(void)testTopBarDrawUnder_false { + self.options.topBar.drawUnder = @(0); + __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; + [self.uut viewWillAppear:false]; + + XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeTop); +} + +-(void)testBottomTabsDrawUnder_true { + self.options.bottomTabs.drawUnder = @(1); + __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; + [self.uut viewWillAppear:false]; + + XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeBottom); +} + +-(void)testBottomTabsDrawUnder_false { + self.options.bottomTabs.drawUnder = @(0); + __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; + [self.uut viewWillAppear:false]; + + XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeBottom); +} + @end From 1eaa06eb85b13611acfd5fc5d1cd9aa001829382 Mon Sep 17 00:00:00 2001 From: yogevbd Date: Tue, 19 Dec 2017 11:37:12 +0200 Subject: [PATCH 2/2] test fix --- lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m b/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m index c5e06248bd3..02d0863fccd 100644 --- a/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m +++ b/lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m @@ -491,7 +491,7 @@ -(void)testTopBarLargeTitle_true { XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways); } -(void)testTopBarLargeTitle_false { - self.options.bottomTabs.hidden = @(0); + self.options.topBar.largeTitle = @(0); __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut]; [self.uut viewWillAppear:false];