[RCTDevLoadingView] Add ability to disable during development.
Summary: I'd like this ability as this has a tendency to get in the way of some of the more complex UI pieces I have. Disabling RCT_DEV entirely is too much for me. Closes https://github.com/facebook/react-native/pull/2451 Github Author: Tj <tfallon@mail.depaul.edu>
This commit is contained in:
parent
7a6f116ed4
commit
58661978a7
|
@ -11,4 +11,6 @@
|
|||
|
||||
@interface RCTDevLoadingView : NSObject <RCTBridgeModule>
|
||||
|
||||
+ (void)setEnabled:(BOOL)enabled;
|
||||
|
||||
@end
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#if RCT_DEV
|
||||
|
||||
static BOOL isEnabled = YES;
|
||||
|
||||
@implementation RCTDevLoadingView
|
||||
{
|
||||
UIWindow *_window;
|
||||
|
@ -27,6 +29,11 @@
|
|||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
isEnabled = enabled;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
|
@ -57,6 +64,10 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (void)showWithURL:(NSURL *)URL
|
||||
{
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
_showDate = [NSDate date];
|
||||
|
@ -90,6 +101,10 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (void)hide
|
||||
{
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
const NSTimeInterval MIN_PRESENTED_TIME = 0.6;
|
||||
|
@ -117,6 +132,7 @@ RCT_EXPORT_MODULE()
|
|||
@implementation RCTDevLoadingView
|
||||
|
||||
+ (NSString *)moduleName { return nil; }
|
||||
+ (void)setEnabled:(BOOL)enabled { }
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue