-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathRNSScreenStackHeaderConfigComponentDescriptor.h
More file actions
59 lines (49 loc) · 1.96 KB
/
RNSScreenStackHeaderConfigComponentDescriptor.h
File metadata and controls
59 lines (49 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#ifdef ANDROID
#include <fbjni/fbjni.h>
#endif
#include <react/debug/react_native_assert.h>
#include <react/renderer/components/rnscreens/Props.h>
#include <react/renderer/components/rnscreens/utils/RectUtil.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include "RNSScreenStackHeaderConfigShadowNode.h"
namespace facebook::react {
using namespace rnscreens;
class RNSScreenStackHeaderConfigComponentDescriptor final
: public ConcreteComponentDescriptor<RNSScreenStackHeaderConfigShadowNode> {
public:
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
void adopt(ShadowNode &shadowNode) const override {
react_native_assert(
dynamic_cast<RNSScreenStackHeaderConfigShadowNode *>(&shadowNode));
auto &configShadowNode =
static_cast<RNSScreenStackHeaderConfigShadowNode &>(shadowNode);
react_native_assert(
dynamic_cast<YogaLayoutableShadowNode *>(&configShadowNode));
auto &layoutableShadowNode =
dynamic_cast<YogaLayoutableShadowNode &>(configShadowNode);
auto state = std::static_pointer_cast<
const RNSScreenStackHeaderConfigShadowNode::ConcreteState>(
shadowNode.getState());
auto stateData = state->getData();
#ifdef ANDROID
if (stateData.frameSize.width != 0) {
layoutableShadowNode.setSize({stateData.frameSize.width, YGUndefined});
configShadowNode.setLogicalPadding(
stateData.paddingStart, stateData.paddingEnd);
}
#else
if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) {
layoutableShadowNode.setSize(stateData.frameSize);
layoutableShadowNode.setPadding(stateData.edgeInsets);
}
#endif // ANDROID
ConcreteComponentDescriptor::adopt(shadowNode);
#if !defined(ANDROID)
std::weak_ptr<void> imageLoader =
contextContainer_->at<std::shared_ptr<void>>("RCTImageLoader");
configShadowNode.setImageLoader(imageLoader);
#endif // !ANDROID
}
};
} // namespace facebook::react