Files
react-native/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputComponentDescriptor.h
T
Valentin Shergin 8a8ff63b7d Fabric: Unification of constructor signature of ComponentDescriptors
Summary:
This is the first step to migrate the registration of Android-specific `ComponentDescriptors` to `ComponentDescriptorProviderRegistry`.
`ComponentDescriptorProviderRegistry` is a never API for component registration that supports reactive registration and simplified signatures for `registry` (`add`) method.

It's tedious to keep those signatures in sync with the base class (`ComponentDescriptor`), we have an idea how to make it better by using a single struct with all params but a migration to that will be a separate effort.

The changes are pure syntactical.

Changelog: [Internal] Internal changes in Fabric.

Reviewed By: mdvacca

Differential Revision: D18010488

fbshipit-source-id: 4cbfdbcae235b32a94b38df2095c956299764e59
2019-10-20 20:53:20 -07:00

49 lines
1.4 KiB
C++

/*
* 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.
*/
#pragma once
#include <react/core/ConcreteComponentDescriptor.h>
#include "AndroidTextInputShadowNode.h"
namespace facebook {
namespace react {
/*
* Descriptor for <AndroidTextInput> component.
*/
class AndroidTextInputComponentDescriptor final
: public ConcreteComponentDescriptor<AndroidTextInputShadowNode> {
public:
AndroidTextInputComponentDescriptor(
EventDispatcher::Weak eventDispatcher,
const ContextContainer::Shared &contextContainer,
ComponentDescriptor::Flavor const &flavor = {})
: ConcreteComponentDescriptor<AndroidTextInputShadowNode>(
eventDispatcher,
contextContainer,
flavor) {}
protected:
void adopt(UnsharedShadowNode shadowNode) const override {
assert(std::dynamic_pointer_cast<AndroidTextInputShadowNode>(shadowNode));
auto concreteShadowNode =
std::static_pointer_cast<AndroidTextInputShadowNode>(shadowNode);
concreteShadowNode->setContextContainer(
const_cast<ContextContainer *>(getContextContainer().get()));
concreteShadowNode->dirtyLayout();
concreteShadowNode->enableMeasurement();
ConcreteComponentDescriptor::adopt(shadowNode);
}
};
} // namespace react
} // namespace facebook