/* * 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 #include #include #include #include #include #include #include namespace facebook { namespace react { /* * Template for all -like classes (classes which have all same props * as and similar basic behaviour). * For example: , , but not , . */ template < const char *concreteComponentName, typename ViewPropsT = ViewProps, typename ViewEventEmitterT = ViewEventEmitter, typename... Ts> class ConcreteViewShadowNode : public ConcreteShadowNode< concreteComponentName, YogaLayoutableShadowNode, ViewPropsT, ViewEventEmitterT, Ts...> { static_assert( std::is_base_of::value, "ViewPropsT must be a descendant of ViewProps"); static_assert( std::is_base_of::value, "ViewPropsT must be a descendant of YogaStylableProps"); static_assert( std::is_base_of::value, "ViewPropsT must be a descendant of AccessibilityProps"); public: using BaseShadowNode = ConcreteShadowNode< concreteComponentName, YogaLayoutableShadowNode, ViewPropsT, ViewEventEmitterT, Ts...>; ConcreteViewShadowNode( ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, ShadowNodeTraits traits) : BaseShadowNode(fragment, family, traits) { initialize(); } ConcreteViewShadowNode( ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment) : BaseShadowNode(sourceShadowNode, fragment) { initialize(); } using ConcreteViewProps = ViewPropsT; using BaseShadowNode::BaseShadowNode; static ShadowNodeTraits BaseTraits() { auto traits = BaseShadowNode::BaseTraits(); traits.set(ShadowNodeTraits::Trait::ViewKind); traits.set(ShadowNodeTraits::Trait::FormsStackingContext); traits.set(ShadowNodeTraits::Trait::FormsView); return traits; } Transform getTransform() const override { return BaseShadowNode::getConcreteProps().transform; } #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE SharedDebugStringConvertibleList getDebugProps() const override { auto list = SharedDebugStringConvertibleList{}; auto basePropsList = ShadowNode::getDebugProps(); std::move( basePropsList.begin(), basePropsList.end(), std::back_inserter(list)); list.push_back(std::make_shared( "layout", "", LayoutableShadowNode::getDebugProps())); return list; } #endif private: void initialize() noexcept { BaseShadowNode::orderIndex_ = BaseShadowNode::getConcreteProps().zIndex; } }; } // namespace react } // namespace facebook