mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Allow to provide a custom ImageManager for cxx platform (#48109)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48109 [Changelog] [Internal] - Allow to provide a custom ImageManager for cxx platform This change allows target platforms to pass a platform specific or app specific ImageManager implementation Reviewed By: javache Differential Revision: D66788794 fbshipit-source-id: d7e99cae5de0a4c60047763dce368271dd191b9c
This commit is contained in:
1 parent
7a81fd7a8a
commit
e9f279117e
2 files changed
+22
-1
No files matched your search
+20
-1
@@ -8,12 +8,31 @@
|
||||
#include "ImageComponentDescriptor.h"
|
||||
#include <react/renderer/imagemanager/ImageManager.h>
|
||||
|
||||
namespace {
|
||||
|
||||
std::shared_ptr<facebook::react::ImageManager> getImageManager(
|
||||
std::shared_ptr<const facebook::react::ContextContainer>&
|
||||
contextContainer) {
|
||||
if (auto imageManager =
|
||||
contextContainer
|
||||
->find<std::shared_ptr<facebook::react::ImageManager>>(
|
||||
facebook::react::ImageManagerKey);
|
||||
imageManager.has_value()) {
|
||||
return imageManager.value();
|
||||
}
|
||||
return std::make_shared<facebook::react::ImageManager>(contextContainer);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
extern const char ImageManagerKey[] = "ImageManager";
|
||||
|
||||
ImageComponentDescriptor::ImageComponentDescriptor(
|
||||
const ComponentDescriptorParameters& parameters)
|
||||
: ConcreteComponentDescriptor(parameters),
|
||||
imageManager_(std::make_shared<ImageManager>(contextContainer_)){};
|
||||
imageManager_(getImageManager(contextContainer_)){};
|
||||
|
||||
void ImageComponentDescriptor::adopt(ShadowNode& shadowNode) const {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
+2
@@ -14,6 +14,8 @@ namespace facebook::react {
|
||||
|
||||
class ImageManager;
|
||||
|
||||
extern const char ImageManagerKey[];
|
||||
|
||||
/*
|
||||
* Descriptor for <Image> component.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user