Browse Source

statusBarHideWithTopBar iOS (#1724)

Graham Chance 7 years ago
parent
commit
75a2b96ebd

+ 2
- 2
README.md View File

92
 | navBarSubtitleFontFamily    |   ✅  |    [Contribute](CONTRIBUTING.md)    |     [Contribute](CONTRIBUTING.md)       |
92
 | navBarSubtitleFontFamily    |   ✅  |    [Contribute](CONTRIBUTING.md)    |     [Contribute](CONTRIBUTING.md)       |
93
 | screenBackgroundColor     | ✅    |   ✅     |     [Contribute](CONTRIBUTING.md)       |  Wix|
93
 | screenBackgroundColor     | ✅    |   ✅     |     [Contribute](CONTRIBUTING.md)       |  Wix|
94
 | orientation     |  ✅   |  WIP @yogevbd      |   [Contribute](CONTRIBUTING.md)          |
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
 | disabledBackGesture       |   ✅  |  WIP @gran33     |    / iOS specific     |
97
 | disabledBackGesture       |   ✅  |  WIP @gran33     |    / iOS specific     |
98
 | screenBackgroundImageName         |   ✅  |   [Contribute](CONTRIBUTING.md)      |    [Contribute](CONTRIBUTING.md)        |
98
 | screenBackgroundImageName         |   ✅  |   [Contribute](CONTRIBUTING.md)      |    [Contribute](CONTRIBUTING.md)        |
99
 | rootBackgroundImageName            |  ✅   |    [Contribute](CONTRIBUTING.md)     |    [Contribute](CONTRIBUTING.md)       |
99
 | rootBackgroundImageName            |  ✅   |    [Contribute](CONTRIBUTING.md)     |    [Contribute](CONTRIBUTING.md)       |

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

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

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

40
 }
40
 }
41
 
41
 
42
 - (BOOL)prefersStatusBarHidden {
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
 -(void)viewDidAppear:(BOOL)animated {
51
 -(void)viewDidAppear:(BOOL)animated {

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

59
 	XCTAssertTrue([self.uut prefersStatusBarHidden]);
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
 - (void)testStatusBarHidden_false {
81
 - (void)testStatusBarHidden_false {
63
 	self.options.statusBarHidden = @(0);
82
 	self.options.statusBarHidden = @(0);
64
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
83
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];