Skip to content

Commit c406ef5

Browse files
authored
Factor in space for top safe area insets into max height calculations in Modal and ImageOnly messages (#3957)
1 parent 391271a commit c406ef5

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Firebase/InAppMessagingDisplay/ImageOnly/FIDImageOnlyViewController.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ - (void)viewDidLayoutSubviews {
114114
CGFloat maxImageViewWidth = self.view.window.frame.size.width - minimalMargine * 2;
115115
CGFloat maxImageViewHeight = self.view.window.frame.size.height - minimalMargine * 2;
116116

117+
// Factor in space for the top notch on iPhone X*.
118+
#if defined(__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
119+
if (@available(iOS 11.0, *)) {
120+
maxImageViewHeight -= self.view.safeAreaInsets.top;
121+
}
122+
#endif // defined(__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
123+
117124
CGFloat adjustedImageViewHeight = self.imageOriginalSize.height;
118125
CGFloat adjustedImageViewWidth = self.imageOriginalSize.width;
119126

Firebase/InAppMessagingDisplay/Modal/FIDModalViewController.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,21 @@ - (void)layoutFineTuneInPortraitMode {
266266
// for tablet case, since we use a fixed card height, the reference would be just the card height
267267
// for non-tablet case, we want to use a dynamic height , so the reference would be the window
268268
// height
269-
CGFloat heightCalcReference =
270-
self.messageCardHeightMaxInTabletCase.active
271-
? self.messageCardView.frame.size.height - TopBottomPaddingAroundContent * 2
272-
: self.view.window.frame.size.height - TopBottomPaddingAroundContent * 2 -
273-
TopBottomPaddingAroundMsgCard * 2;
269+
CGFloat heightCalcReference = 0;
270+
if (self.messageCardHeightMaxInTabletCase.active) {
271+
heightCalcReference =
272+
self.messageCardView.frame.size.height - TopBottomPaddingAroundContent * 2;
273+
} else {
274+
heightCalcReference = self.view.window.frame.size.height - TopBottomPaddingAroundContent * 2 -
275+
TopBottomPaddingAroundMsgCard * 2;
276+
277+
// Factor in space for the top notch on iPhone X*.
278+
#if defined(__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
279+
if (@available(iOS 11.0, *)) {
280+
heightCalcReference -= self.view.safeAreaInsets.top;
281+
}
282+
#endif // defined(__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
283+
}
274284

275285
FIRLogDebug(kFIRLoggerInAppMessagingDisplay, @"I-FID300004",
276286
@"The height calc reference is %lf "

0 commit comments

Comments
 (0)