|
14 | 14 | #import <react/renderer/components/AppSpecs/EventEmitters.h> |
15 | 15 | #import <react/renderer/components/AppSpecs/Props.h> |
16 | 16 |
|
| 17 | +#if __has_include(<React/RCTFabricComponentsPlugins.h>) |
| 18 | +#import <React/RCTFabricComponentsPlugins.h> |
| 19 | +#else |
| 20 | +#import "RCTFabricComponentsPlugins.h" |
| 21 | +#endif |
| 22 | + |
17 | 23 | using namespace facebook::react; |
18 | 24 |
|
| 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 | + |
19 | 29 | /** |
20 | 30 | * A tab's view controller, which reports when the tab bar or window changes |
21 | 31 | * the area its content needs to clear. |
@@ -205,17 +215,20 @@ - (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter |
205 | 215 |
|
206 | 216 | - (void)tabSafeAreaInsetsDidChange:(UIEdgeInsets)insets |
207 | 217 | { |
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. |
210 | 218 | CGRect tabBarFrame = _tabBarController.tabBar.frame; |
211 | 219 | 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 { |
213 | 226 | 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 | + } |
219 | 232 | } |
220 | 233 | if (UIEdgeInsetsEqualToEdgeInsets(insets, _contentInsets) || _eventEmitter == nullptr) { |
221 | 234 | return; |
|
0 commit comments