mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Reland: [RN][iOS] Extend Fabric iOS plugins to include Core components
Summary: Changelog: [Internal] Reviewed By: shergin Differential Revision: D18638769 fbshipit-source-id: bc27de0ebfd3689aa427f3aef7e194f3938d893c
This commit is contained in:
committed by
Facebook Github Bot
parent
bb1f9b23e7
commit
01a3edcc7a
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @generated by an internal plugin build system
|
||||
*/
|
||||
|
||||
#ifdef RN_DISABLE_OSS_PLUGIN_HEADER
|
||||
|
||||
// FB Internal: FBRCTFabricComponentsPlugins.h is autogenerated by the build system.
|
||||
#import <React/FBRCTFabricComponentsPlugins.h>
|
||||
|
||||
#else
|
||||
|
||||
// OSS-compatibility layer
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <React/RCTComponentViewProtocol.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Class<RCTComponentViewProtocol> RCTFabricComponentsProvider(const char *name);
|
||||
|
||||
// Lookup functions
|
||||
Class<RCTComponentViewProtocol> RCTSafeAreaViewCls(void) __attribute__((used));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif // RN_DISABLE_OSS_PLUGIN_HEADER
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @generated by an internal plugin build system
|
||||
*/
|
||||
|
||||
#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
|
||||
|
||||
// OSS-compatibility layer
|
||||
|
||||
#import "RCTFabricComponentsPlugins.h"
|
||||
|
||||
#import <string>
|
||||
#import <unordered_map>
|
||||
|
||||
Class<RCTComponentViewProtocol> RCTFabricComponentsProvider(const char *name) {
|
||||
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
|
||||
{"SafeAreaView", RCTSafeAreaViewCls},
|
||||
};
|
||||
|
||||
auto p = sFabricComponentsClassMap.find(name);
|
||||
if (p != sFabricComponentsClassMap.end()) {
|
||||
auto classFunc = p->second;
|
||||
return classFunc();
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#endif // RN_DISABLE_OSS_PLUGIN_HEADER
|
||||
@@ -10,6 +10,7 @@
|
||||
#import <react/components/safeareaview/SafeAreaViewComponentDescriptor.h>
|
||||
#import <react/components/safeareaview/SafeAreaViewState.h>
|
||||
#import "RCTConversions.h"
|
||||
#import "RCTFabricComponentsPlugins.h"
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
@@ -65,3 +66,8 @@ using namespace facebook::react;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Class<RCTComponentViewProtocol> RCTSafeAreaViewCls(void)
|
||||
{
|
||||
return RCTSafeAreaViewComponentView.class;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#import "RCTARTSurfaceViewComponentView.h"
|
||||
#import "RCTActivityIndicatorViewComponentView.h"
|
||||
#import "RCTComponentViewClassDescriptor.h"
|
||||
#import "RCTFabricComponentsPlugins.h"
|
||||
#import "RCTImageComponentView.h"
|
||||
#import "RCTLegacyViewManagerInteropComponentView.h"
|
||||
#import "RCTModalHostViewComponentView.h"
|
||||
@@ -26,7 +27,6 @@
|
||||
#import "RCTParagraphComponentView.h"
|
||||
#import "RCTPullToRefreshViewComponentView.h"
|
||||
#import "RCTRootComponentView.h"
|
||||
#import "RCTSafeAreaViewComponentView.h"
|
||||
#import "RCTScrollViewComponentView.h"
|
||||
#import "RCTSliderComponentView.h"
|
||||
#import "RCTSwitchComponentView.h"
|
||||
@@ -60,7 +60,6 @@ using namespace facebook::react;
|
||||
[componentViewFactory registerComponentViewClass:[RCTUnimplementedNativeComponentView class]];
|
||||
[componentViewFactory registerComponentViewClass:[RCTModalHostViewComponentView class]];
|
||||
[componentViewFactory registerComponentViewClass:[RCTARTSurfaceViewComponentView class]];
|
||||
[componentViewFactory registerComponentViewClass:[RCTSafeAreaViewComponentView class]];
|
||||
|
||||
auto providerRegistry = &componentViewFactory->_providerRegistry;
|
||||
|
||||
@@ -74,9 +73,16 @@ using namespace facebook::react;
|
||||
[componentViewFactory registerComponentViewClass:klass];
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Fallback 2: In case delegate isn't defined, look into core components.
|
||||
Class<RCTComponentViewProtocol> klass = RCTFabricComponentsProvider(requestedComponentName);
|
||||
if (klass) {
|
||||
[componentViewFactory registerComponentViewClass:klass];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback 2: Try to use Paper Interop.
|
||||
// Fallback 3: Try to use Paper Interop.
|
||||
if ([RCTLegacyViewManagerInteropComponentView isSupported:RCTNSStringFromString(requestedComponentName)]) {
|
||||
auto flavor = std::make_shared<std::string const>(requestedComponentName);
|
||||
auto componentName = ComponentName{flavor->c_str()};
|
||||
@@ -90,7 +96,7 @@ using namespace facebook::react;
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback 3: Finally use <UnimplementedView>.
|
||||
// Fallback 4: Finally use <UnimplementedView>.
|
||||
auto flavor = std::make_shared<std::string const>(requestedComponentName);
|
||||
auto componentName = ComponentName{flavor->c_str()};
|
||||
auto componentHandle = reinterpret_cast<ComponentHandle>(componentName);
|
||||
|
||||
Reference in New Issue
Block a user