Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PaymentButton sizing issue #255

Merged
merged 9 commits into from
Feb 28, 2024
Merged

Fixed PaymentButton sizing issue #255

merged 9 commits into from
Feb 28, 2024

Conversation

stechiu
Copy link
Contributor

@stechiu stechiu commented Feb 16, 2024

Reason for changes

This PR is copied from the original #247, which was branched from next-major-version and we concluded that this change is non-breaking and should go into main. So this PR is branched from main

There was a sizing issue with the Payment Button when used in SwiftUI apps

  • The button couldn't be horizontally centered
  • The button frame took up the entirety of the screen size rather than hugging the button
  • If a button was added to a Form Section, the button wouldn't resize to fit the Section dimensions; instead, the size remained static

Summary of changes

  • This PR fixes the above issues
  • A dev won't be able to set the height to smaller than 38px or width shorter than 300px
  • PayLater and Credit are also displayed correctly in SwiftUI
Bug PR
Screenshot 2024-02-01 at 8 08 06 PM Screenshot 2024-02-16 at 2 38 27 PM

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@stechiu stechiu requested a review from a team as a code owner February 16, 2024 22:47
Sources/PaymentButtons/PayPalButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalCreditButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalCreditButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalPayLaterButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PayPalPayLaterButton.swift Outdated Show resolved Hide resolved
Sources/PaymentButtons/PaymentButton.swift Show resolved Hide resolved
Co-authored-by: Jax DesMarais-Leder <jdesmarais@paypal.com>
@@ -111,6 +111,7 @@ struct SwiftUIPaymentButtonDemo: View {
size: selectedSize
)
.id(buttonID)
.frame(maxWidth: .infinity)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these needed? I removed them and tested in canvas and sim and seem to be okay without these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not needed but I have them there so that people, internally and externally, who aren't familiar with SwiftUI know that you can set the button widths. Pre-PR, this part was broken and you couldn't customize the width in SwiftUI. If it feels redundant and unnecessary, I can remove it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to remove them if they're not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I'll update but will leave one of the in

@stechiu stechiu merged commit 15fa228 into main Feb 28, 2024
4 checks passed
@stechiu stechiu deleted the button-swiftui-size-bug branch February 28, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants