Skip to content

Commit

Permalink
fixing extending the separators to the trailing edge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Guretzki committed Feb 25, 2025
1 parent 48154b5 commit 31be901
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 11 additions & 1 deletion Adyen/UI/Form/FormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ internal final class FormView: UIView {
// MARK: - Properties

/// A Boolean value that determines whether the `FormView` is embedded in a `UIScrollView`
internal var isEmbeddedInScrollView: Bool = true
internal var isEmbeddedInScrollView: Bool = true {
didSet {
updateLayoutGuidePreservation()
}
}

/// Initializes the form view.
internal init() {
Expand Down Expand Up @@ -51,9 +55,15 @@ internal final class FormView: UIView {
// MARK: - Private

private func setup() {
updateLayoutGuidePreservation()
addSubviews()
setupLayout()
}

private func updateLayoutGuidePreservation() {
stackView.preservesSuperviewLayoutMargins = isEmbeddedInScrollView
self.preservesSuperviewLayoutMargins = isEmbeddedInScrollView
}

private func addSubviews() {
addSubview(stackView)
Expand Down
7 changes: 4 additions & 3 deletions Adyen/UI/Form/FormViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ open class FormViewController: UIViewController, AdyenObserver, PreferredContent

// MARK: - UI elements

private let scrollView: UIScrollView = {
private lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.preservesSuperviewLayoutMargins = true
return scrollView
}()

Expand Down Expand Up @@ -256,8 +257,8 @@ open class FormViewController: UIViewController, AdyenObserver, PreferredContent

NSLayoutConstraint.activate([
formView.topAnchor.constraint(equalTo: scrollView.topAnchor),
formView.leadingAnchor.constraint(equalTo: scrollView.layoutMarginsGuide.leadingAnchor),
formView.trailingAnchor.constraint(equalTo: scrollView.layoutMarginsGuide.trailingAnchor),
formView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
formView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
formView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor)
])
} else {
Expand Down

0 comments on commit 31be901

Please sign in to comment.