Skip to content

Commit

Permalink
fix(iOS): remove deprecated method from RCTPerfMonitor & fix position (
Browse files Browse the repository at this point in the history
…facebook#43058)

Summary:
This PR removes usage of deprecated `statusBarFrame` method in `RCTPerfMonitor` . Instead `RCTPerfMonitor` now uses `safeAreaInsets` which also fixes issue causing Perf Monitor to appear under corner in landscape mode on e.g. `iPhone 15 Pro`. It also fixes initial position of expanded state which was causing it to render under notch.

Also removed duplicate background color setting

## Changelog:
[IOS] [REMOVED] - Remove usage of deprecated statusBarFrame method
[IOS] [FIXED] - Fix position of RCTPerfMonitor in landscape mode & expanded mode

Pull Request resolved: facebook#43058

Test Plan: `RNTester` builds and runs successfully, `RCTPerfMonitor` works and displays correctly

Reviewed By: dmytrorykun

Differential Revision: D59116913

Pulled By: cipolleschi

fbshipit-source-id: 0ff61f61b206c530cfb9e471bc2dc33a0a43c833
  • Loading branch information
krozniata authored and facebook-github-bot committed Jul 8, 2024
1 parent 8c8c77b commit 258f41a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/react-native/React/CoreModules/RCTPerfMonitor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,15 @@ - (UIPanGestureRecognizer *)gestureRecognizer
- (UIView *)container
{
if (!_container) {
CGSize statusBarSize = RCTUIStatusBarManager().statusBarFrame.size;
CGFloat statusBarHeight = statusBarSize.height;
_container = [[UIView alloc] initWithFrame:CGRectMake(10, statusBarHeight, 180, RCTPerfMonitorBarHeight)];
UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;

_container =
[[UIView alloc] initWithFrame:CGRectMake(safeInsets.left, safeInsets.top, 180, RCTPerfMonitorBarHeight)];
_container.layer.borderWidth = 2;
_container.layer.borderColor = [UIColor lightGrayColor].CGColor;
[_container addGestureRecognizer:self.gestureRecognizer];
[_container addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)]];

_container.backgroundColor = [UIColor whiteColor];

_container.backgroundColor = [UIColor systemBackgroundColor];
}

Expand Down Expand Up @@ -449,7 +448,9 @@ - (void)tap
{
[self loadPerformanceLoggerData];
if (CGRectIsEmpty(_storedMonitorFrame)) {
_storedMonitorFrame = CGRectMake(0, 20, self.container.window.frame.size.width, RCTPerfMonitorExpandHeight);
UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;
_storedMonitorFrame =
CGRectMake(safeInsets.left, safeInsets.top, self.container.window.frame.size.width, RCTPerfMonitorExpandHeight);
[self.container addSubview:self.metrics];
} else {
[_metrics reloadData];
Expand Down

0 comments on commit 258f41a

Please sign in to comment.