diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index a56b32f495e..637161e82a7 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h @@ -848,8 +848,8 @@ namespace facebook { @protocol NativeDevLoadingViewSpec - (void)showMessage:(NSString *)message - color:(NSNumber *)color - backgroundColor:(NSNumber *)backgroundColor; + color:(NSDictionary *)color + backgroundColor:(NSDictionary *)backgroundColor; - (void)hide; @end diff --git a/Libraries/Utilities/NativeDevLoadingView.js b/Libraries/Utilities/NativeDevLoadingView.js index bf8d311ea1b..e672771778b 100644 --- a/Libraries/Utilities/NativeDevLoadingView.js +++ b/Libraries/Utilities/NativeDevLoadingView.js @@ -16,8 +16,8 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { +showMessage: ( message: string, - color: ?number, - backgroundColor: ?number, + color: Object, + backgroundColor: Object, ) => void; +hide: () => void; } diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index 2c518ea1d30..21bd66f4258 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -105,9 +105,6 @@ rn_apple_library( ) + react_module_plugin_providers( name = "WebSocketModule", native_class_func = "RCTWebSocketModuleCls", - ) + react_module_plugin_providers( - name = "DevLoadingView", - native_class_func = "RCTDevLoadingViewCls", ), plugins_header = "FBCoreModulesPlugins.h", preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_extra_build_flags() + [ diff --git a/React/CoreModules/CoreModulesPlugins.h b/React/CoreModules/CoreModulesPlugins.h index 94a9584ca47..660c86a281d 100644 --- a/React/CoreModules/CoreModulesPlugins.h +++ b/React/CoreModules/CoreModulesPlugins.h @@ -51,7 +51,6 @@ Class RCTRedBoxCls(void) __attribute__((used)); Class RCTTVNavigationEventEmitterCls(void) __attribute__((used)); Class RCTWebSocketExecutorCls(void) __attribute__((used)); Class RCTWebSocketModuleCls(void) __attribute__((used)); -Class RCTDevLoadingViewCls(void) __attribute__((used)); #ifdef __cplusplus } diff --git a/React/CoreModules/CoreModulesPlugins.mm b/React/CoreModules/CoreModulesPlugins.mm index d8e2b784ae4..d1a69375116 100644 --- a/React/CoreModules/CoreModulesPlugins.mm +++ b/React/CoreModules/CoreModulesPlugins.mm @@ -40,7 +40,6 @@ Class RCTCoreModulesClassProvider(const char *name) { {"TVNavigationEventEmitter", RCTTVNavigationEventEmitterCls}, {"WebSocketExecutor", RCTWebSocketExecutorCls}, {"WebSocketModule", RCTWebSocketModuleCls}, - {"DevLoadingView", RCTDevLoadingViewCls}, }; auto p = sCoreModuleClassMap.find(name); diff --git a/React/CoreModules/RCTDevLoadingView.h b/React/DevSupport/RCTDevLoadingView.h similarity index 67% rename from React/CoreModules/RCTDevLoadingView.h rename to React/DevSupport/RCTDevLoadingView.h index 9fdbf707597..4fe67f1b767 100644 --- a/React/CoreModules/RCTDevLoadingView.h +++ b/React/DevSupport/RCTDevLoadingView.h @@ -6,10 +6,17 @@ */ #import + #import @class RCTLoadingProgress; @interface RCTDevLoadingView : NSObject + ++ (void)setEnabled:(BOOL)enabled; +- (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor; +- (void)showWithURL:(NSURL *)URL; - (void)updateProgress:(RCTLoadingProgress *)progress; +- (void)hide; + @end diff --git a/React/CoreModules/RCTDevLoadingView.mm b/React/DevSupport/RCTDevLoadingView.m similarity index 78% rename from React/CoreModules/RCTDevLoadingView.mm rename to React/DevSupport/RCTDevLoadingView.m index 82eb0b0327d..f2dbd6b3897 100644 --- a/React/CoreModules/RCTDevLoadingView.mm +++ b/React/DevSupport/RCTDevLoadingView.m @@ -10,22 +10,14 @@ #import #import -#import #import -#import #import #import -#import - -#import "CoreModulesPlugins.h" - -using namespace facebook::react; - -@interface RCTDevLoadingView () -@end #if RCT_DEV | RCT_ENABLE_LOADING_VIEW +static BOOL isEnabled = YES; + @implementation RCTDevLoadingView { UIWindow *_window; @@ -37,6 +29,11 @@ using namespace facebook::react; RCT_EXPORT_MODULE() ++ (void)setEnabled:(BOOL)enabled +{ + isEnabled = enabled; +} + + (BOOL)requiresMainQueueSetup { return YES; @@ -60,14 +57,9 @@ RCT_EXPORT_MODULE() } } -RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(NSNumber *)color backgroundColor:(NSNumber *)backgroundColor) +RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor) { - [self showMessage:message withColor:[RCTConvert UIColor:color] andBackgroundColor:[RCTConvert UIColor:backgroundColor]]; -} - --(void)showMessage:(NSString *)message withColor:(UIColor *)color andBackgroundColor:(UIColor *)backgroundColor -{ - if (!RCTDevLoadingViewGetEnabled()) { + if (!isEnabled) { return; } @@ -107,7 +99,7 @@ RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(NSNumber *)color backgr RCT_EXPORT_METHOD(hide) { - if (!RCTDevLoadingViewGetEnabled()) { + if (!isEnabled) { return; } @@ -149,8 +141,8 @@ RCT_EXPORT_METHOD(hide) } [self showMessage:message - withColor:color - andBackgroundColor:backgroundColor]; + color:color + backgroundColor:backgroundColor]; } - (void)updateProgress:(RCTLoadingProgress *)progress @@ -163,11 +155,6 @@ RCT_EXPORT_METHOD(hide) }); } -- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker -{ - return std::make_shared(self, jsInvoker); -} - @end #else @@ -175,19 +162,12 @@ RCT_EXPORT_METHOD(hide) @implementation RCTDevLoadingView + (NSString *)moduleName { return nil; } -- (void)showMessage:(NSString *)message color:(NSNumber *)color backgroundColor:(NSNumber *)backgroundColor { } ++ (void)setEnabled:(BOOL)enabled { } +- (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor { } - (void)showWithURL:(NSURL *)URL { } - (void)updateProgress:(RCTLoadingProgress *)progress { } - (void)hide { } -- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker -{ - return std::make_shared(self, jsInvoker); -} @end #endif - -Class RCTDevLoadingViewCls(void) { - return RCTDevLoadingView.class; -} diff --git a/React/DevSupport/RCTDevLoadingViewSetEnabled.h b/React/DevSupport/RCTDevLoadingViewSetEnabled.h deleted file mode 100644 index 1ad182578cd..00000000000 --- a/React/DevSupport/RCTDevLoadingViewSetEnabled.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -RCT_EXTERN void RCTDevLoadingViewSetEnabled(BOOL enabled); -RCT_EXTERN BOOL RCTDevLoadingViewGetEnabled(void); diff --git a/React/DevSupport/RCTDevLoadingViewSetEnabled.m b/React/DevSupport/RCTDevLoadingViewSetEnabled.m deleted file mode 100644 index 90a5ff15f43..00000000000 --- a/React/DevSupport/RCTDevLoadingViewSetEnabled.m +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTDevLoadingViewSetEnabled.h" - -#if RCT_DEV | RCT_ENABLE_LOADING_VIEW -static BOOL isDevLoadingViewEnabled = YES; -#else -static BOOL isDevLoadingViewEnabled = NO; -#endif - -void RCTDevLoadingViewSetEnabled(BOOL enabled) { - isDevLoadingViewEnabled = enabled; -} - -BOOL RCTDevLoadingViewGetEnabled() { - return isDevLoadingViewEnabled; -} diff --git a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java index f9e0c38c94c..30cb6d15958 100644 --- a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java +++ b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java @@ -16,6 +16,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactModuleWithSpec; +import com.facebook.react.bridge.ReadableMap; import com.facebook.react.turbomodule.core.interfaces.TurboModule; public abstract class NativeDevLoadingViewSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { @@ -27,5 +28,5 @@ public abstract class NativeDevLoadingViewSpec extends ReactContextBaseJavaModul public abstract void hide(); @ReactMethod - public abstract void showMessage(String message, Double color, Double backgroundColor); + public abstract void showMessage(String message, ReadableMap color, ReadableMap backgroundColor); }