Skip to content

Commit 8d8b8f3

Browse files
javachemeta-codesync[bot]
authored andcommitted
Fix native RNTester tabs in Buck builds (#58900)
Summary: Pull Request resolved: #58900 Internal Buck builds did not link the RNTesterTabsIOS component, so React Native rendered the component as an unimplemented placeholder. Link the component and its Fabric plugin into the RNTester Apple target. Keep compact bottom-tab content aligned with the previous RNTester chrome so existing example screenshot bounds remain stable. Changelog: [Internal] Differential Revision: D123770213 fbshipit-source-id: 9892cbe1b15a075ed489fa44c16ac349050fc19a
1 parent 30e2d93 commit 8d8b8f3

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

‎packages/rn-tester/RNTesterTabsIOS/ios/RNTesterTabsIOSComponentView.mm‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@
1414
#import <react/renderer/components/AppSpecs/EventEmitters.h>
1515
#import <react/renderer/components/AppSpecs/Props.h>
1616

17+
#if __has_include(<React/RCTFabricComponentsPlugins.h>)
18+
#import <React/RCTFabricComponentsPlugins.h>
19+
#else
20+
#import "RCTFabricComponentsPlugins.h"
21+
#endif
22+
1723
using namespace facebook::react;
1824

25+
// Preserve RNTester's existing example bounds on compact bottom-tab layouts.
26+
static constexpr CGFloat LegacyTopInset = 50;
27+
static constexpr CGFloat LegacyBottomInset = 65;
28+
1929
/**
2030
* A tab's view controller, which reports when the tab bar or window changes
2131
* the area its content needs to clear.
@@ -205,17 +215,20 @@ - (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter
205215

206216
- (void)tabSafeAreaInsetsDidChange:(UIEdgeInsets)insets
207217
{
208-
// The home indicator's inset only applies beneath a tab bar along the bottom edge, which already
209-
// clears it. With the tab bar at the side, content runs to the bottom edge.
210218
CGRect tabBarFrame = _tabBarController.tabBar.frame;
211219
CGRect bounds = _tabBarController.view.bounds;
212-
if (CGRectGetWidth(tabBarFrame) < CGRectGetWidth(bounds) || CGRectGetMaxY(tabBarFrame) < CGRectGetMaxY(bounds)) {
220+
BOOL hasBottomTabBar = !_tabBarController.tabBar.hidden && CGRectGetWidth(tabBarFrame) >= CGRectGetWidth(bounds) &&
221+
CGRectGetMaxY(tabBarFrame) >= CGRectGetMaxY(bounds);
222+
if (hasBottomTabBar) {
223+
insets.top = MAX(insets.top, LegacyTopInset);
224+
insets.bottom = MIN(insets.bottom, LegacyBottomInset);
225+
} else {
213226
insets.bottom = 0;
214-
}
215-
// A window with no status bar along the top, such as the iPhone Duo's, reports no top inset. Keep
216-
// content a small distance from the display's rounded top edge.
217-
if (insets.top == 0) {
218-
insets.top = 16;
227+
// A window with no status bar along the top, such as the iPhone Duo's, reports no top inset. Keep
228+
// content a small distance from the display's rounded top edge.
229+
if (insets.top == 0) {
230+
insets.top = 16;
231+
}
219232
}
220233
if (UIEdgeInsetsEqualToEdgeInsets(insets, _contentInsets) || _eventEmitter == nullptr) {
221234
return;

0 commit comments

Comments
 (0)