Browse Source

Fix topBar.noBorder option on iOS 13 (#5705)

* Fix topBar.noBorder option on iOS 13

* Fix unit tests

* empty commit
Yogev Ben David 5 years ago
parent
commit
919fa12780
No account linked to committer's email address

+ 2
- 0
lib/ios/UINavigationBar+utils.h View File

8
 
8
 
9
 - (void)rnn_setBackIndicatorImage:(UIImage *)image;
9
 - (void)rnn_setBackIndicatorImage:(UIImage *)image;
10
 
10
 
11
+- (void)rnn_showBorder:(BOOL)showBorder;
12
+
11
 @end
13
 @end

+ 11
- 0
lib/ios/UINavigationBar+utils.m View File

56
     }
56
     }
57
 }
57
 }
58
 
58
 
59
+- (void)rnn_showBorder:(BOOL)showBorder {
60
+    if (@available(iOS 13.0, *)) {
61
+        UIColor* shadowColor = showBorder ? [[UINavigationBarAppearance new] shadowColor] : nil;
62
+        [[self getNavigaitonBarStandardAppearance] setShadowColor:shadowColor];
63
+        [[self getNavigaitonBarCompactAppearance] setShadowColor:shadowColor];
64
+        [[self getNavigaitonBarScrollEdgeAppearance] setShadowColor:shadowColor];
65
+    } else {
66
+        [self setShadowImage:showBorder ? nil : [UIImage new]];
67
+    }
68
+}
69
+
59
 - (void)removeTransparentView {
70
 - (void)removeTransparentView {
60
     UIView *transparentView = [self viewWithTag:TOP_BAR_TRANSPARENT_TAG];
71
     UIView *transparentView = [self viewWithTag:TOP_BAR_TRANSPARENT_TAG];
61
     if (transparentView){
72
     if (transparentView){

+ 1
- 5
lib/ios/UINavigationController+RNNOptions.m View File

36
 }
36
 }
37
 
37
 
38
 - (void)setNavigationBarNoBorder:(BOOL)noBorder {
38
 - (void)setNavigationBarNoBorder:(BOOL)noBorder {
39
-	if (noBorder) {
40
-		[self.navigationBar setShadowImage:[[UIImage alloc] init]];
41
-	} else {
42
-		[self.navigationBar setShadowImage:nil];
43
-	}
39
+	[self.navigationBar rnn_showBorder:!noBorder];
44
 }
40
 }
45
 
41
 
46
 - (void)setBarStyle:(UIBarStyle)barStyle {
42
 - (void)setBarStyle:(UIBarStyle)barStyle {

+ 2
- 2
playground/ios/NavigationTests/RNNRootViewControllerTest.m View File

461
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
461
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
462
 	__unused RNNStackController* nav = [self createNavigationController];
462
 	__unused RNNStackController* nav = [self createNavigationController];
463
 	[self.uut viewWillAppear:false];
463
 	[self.uut viewWillAppear:false];
464
-	XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
464
+	XCTAssertNil(self.uut.navigationController.navigationBar.standardAppearance.shadowColor);
465
 }
465
 }
466
 
466
 
467
 -(void)testTopBarNoBorderOff {
467
 -(void)testTopBarNoBorderOff {
469
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
469
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
470
 	__unused RNNStackController* nav = [self createNavigationController];
470
 	__unused RNNStackController* nav = [self createNavigationController];
471
 	[self.uut viewWillAppear:false];
471
 	[self.uut viewWillAppear:false];
472
-	XCTAssertNil(self.uut.navigationController.navigationBar.shadowImage);
472
+	XCTAssertEqual(self.uut.navigationController.navigationBar.standardAppearance.shadowColor, [UINavigationBarAppearance new].shadowColor);
473
 }
473
 }
474
 
474
 
475
 -(void)testStatusBarBlurOn {
475
 -(void)testStatusBarBlurOn {