Valentin Shergin 142dd7673e Fabric: UIManager::setNativeProps
Summary: Pretty straightforward wiring UIManager and the new feature in ShadowTree: we get the node, clone with the new props and then replace this.

Reviewed By: sahrens

Differential Revision: D13114788

fbshipit-source-id: 3a34fb879f3ec564c26278034a19b88518302de8
2018-11-27 18:03:27 -08:00

75 lines
2.1 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <folly/Optional.h>
#include <folly/dynamic.h>
#include <jsi/jsi.h>
#include <react/core/ShadowNode.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ShadowTreeRegistry.h>
#include <react/uimanager/UIManagerDelegate.h>
namespace facebook {
namespace react {
class UIManager {
public:
void setShadowTreeRegistry(ShadowTreeRegistry *shadowTreeRegistry);
void setComponentDescriptorRegistry(
const SharedComponentDescriptorRegistry &componentDescriptorRegistry);
/*
* Sets and gets the UIManager's delegate.
* The delegate is stored as a raw pointer, so the owner must null
* the pointer before being destroyed.
*/
void setDelegate(UIManagerDelegate *delegate);
UIManagerDelegate *getDelegate();
private:
friend class UIManagerBinding;
SharedShadowNode createNode(
Tag tag,
const std::string &name,
SurfaceId surfaceId,
const RawProps &props,
SharedEventTarget eventTarget) const;
SharedShadowNode cloneNode(
const SharedShadowNode &shadowNode,
const SharedShadowNodeSharedList &children = nullptr,
const folly::Optional<RawProps> &rawProps = {}) const;
void appendChild(
const SharedShadowNode &parentShadowNode,
const SharedShadowNode &childShadowNode) const;
void completeSurface(
SurfaceId surfaceId,
const SharedShadowNodeUnsharedList &rootChildren) const;
void setNativeProps(
const SharedShadowNode &shadowNode,
const RawProps &rawProps) const;
/*
* Returns layout metrics of given `shadowNode` relative to
* `ancestorShadowNode` (relative to the root node in case if provided
* `ancestorShadowNode` is nullptr).
*/
LayoutMetrics getRelativeLayoutMetrics(
const ShadowNode &shadowNode,
const ShadowNode *ancestorShadowNode) const;
ShadowTreeRegistry *shadowTreeRegistry_;
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
UIManagerDelegate *delegate_;
};
} // namespace react
} // namespace facebook