Skip to content

Commit 3e638aa

Browse files
committed
[wip]: maybe in layout method
1 parent 94ca492 commit 3e638aa

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

packages/react-native-bottom-tabs/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,33 @@ namespace facebook::react {
55
extern const char RNCTabViewComponentName[] = "RNCTabView";
66

77
void RNCTabViewShadowNode::updateStateIfNeeded() {
8-
ensureUnsealed();
8+
// ensureUnsealed();
9+
// const auto &stateData = getStateData();
10+
// auto frameSize = stateData.frameSize;
11+
//
12+
// for (auto &child : getLayoutableChildNodes()) {
13+
// auto yogaChild = dynamic_cast<YogaLayoutableShadowNode*>(child);
14+
// yogaChild->getState();
15+
// if (!yogaChild->getSealed() && yogaChild->getLayoutMetrics().frame.size != frameSize) {
16+
// yogaChild->setSize(frameSize);
17+
// }
18+
// }
19+
20+
};
21+
22+
void RNCTabViewShadowNode::layout(facebook::react::LayoutContext layoutContext) {
23+
YogaLayoutableShadowNode::layout(layoutContext);
24+
25+
// Now adjust children as needed
926
const auto &stateData = getStateData();
1027
auto frameSize = stateData.frameSize;
1128

12-
for (auto &child : getLayoutableChildNodes()) {
13-
auto yogaChild = dynamic_cast<YogaLayoutableShadowNode*>(child);
14-
if (!yogaChild->getSealed() && yogaChild->getLayoutMetrics().frame.size != frameSize) {
15-
yogaChild->setSize(frameSize);
16-
}
29+
for (auto childNode : getLayoutableChildNodes()) {
30+
childNode->ensureUnsealed();
31+
auto yogaChild = dynamic_cast<YogaLayoutableShadowNode*>(childNode);
32+
yogaChild->setSize(frameSize);
33+
1734
}
18-
};
35+
}
1936

2037
}

packages/react-native-bottom-tabs/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <react/renderer/components/RNCTabView/Props.h>
88
#include <react/renderer/components/RNCTabView/EventEmitters.h>
99
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
10+
#include <react/renderer/core/LayoutContext.h>
11+
#include <react/renderer/core/LayoutConstraints.h>
1012

1113
namespace facebook::react {
1214

@@ -26,6 +28,10 @@ RNCTabViewState>
2628
using ConcreteViewShadowNode::ConcreteViewShadowNode;
2729

2830
void updateStateIfNeeded();
31+
32+
#pragma mark - ShadowNode overrides
33+
34+
void layout(LayoutContext layoutContext) override;
2935
};
3036
}
3137

0 commit comments

Comments
 (0)