From 6a9a76e4200d5ff12341d3487b6bff7c8a6dbc88 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 27 Feb 2020 17:01:18 -0800 Subject: [PATCH] Make RCTDevLoadingView TurboModule-compatible Summary: This is a redo of D16969764, with a few extensions. ## Changes 1. Move `RCTDevLoadingView.{h,m}` to `CoreModuels/RCTDevLoadingView.{h,mm}` 2. Extract ObjC API of `RCTDevLodingView` into `RCTDevLoadingViewProtocol` in `ReactInternal`. 3. Create API `RCTDevLoadingViewSetEnabled.h` in `ReactInternal` to enable/disable `RCTDevLoadingView` Changelog: [iOS][Added] - Make RCTDevLoadingView TurboModule-compatible Reviewed By: PeteTheHeat Differential Revision: D18642554 fbshipit-source-id: 6b62e27e128d98254b7a6d018399ec1c06e274fc --- .../FBReactNativeSpec-generated.mm | 2 +- .../FBReactNativeSpec/FBReactNativeSpec.h | 4 +- Libraries/Utilities/LoadingView.ios.js | 14 +++-- Libraries/Utilities/NativeDevLoadingView.js | 4 +- RNTester/Podfile.lock | 48 ++++++++--------- .../RNTesterPods.xcodeproj/project.pbxproj | 54 +++++++++++++++++++ React/CoreModules/BUCK | 3 ++ React/CoreModules/CoreModulesPlugins.h | 1 + React/CoreModules/CoreModulesPlugins.mm | 1 + React/CoreModules/RCTDevLoadingView.h | 13 +++++ .../RCTDevLoadingView.mm} | 39 +++++++++++--- React/CxxBridge/RCTCxxBridge.mm | 9 ++-- ...dingView.h => RCTDevLoadingViewProtocol.h} | 6 +-- .../DevSupport/RCTDevLoadingViewSetEnabled.h | 11 ++++ .../DevSupport/RCTDevLoadingViewSetEnabled.m | 22 ++++++++ .../specs/NativeDevLoadingViewSpec.java | 3 +- .../specs/jni/FBReactNativeSpec-generated.cpp | 2 +- 17 files changed, 185 insertions(+), 51 deletions(-) create mode 100644 React/CoreModules/RCTDevLoadingView.h rename React/{DevSupport/RCTDevLoadingView.m => CoreModules/RCTDevLoadingView.mm} (80%) rename React/DevSupport/{RCTDevLoadingView.h => RCTDevLoadingViewProtocol.h} (83%) create mode 100644 React/DevSupport/RCTDevLoadingViewSetEnabled.h create mode 100644 React/DevSupport/RCTDevLoadingViewSetEnabled.m diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm index 93cd6113a2171a..0b16070524cbe0 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm @@ -825,7 +825,7 @@ + (RCTManagedPointer *)JS_NativeCameraRollManager_PhotoIdentifiersPage:(id)json static facebook::jsi::Value __hostFunction_NativeDevLoadingViewSpecJSI_showMessage(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "showMessage", @selector(showMessage:color:backgroundColor:), args, count); + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "showMessage", @selector(showMessage:withColor:withBackgroundColor:), args, count); } static facebook::jsi::Value __hostFunction_NativeDevLoadingViewSpecJSI_hide(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index 754ea84d77b2a7..265fcdf3770310 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:(NSDictionary *)color - backgroundColor:(NSDictionary *)backgroundColor; + withColor:(NSNumber *)withColor +withBackgroundColor:(NSNumber *)withBackgroundColor; - (void)hide; @end diff --git a/Libraries/Utilities/LoadingView.ios.js b/Libraries/Utilities/LoadingView.ios.js index 782bedfbbb69c0..d1d74f6f059233 100644 --- a/Libraries/Utilities/LoadingView.ios.js +++ b/Libraries/Utilities/LoadingView.ios.js @@ -16,13 +16,21 @@ import NativeDevLoadingView from './NativeDevLoadingView'; module.exports = { showMessage(message: string, type: 'load' | 'refresh') { if (NativeDevLoadingView) { + const green = processColor('#275714'); + const blue = processColor('#2584e8'); + const white = processColor('#ffffff'); + NativeDevLoadingView.showMessage( message, // Use same colors as iOS "Personal Hotspot" bar. - processColor('#ffffff'), + typeof white === 'number' ? white : null, type && type === 'load' - ? processColor('#275714') - : processColor('#2584e8'), + ? typeof green === 'number' + ? green + : null + : typeof blue === 'number' + ? blue + : null, ); } }, diff --git a/Libraries/Utilities/NativeDevLoadingView.js b/Libraries/Utilities/NativeDevLoadingView.js index e672771778b8a1..8938fb6df5ccbf 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: Object, - backgroundColor: Object, + withColor: ?number, + withBackgroundColor: ?number, ) => void; +hide: () => void; } diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index 3aef761d0003c4..c4e421b421dd05 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -451,8 +451,8 @@ SPEC CHECKSUMS: CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 - FBLazyVector: 9806caa151956ce2238f70bde6649a6e3468d2c2 - FBReactNativeSpec: 36a4e4488cc758ffceea8e1b3b5c6dab3ed99fa2 + FBLazyVector: 8ea0285646adaf7fa725c20ed737c49ee5ea680a + FBReactNativeSpec: e8f07c749b9cf184c819f5a8ca44b91ab61fca12 Flipper: 10b225e352595f521be0e5badddd90e241336e89 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: 2de3d03e0acc7064d5e4ed9f730e2f217486f162 @@ -463,28 +463,28 @@ SPEC CHECKSUMS: Folly: b73c3869541e86821df3c387eb0af5f65addfab4 glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 - RCTRequired: f04f9813bccb37099f642722b46e879fc47c7e78 - RCTTypeSafety: 26a1a3b30655098b72d3954e3e7d0f9a7a059e95 - React: 7b262249ab4afa1d300c9e90f50edcc2a5f72bcd - React-ART: 25a40dbfb785ceec6ca41d5bd1ec997ca8c01f17 - React-Core: 86046aecc5d3297cd37391ad7577e33784bcff74 - React-CoreModules: b6dd63292ef064320a8c1b2e40291b95690e0e5f - React-cxxreact: 9a0a25be41fd93b42d3cbef6311b309a1da53191 - React-jsi: 1143a100f9e746b6acb9c8ebff6c3fe66669e404 - React-jsiexecutor: 56259faac069d4e475001c1ddb042ef622318f10 - React-jsinspector: 5a11c19a7a267ea4a54f7082ca7834470f5c3fec - React-RCTActionSheet: 83587cdb4e14b9d986058a3acec8fc1cd9815b59 - React-RCTAnimation: e328fb809d590c09d88aa4d42f3963de522fef90 - React-RCTBlob: de3bd0bdbc42ec4e64183aefec9d582a7463cf00 - React-RCTImage: 046397bd2ba8506628b720ba3baf2ba7e331b1bf - React-RCTLinking: 7b77eca020eaf222d19151f0f52cd6065cbc90ec - React-RCTNetwork: d16dd52792dc3d66c3e23b464afe0f759d3a5670 - React-RCTPushNotification: 9290035bbd9ecef15f03d760cc422a219b55be07 - React-RCTSettings: f7daf792f772c8582b31c7aeeb1f146df61a52a7 - React-RCTTest: e10acfa457347879d3723bc85f1d2754414b9d2c - React-RCTText: b3eb3514addd9b105c0edb05ed32333428ba2a52 - React-RCTVibration: e2856bb9408f7e8eccfe870e123e5644ab744219 - ReactCommon: c3834cbee58b60f71c8155c04a3f44e60ec017fb + RCTRequired: 34582e9b3ebe69f244e091f37218d318406d5c4a + RCTTypeSafety: 1ade47a69b092cddf1e4ea21e0c5bdc65cc950b4 + React: cafb3c2321f7df55ce90dbf29d513799a79e4418 + React-ART: df0460bdff42ef039e28ee3ffd41f50b75644788 + React-Core: 08c69f013e6fd654ea8f9fd84bbd66780a54d886 + React-CoreModules: 0b59c833afcc9735e5a0220997fb18876dc9e52c + React-cxxreact: c0246279e902a2a6e71e309e8cdcbaa4877141c6 + React-jsi: fe94132da767bfc4801968c2a12abae43e9a833e + React-jsiexecutor: 55eff40b2e0696e7a979016e321793ec8b28a2ac + React-jsinspector: 7fbf9b42b58b02943a0d89b0ba9fff0070f2de98 + React-RCTActionSheet: 51c43beeb74ef41189e87fe9823e53ebf6210359 + React-RCTAnimation: 528462d8fe78787f2e058062cd9a4b44735ea579 + React-RCTBlob: e29e0277cbcd91f07719d8411a3fa5db6600b4cf + React-RCTImage: a24587309c984427ec74d3c7be13b00ca0caabeb + React-RCTLinking: 696a3911a5d380ba87e29fde099a811e51e69e2f + React-RCTNetwork: cc2ccdcbf13dbea0710ef887e0b9ceae7f5aef28 + React-RCTPushNotification: 13befc7c6efba31625fd9a945dfa71a31b724b4a + React-RCTSettings: a2b148ef74dcb98369e5bb0def506d2d29125ab3 + React-RCTTest: cfe25fcf70b04a747dba4326105db398250caa9a + React-RCTText: 6c01963d3e562109f5548262b09b1b2bc260dd60 + React-RCTVibration: d218336fa28ade97e99b4ddb935f1de5c670e361 + ReactCommon: d17767bf5744406b4f4be1db7356ffbf1f99180c Yoga: f7fa200d8c49f97b54c9421079e781fb900b5cae YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/RNTester/RNTesterPods.xcodeproj/project.pbxproj b/RNTester/RNTesterPods.xcodeproj/project.pbxproj index 5dde964f3e58a9..9ce41dc1357dfa 100644 --- a/RNTester/RNTesterPods.xcodeproj/project.pbxproj +++ b/RNTester/RNTesterPods.xcodeproj/project.pbxproj @@ -395,6 +395,7 @@ 13B07F8E1A680F5B00A75B9A /* Resources */, 68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */, 5CF0FD27207FC6EC00C13D65 /* Start Metro */, + 33D41129F73FA216240D6A8E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -413,6 +414,7 @@ E7DB209B22B2BA84005AC45F /* Sources */, E7DB209C22B2BA84005AC45F /* Frameworks */, E7DB209D22B2BA84005AC45F /* Resources */, + 82168A981B1591BFD3DFCF51 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -431,6 +433,7 @@ E7DB214F22B2F332005AC45F /* Sources */, E7DB215022B2F332005AC45F /* Frameworks */, E7DB215122B2F332005AC45F /* Resources */, + 28D6EF6C8ED1C5CEB67629BA /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -509,6 +512,40 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 28D6EF6C8ED1C5CEB67629BA /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 33D41129F73FA216240D6A8E /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 56D84768A7BBB2750D674CF3 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -582,6 +619,23 @@ shellPath = /bin/sh; shellScript = "export NODE_BINARY=node\nPROJECT_ROOT=$SRCROOT/.. $SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js\n"; }; + 82168A981B1591BFD3DFCF51 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; F9CB97B0D9633939D43E75E0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index 15fb3679879267..c597beb0411234 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -109,6 +109,9 @@ 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 b158cb2aa3214f..478c7473a512ba 100644 --- a/React/CoreModules/CoreModulesPlugins.h +++ b/React/CoreModules/CoreModulesPlugins.h @@ -52,6 +52,7 @@ Class RCTLogBoxCls(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 dfd937c5389930..40c36eb59508fa 100644 --- a/React/CoreModules/CoreModulesPlugins.mm +++ b/React/CoreModules/CoreModulesPlugins.mm @@ -41,6 +41,7 @@ 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/CoreModules/RCTDevLoadingView.h new file mode 100644 index 00000000000000..d2fb7e60358608 --- /dev/null +++ b/React/CoreModules/RCTDevLoadingView.h @@ -0,0 +1,13 @@ +/* + * 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 +#import +#import + +@interface RCTDevLoadingView : NSObject +@end diff --git a/React/DevSupport/RCTDevLoadingView.m b/React/CoreModules/RCTDevLoadingView.mm similarity index 80% rename from React/DevSupport/RCTDevLoadingView.m rename to React/CoreModules/RCTDevLoadingView.mm index fbc8add18f766c..a76f4a3e774d9a 100644 --- a/React/DevSupport/RCTDevLoadingView.m +++ b/React/CoreModules/RCTDevLoadingView.mm @@ -10,13 +10,21 @@ #import #import +#import #import +#import #import #import +#import -#if RCT_DEV | RCT_ENABLE_LOADING_VIEW +#import "CoreModulesPlugins.h" + +using namespace facebook::react; + +@interface RCTDevLoadingView () +@end -static BOOL isEnabled = YES; +#if RCT_DEV | RCT_ENABLE_LOADING_VIEW @implementation RCTDevLoadingView { @@ -31,7 +39,7 @@ @implementation RCTDevLoadingView + (void)setEnabled:(BOOL)enabled { - isEnabled = enabled; + RCTDevLoadingViewSetEnabled(enabled); } + (BOOL)requiresMainQueueSetup @@ -57,9 +65,9 @@ - (void)setBridge:(RCTBridge *)bridge } } -RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor) +-(void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor { - if (!isEnabled) { + if (!RCTDevLoadingViewGetEnabled()) { return; } @@ -102,9 +110,14 @@ - (void)setBridge:(RCTBridge *)bridge }); } +RCT_EXPORT_METHOD(showMessage:(NSString *)message withColor:(NSNumber *)color withBackgroundColor:(NSNumber *)backgroundColor) +{ + [self showMessage:message color:[RCTConvert UIColor:color] backgroundColor:[RCTConvert UIColor:backgroundColor]]; +} + RCT_EXPORT_METHOD(hide) { - if (!isEnabled) { + if (!RCTDevLoadingViewGetEnabled()) { return; } @@ -160,6 +173,11 @@ - (void)updateProgress:(RCTLoadingProgress *)progress }); } +- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker +{ + return std::make_shared(self, jsInvoker); +} + @end #else @@ -169,10 +187,19 @@ @implementation RCTDevLoadingView + (NSString *)moduleName { return nil; } + (void)setEnabled:(BOOL)enabled { } - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor { } +- (void)showMessage:(NSString *)message withColor:(NSNumber *)color withBackgroundColor:(NSNumber *)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/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 1aeea6300f92db..31455a5da90191 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -45,8 +45,8 @@ #import #endif -#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include() -#import +#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include() +#import #endif static NSString *const RCTJSThreadName = @"com.facebook.react.JavaScript"; @@ -372,10 +372,9 @@ - (void)start sourceCode = source.data; dispatch_group_leave(prepareBridge); } onProgress:^(RCTLoadingProgress *progressData) { -#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include() +#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include() // Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading. - RCTDevLoadingView *loadingView = [weakSelf moduleForName:RCTBridgeModuleNameForClass([RCTDevLoadingView class]) - lazilyLoadIfNecessary:NO]; + id loadingView = [weakSelf moduleForName:@"DevLoadingView" lazilyLoadIfNecessary:NO]; [loadingView updateProgress:progressData]; #endif }]; diff --git a/React/DevSupport/RCTDevLoadingView.h b/React/DevSupport/RCTDevLoadingViewProtocol.h similarity index 83% rename from React/DevSupport/RCTDevLoadingView.h rename to React/DevSupport/RCTDevLoadingViewProtocol.h index 4fe67f1b76759e..dbd86fbe4b0dae 100644 --- a/React/DevSupport/RCTDevLoadingView.h +++ b/React/DevSupport/RCTDevLoadingViewProtocol.h @@ -7,16 +7,12 @@ #import -#import - @class RCTLoadingProgress; -@interface RCTDevLoadingView : NSObject - +@protocol RCTDevLoadingViewProtocol + (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/DevSupport/RCTDevLoadingViewSetEnabled.h b/React/DevSupport/RCTDevLoadingViewSetEnabled.h new file mode 100644 index 00000000000000..1ad182578cdefe --- /dev/null +++ b/React/DevSupport/RCTDevLoadingViewSetEnabled.h @@ -0,0 +1,11 @@ +/* + * 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 new file mode 100644 index 00000000000000..90a5ff15f43e1b --- /dev/null +++ b/React/DevSupport/RCTDevLoadingViewSetEnabled.m @@ -0,0 +1,22 @@ +/* + * 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 30cb6d15958c07..95a3c553a48f8f 100644 --- a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java +++ b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeDevLoadingViewSpec.java @@ -16,7 +16,6 @@ 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 { @@ -28,5 +27,5 @@ public NativeDevLoadingViewSpec(ReactApplicationContext reactContext) { public abstract void hide(); @ReactMethod - public abstract void showMessage(String message, ReadableMap color, ReadableMap backgroundColor); + public abstract void showMessage(String message, Double withColor, Double withBackgroundColor); } diff --git a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/jni/FBReactNativeSpec-generated.cpp b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/jni/FBReactNativeSpec-generated.cpp index 79dc500ad1633d..d3e521352b9322 100644 --- a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/jni/FBReactNativeSpec-generated.cpp +++ b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/jni/FBReactNativeSpec-generated.cpp @@ -663,7 +663,7 @@ namespace facebook { static facebook::jsi::Value __hostFunction_NativeDevLoadingViewSpecJSI_showMessage(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, "showMessage", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;)V", args, count); + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, "showMessage", "(Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V", args, count); } static facebook::jsi::Value __hostFunction_NativeDevLoadingViewSpecJSI_hide(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {