Browse Source

statusBarHideWithTopBar iOS (#1724)

Graham Chance 7 years ago
parent
commit
75a2b96ebd

+ 2
- 2
README.md View File

@@ -92,8 +92,8 @@ Note:  v1 properties with names beginning with 'navBar' are replaced in v2 with
92 92
 | navBarSubtitleFontFamily    |   ✅  |    [Contribute](CONTRIBUTING.md)    |     [Contribute](CONTRIBUTING.md)       |
93 93
 | screenBackgroundColor     | ✅    |   ✅     |     [Contribute](CONTRIBUTING.md)       |  Wix|
94 94
 | orientation     |  ✅   |  WIP @yogevbd      |   [Contribute](CONTRIBUTING.md)          |
95
-| statusBarHideWithTopBar        |  ✅   |    [Contribute](CONTRIBUTING.md)     |     [Contribute](CONTRIBUTING.md)       |
96
-| statusBarHidden       |  ✅   |    ✅       |     [Contribute](CONTRIBUTING.md)      | Wix|
95
+| statusBarHideWithTopBar        |  ✅   |   ✅     |     [Contribute](CONTRIBUTING.md)       | @gtchance|
96
+| statusBarHidden       |  ✅   |    ✅       |     [Contribute](CONTRIBUTING.md)      | WIX |
97 97
 | disabledBackGesture       |   ✅  |  WIP @gran33     |    / iOS specific     |
98 98
 | screenBackgroundImageName         |   ✅  |   [Contribute](CONTRIBUTING.md)      |    [Contribute](CONTRIBUTING.md)        |
99 99
 | rootBackgroundImageName            |  ✅   |    [Contribute](CONTRIBUTING.md)     |    [Contribute](CONTRIBUTING.md)       |

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

@@ -19,6 +19,7 @@ extern const NSInteger BLUR_STATUS_TAG;
19 19
 @property (nonatomic, strong) NSNumber* topBarTextFontSize;
20 20
 @property (nonatomic, strong) NSNumber* topBarNoBorder;
21 21
 @property (nonatomic, strong) NSNumber* statusBarBlur;
22
+@property (nonatomic, strong) NSNumber* statusBarHideWithTopBar;
22 23
 
23 24
 
24 25
 -(instancetype)init;

+ 6
- 1
lib/ios/RNNRootViewController.m View File

@@ -40,7 +40,12 @@
40 40
 }
41 41
 
42 42
 - (BOOL)prefersStatusBarHidden {
43
-	return [self.navigationOptions.statusBarHidden boolValue]; // || self.navigationController.isNavigationBarHidden;
43
+	if ([self.navigationOptions.statusBarHidden boolValue]) {
44
+		return YES;
45
+	} else if ([self.navigationOptions.statusBarHideWithTopBar boolValue]) {
46
+		return self.navigationController.isNavigationBarHidden;
47
+	}
48
+	return NO;
44 49
 }
45 50
 
46 51
 -(void)viewDidAppear:(BOOL)animated {

+ 19
- 0
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

@@ -59,6 +59,25 @@
59 59
 	XCTAssertTrue([self.uut prefersStatusBarHidden]);
60 60
 }
61 61
 
62
+- (void)testStatusBarHideWithTopBar_false {
63
+	self.options.statusBarHideWithTopBar = @(0);
64
+	self.options.topBarHidden = @(1);
65
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
66
+	[self.uut viewWillAppear:false];
67
+	
68
+	XCTAssertFalse([self.uut prefersStatusBarHidden]);
69
+}
70
+
71
+- (void)testStatusBarHideWithTopBar_true {
72
+	self.options.statusBarHideWithTopBar = @(1);
73
+	self.options.topBarHidden = @(1);
74
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
75
+	[self.uut viewWillAppear:false];
76
+
77
+	XCTAssertTrue([self.uut prefersStatusBarHidden]);
78
+}
79
+
80
+
62 81
 - (void)testStatusBarHidden_false {
63 82
 	self.options.statusBarHidden = @(0);
64 83
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];