Skip to content

Commit

Permalink
fix payment sheet padding on SE
Browse files Browse the repository at this point in the history
  • Loading branch information
virginiacook committed Dec 12, 2023
1 parent cd0157d commit 9caeb8b
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,31 @@ class SheetFooterView: UIView {

private func setupConstraints() {
stackView.translatesAutoresizingMaskIntoConstraints = false

let bottomConstraint: NSLayoutConstraint

if #available(iOS 11.0, *) {
// Check if the device has a bottom safe area inset
if let window = UIApplication.shared.windows.first {
let bottomSafeAreaInset = window.safeAreaInsets.bottom
if bottomSafeAreaInset > 0 {
// Device has a bottom safe area inset, no need for additional padding
bottomConstraint = stackView.bottomAnchor.constraint(equalTo: bottomAnchor)
} else {
// Device does not have a bottom safe area inset, add padding
bottomConstraint = stackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -20)
}
}
} else {
// Fallback for earlier iOS versions
bottomConstraint = stackView.bottomAnchor.constraint(equalTo: bottomAnchor)
}

NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor)
bottomConstraint
])
}
}

0 comments on commit 9caeb8b

Please sign in to comment.