From f03147676b81f938c04c22525ffc60befd07441d Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Mon, 24 Jun 2024 10:50:01 -0500 Subject: [PATCH] Fix Constraints Error in `PayPalWebCheckoutViewController` (#1342) * fix constraints warning by adding leading and trailing constraints for nested stackViews * remove print statement --- Demo/Application/Base/AppDelegate.swift | 1 - .../PayPalWebCheckoutViewController.swift | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Demo/Application/Base/AppDelegate.swift b/Demo/Application/Base/AppDelegate.swift index 097d1b26da..182f8a15d8 100644 --- a/Demo/Application/Base/AppDelegate.swift +++ b/Demo/Application/Base/AppDelegate.swift @@ -64,7 +64,6 @@ import BraintreeCore if let preferences = settings.object(forKey: "PreferenceSpecifiers") as? Array<[String: Any]> { var defaultsToRegister: [String: Any] = [:] preferences.forEach { prefSpecification in - print(prefSpecification) if let key = prefSpecification["Key"] as? String, prefSpecification.keys.contains("DefaultValue") { defaultsToRegister[key] = prefSpecification["DefaultValue"] } diff --git a/Demo/Application/Features/PayPalWebCheckoutViewController.swift b/Demo/Application/Features/PayPalWebCheckoutViewController.swift index 4e1d137140..f42490775a 100644 --- a/Demo/Application/Features/PayPalWebCheckoutViewController.swift +++ b/Demo/Application/Features/PayPalWebCheckoutViewController.swift @@ -50,17 +50,28 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController { let payPalCheckoutButton = createButton(title: "PayPal Checkout", action: #selector(tappedPayPalCheckout)) let payPalVaultButton = createButton(title: "PayPal Vault", action: #selector(tappedPayPalVault)) let payPalAppSwitchButton = createButton(title: "PayPal App Switch", action: #selector(tappedPayPalAppSwitch)) + let oneTimeCheckoutStackView = buttonsStackView(label: "1-Time Checkout", views: [ + UIStackView(arrangedSubviews: [payLaterToggleLabel, payLaterToggle]), + UIStackView(arrangedSubviews: [newPayPalCheckoutToggleLabel, newPayPalCheckoutToggle]), + payPalCheckoutButton + ]) + let vaultStackView = buttonsStackView(label: "Vault",views: [payPalVaultButton, payPalAppSwitchButton]) + let stackView = UIStackView(arrangedSubviews: [ UIStackView(arrangedSubviews: [emailLabel, emailTextField]), - buttonsStackView(label: "1-Time Checkout", views: [ - UIStackView(arrangedSubviews: [payLaterToggleLabel, payLaterToggle]), - UIStackView(arrangedSubviews: [newPayPalCheckoutToggleLabel, newPayPalCheckoutToggle]), - payPalCheckoutButton - ]), - buttonsStackView(label: "Vault",views: [payPalVaultButton, payPalAppSwitchButton]) + oneTimeCheckoutStackView, + vaultStackView ]) - + + NSLayoutConstraint.activate([ + oneTimeCheckoutStackView.leadingAnchor.constraint(equalTo: stackView.leadingAnchor), + oneTimeCheckoutStackView.trailingAnchor.constraint(equalTo: stackView.trailingAnchor), + + vaultStackView.leadingAnchor.constraint(equalTo: stackView.leadingAnchor), + vaultStackView.trailingAnchor.constraint(equalTo: stackView.trailingAnchor) + ]) + stackView.axis = .vertical stackView.distribution = .fillProportionally stackView.spacing = 25