[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>
|
@interface RCTDevLoadingView : NSObject <RCTBridgeModule>
|
||||||
|
|
||||||
|
+ (void)setEnabled:(BOOL)enabled;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#if RCT_DEV
|
#if RCT_DEV
|
||||||
|
|
||||||
|
static BOOL isEnabled = YES;
|
||||||
|
|
||||||
@implementation RCTDevLoadingView
|
@implementation RCTDevLoadingView
|
||||||
{
|
{
|
||||||
UIWindow *_window;
|
UIWindow *_window;
|
||||||
|
@ -27,6 +29,11 @@
|
||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (void)setEnabled:(BOOL)enabled
|
||||||
|
{
|
||||||
|
isEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
|
@ -57,6 +64,10 @@ RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
- (void)showWithURL:(NSURL *)URL
|
- (void)showWithURL:(NSURL *)URL
|
||||||
{
|
{
|
||||||
|
if (!isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
_showDate = [NSDate date];
|
_showDate = [NSDate date];
|
||||||
|
@ -90,6 +101,10 @@ RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
- (void)hide
|
- (void)hide
|
||||||
{
|
{
|
||||||
|
if (!isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
const NSTimeInterval MIN_PRESENTED_TIME = 0.6;
|
const NSTimeInterval MIN_PRESENTED_TIME = 0.6;
|
||||||
|
@ -117,6 +132,7 @@ RCT_EXPORT_MODULE()
|
||||||
@implementation RCTDevLoadingView
|
@implementation RCTDevLoadingView
|
||||||
|
|
||||||
+ (NSString *)moduleName { return nil; }
|
+ (NSString *)moduleName { return nil; }
|
||||||
|
+ (void)setEnabled:(BOOL)enabled { }
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue