|
| 1 | +#include "MainComponentsRegistry.h" |
| 2 | + |
| 3 | +#include <CoreComponentsRegistry.h> |
| 4 | +#include <fbjni/fbjni.h> |
| 5 | +#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h> |
| 6 | +#include <react/renderer/components/rncore/ComponentDescriptors.h> |
| 7 | +#include <react/renderer/components/FastShadowView/ComponentDescriptors.h> |
| 8 | + |
| 9 | +namespace facebook { |
| 10 | +namespace react { |
| 11 | + |
| 12 | +MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {} |
| 13 | + |
| 14 | +std::shared_ptr<ComponentDescriptorProviderRegistry const> |
| 15 | +MainComponentsRegistry::sharedProviderRegistry() { |
| 16 | + auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); |
| 17 | + |
| 18 | + // Custom Fabric Components go here. You can register custom |
| 19 | + // components coming from your App or from 3rd party libraries here. |
| 20 | + // |
| 21 | + // providerRegistry->add(concreteComponentDescriptorProvider< |
| 22 | + // AocViewerComponentDescriptor>()); |
| 23 | + providerRegistry->add(concreteComponentDescriptorProvider<FastShadowViewComponentDescriptor>()); |
| 24 | + return providerRegistry; |
| 25 | +} |
| 26 | + |
| 27 | +jni::local_ref<MainComponentsRegistry::jhybriddata> |
| 28 | +MainComponentsRegistry::initHybrid( |
| 29 | + jni::alias_ref<jclass>, |
| 30 | + ComponentFactory *delegate) { |
| 31 | + auto instance = makeCxxInstance(delegate); |
| 32 | + |
| 33 | + auto buildRegistryFunction = |
| 34 | + [](EventDispatcher::Weak const &eventDispatcher, |
| 35 | + ContextContainer::Shared const &contextContainer) |
| 36 | + -> ComponentDescriptorRegistry::Shared { |
| 37 | + auto registry = MainComponentsRegistry::sharedProviderRegistry() |
| 38 | + ->createComponentDescriptorRegistry( |
| 39 | + {eventDispatcher, contextContainer}); |
| 40 | + |
| 41 | + auto mutableRegistry = |
| 42 | + std::const_pointer_cast<ComponentDescriptorRegistry>(registry); |
| 43 | + |
| 44 | + mutableRegistry->setFallbackComponentDescriptor( |
| 45 | + std::make_shared<UnimplementedNativeViewComponentDescriptor>( |
| 46 | + ComponentDescriptorParameters{ |
| 47 | + eventDispatcher, contextContainer, nullptr})); |
| 48 | + |
| 49 | + return registry; |
| 50 | + }; |
| 51 | + |
| 52 | + delegate->buildRegistryFunction = buildRegistryFunction; |
| 53 | + return instance; |
| 54 | +} |
| 55 | + |
| 56 | +void MainComponentsRegistry::registerNatives() { |
| 57 | + registerHybrid({ |
| 58 | + makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid), |
| 59 | + }); |
| 60 | +} |
| 61 | + |
| 62 | +} // namespace react |
| 63 | +} // namespace facebook |
0 commit comments