|
11 | 11 | #import <React/RCTEventDispatcherProtocol.h> |
12 | 12 | #import <React/RCTInitializing.h> |
13 | 13 | #import <React/RCTLog.h> |
14 | | -#import <React/RCTStatusBarAppearance.h> |
15 | 14 | #import <React/RCTUtils.h> |
16 | 15 |
|
17 | 16 | #import <FBReactNativeSpec/FBReactNativeSpec.h> |
@@ -69,28 +68,6 @@ static BOOL RCTViewControllerBasedStatusBarAppearance() |
69 | 68 | return value; |
70 | 69 | } |
71 | 70 |
|
72 | | -// UIKit makes the app-level setters no-ops only for apps built with the iOS 27 SDK. |
73 | | -static BOOL RCTAppLevelStatusBarIsNoOp() |
74 | | -{ |
75 | | -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 270000 |
76 | | - if (@available(iOS 27.0, *)) { |
77 | | - return YES; |
78 | | - } |
79 | | -#endif |
80 | | - return NO; |
81 | | -} |
82 | | - |
83 | | -static void RCTWarnAppLevelStatusBarUnavailable() |
84 | | -{ |
85 | | - static dispatch_once_t onceToken; |
86 | | - dispatch_once(&onceToken, ^{ |
87 | | - RCTLogWarn( |
88 | | - @"StatusBar has no effect because UIViewControllerBasedStatusBarAppearance is NO in Info.plist. " |
89 | | - @"Apps built with the iOS 27 SDK cannot use the app-level status bar API that this setting uses. " |
90 | | - @"Set UIViewControllerBasedStatusBarAppearance to YES to control the status bar from JavaScript."); |
91 | | - }); |
92 | | -} |
93 | | - |
94 | 71 | RCT_EXPORT_MODULE() |
95 | 72 |
|
96 | 73 | + (BOOL)requiresMainQueueSetup |
@@ -170,32 +147,30 @@ - (void)setStyle:(NSString *)style animated:(BOOL)animated |
170 | 147 | { |
171 | 148 | dispatch_async(dispatch_get_main_queue(), ^{ |
172 | 149 | UIStatusBarStyle statusBarStyle = [RCTConvert UIStatusBarStyle:style]; |
173 | | - [RCTStatusBarAppearance setStyle:statusBarStyle animated:animated]; |
174 | | - if (!RCTViewControllerBasedStatusBarAppearance()) { |
| 150 | + if (RCTViewControllerBasedStatusBarAppearance()) { |
| 151 | + RCTLogWarn(@"RCTStatusBarManager is a no-op when \ |
| 152 | + UIViewControllerBasedStatusBarAppearance is YES; set the status bar from your view controller instead"); |
| 153 | + } else { |
175 | 154 | #pragma clang diagnostic push |
176 | 155 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
177 | 156 | [RCTSharedApplication() setStatusBarStyle:statusBarStyle animated:animated]; |
178 | | -#pragma clang diagnostic pop |
179 | | - if (RCTAppLevelStatusBarIsNoOp()) { |
180 | | - RCTWarnAppLevelStatusBarUnavailable(); |
181 | | - } |
182 | 157 | } |
| 158 | +#pragma clang diagnostic pop |
183 | 159 | }); |
184 | 160 | } |
185 | 161 |
|
186 | 162 | - (void)setHidden:(BOOL)hidden withAnimation:(NSString *)withAnimation |
187 | 163 | { |
188 | 164 | dispatch_async(dispatch_get_main_queue(), ^{ |
189 | 165 | UIStatusBarAnimation animation = [RCTConvert UIStatusBarAnimation:withAnimation]; |
190 | | - [RCTStatusBarAppearance setHidden:hidden withAnimation:animation]; |
191 | | - if (!RCTViewControllerBasedStatusBarAppearance()) { |
| 166 | + if (RCTViewControllerBasedStatusBarAppearance()) { |
| 167 | + RCTLogWarn(@"RCTStatusBarManager is a no-op when \ |
| 168 | + UIViewControllerBasedStatusBarAppearance is YES; set the status bar from your view controller instead"); |
| 169 | + } else { |
192 | 170 | #pragma clang diagnostic push |
193 | 171 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
194 | 172 | [RCTSharedApplication() setStatusBarHidden:hidden withAnimation:animation]; |
195 | 173 | #pragma clang diagnostic pop |
196 | | - if (RCTAppLevelStatusBarIsNoOp()) { |
197 | | - RCTWarnAppLevelStatusBarUnavailable(); |
198 | | - } |
199 | 174 | } |
200 | 175 | }); |
201 | 176 | } |
|
0 commit comments