Skip to content

Commit

Permalink
Fix flow controller support in UPI (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
porter-stripe authored Oct 12, 2022
1 parent 498de94 commit 2c9bb00
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Stripe/PollingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,23 @@ class PollingViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
guard let parent = parent else {
assertionFailure("PollingViewController must have a parent view controller")
return
}
// Height of the polling view controller is either the height of the parent, or the height of the screen (flow controller use case)
let height = parent?.view.frame.size.height ?? UIScreen.main.bounds.height

let stackView = UIStackView(arrangedSubviews: [formStackView])
stackView.spacing = PaymentSheetUI.defaultPadding
stackView.axis = .vertical
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.backgroundColor = appearance.colors.background
view.backgroundColor = appearance.colors.background
view.addSubview(stackView)

NSLayoutConstraint.activate([
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
stackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
view.heightAnchor.constraint(equalToConstant: parent.view.frame.size.height - SheetNavigationBar.height), // polling view should always be the same height as the presenting view controller
view.heightAnchor.constraint(equalToConstant: height - SheetNavigationBar.height),
])
}

Expand Down

0 comments on commit 2c9bb00

Please sign in to comment.