Skip to content

Commit 94ecdca

Browse files
authored
fix(iPhone X): Fix for bottom area padding for accept button on iPhone X. (#138)
* add bottom padding based on safe area * use common method
1 parent 55a61ec commit 94ecdca

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Leanplum-SDK/Classes/LPMessageTemplates.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,10 +1036,7 @@ - (void)updateHtmlLayoutWithContext:(LPActionContext *)context
10361036
CGFloat htmlHeight = [[context numberNamed:LPMT_ARG_HTML_HEIGHT] doubleValue];
10371037
BOOL isFullscreen = htmlHeight < 1;
10381038
BOOL isIPhoneX = statusBarHeight > 40;
1039-
CGFloat bottomSafeAreaHeight = 0;
1040-
if (@available(iOS 11.0, *)) {
1041-
bottomSafeAreaHeight = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom;
1042-
}
1039+
CGFloat bottomSafeAreaHeight = [self safeAreaInsets].bottom;
10431040

10441041
// Banner logic.
10451042
if (!isFullscreen) {
@@ -1154,7 +1151,7 @@ - (void)updateNonWebPopupLayout:(int)statusBarHeight
11541151
} else {
11551152
_acceptButton.frame = CGRectMake(
11561153
(_popupView.frame.size.width - textSize.width - 2*LPMT_ACCEPT_BUTTON_MARGIN) / 2,
1157-
_popupView.frame.size.height - textSize.height - 3*LPMT_ACCEPT_BUTTON_MARGIN,
1154+
_popupView.frame.size.height - textSize.height - 3*LPMT_ACCEPT_BUTTON_MARGIN - [self safeAreaInsets].bottom,
11581155
textSize.width + 2*LPMT_ACCEPT_BUTTON_MARGIN,
11591156
textSize.height + 2*LPMT_ACCEPT_BUTTON_MARGIN);
11601157
}
@@ -1224,6 +1221,16 @@ - (void)refreshPopupContent
12241221
}
12251222
}
12261223

1224+
-(UIEdgeInsets)safeAreaInsets
1225+
{
1226+
UIEdgeInsets insets = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
1227+
if (@available(iOS 11.0, *)) {
1228+
insets = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
1229+
}
1230+
return insets;
1231+
}
1232+
1233+
12271234
- (void)appStorePrompt
12281235
{
12291236
dispatch_async(dispatch_get_main_queue(), ^{

0 commit comments

Comments
 (0)