Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@
#import <react/renderer/components/AppSpecs/EventEmitters.h>
#import <react/renderer/components/AppSpecs/Props.h>

#if __has_include(<React/RCTFabricComponentsPlugins.h>)
#import <React/RCTFabricComponentsPlugins.h>
#else
#import "RCTFabricComponentsPlugins.h"
#endif

using namespace facebook::react;

// Preserve RNTester's existing example bounds on compact bottom-tab layouts.
static constexpr CGFloat LegacyTopInset = 50;
static constexpr CGFloat LegacyBottomInset = 65;

/**
* A tab's view controller, which reports when the tab bar or window changes
* the area its content needs to clear.
Expand Down Expand Up @@ -205,17 +215,20 @@ - (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter

- (void)tabSafeAreaInsetsDidChange:(UIEdgeInsets)insets
{
// The home indicator's inset only applies beneath a tab bar along the bottom edge, which already
// clears it. With the tab bar at the side, content runs to the bottom edge.
CGRect tabBarFrame = _tabBarController.tabBar.frame;
CGRect bounds = _tabBarController.view.bounds;
if (CGRectGetWidth(tabBarFrame) < CGRectGetWidth(bounds) || CGRectGetMaxY(tabBarFrame) < CGRectGetMaxY(bounds)) {
BOOL hasBottomTabBar = !_tabBarController.tabBar.hidden && CGRectGetWidth(tabBarFrame) >= CGRectGetWidth(bounds) &&
CGRectGetMaxY(tabBarFrame) >= CGRectGetMaxY(bounds);
if (hasBottomTabBar) {
insets.top = MAX(insets.top, LegacyTopInset);
insets.bottom = MIN(insets.bottom, LegacyBottomInset);
} else {
insets.bottom = 0;
}
// A window with no status bar along the top, such as the iPhone Duo's, reports no top inset. Keep
// content a small distance from the display's rounded top edge.
if (insets.top == 0) {
insets.top = 16;
// A window with no status bar along the top, such as the iPhone Duo's, reports no top inset. Keep
// content a small distance from the display's rounded top edge.
if (insets.top == 0) {
insets.top = 16;
}
}
if (UIEdgeInsetsEqualToEdgeInsets(insets, _contentInsets) || _eventEmitter == nullptr) {
return;
Expand Down
Loading