-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add custom corner radius for PaymentButtons #229
Conversation
@@ -12,6 +12,9 @@ public enum PaymentButtonEdges: Int { | |||
/// Pill shaped corner radius. | |||
case rounded | |||
|
|||
/// Custom corner radius. | |||
case custom(CGFloat) | |||
|
|||
func cornerRadius(for view: UIView) -> CGFloat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func cornerRadius(for view: UIView) -> CGFloat { | |
func cornerRadius(for buttonSize: CGRect) -> CGFloat { |
🧶 : Might be overkill, but it would remove need for import UIKit
for this enum.
Stepper("Custom Corner Radius: \(customEdge)", value: $customEdge, in: 0...100).onChange(of: customEdge) { _ in | ||
if selectedEdge.description == "custom" { | ||
selectedEdge = PaymentButtonEdges.custom(CGFloat(customEdge)) | ||
buttonId += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious q: is button ID used by SwiftUI to re-render?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buttonId += 1 | |
buttonID += 1 |
Also side note our team uses ID
naming convention for iOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious q: is button ID used by SwiftUI to re-render?
Yeah the views use the buttonId
as their .id()
and it triggers a re-render
Also side note our team uses ID naming convention for iOS.
It was already declared I can change it though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and tested in demo app. LGTM
Changes LGTM! Wanted to call out that we technically can target this for I also understand if we want to keep all PaymentButton related changes in V2, though |
@@ -63,7 +64,12 @@ struct SwiftUIPaymentButtonDemo: View { | |||
selectedEdge = PaymentButtonEdges.allCases[edgesIndex] | |||
buttonId += 1 | |||
} | |||
|
|||
Stepper("Custom Corner Radius: \(customEdge)", value: $customEdge, in: 0...100).onChange(of: customEdge) { _ in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very neat!
Looks like this equivalent change went into |
Reason for changes
To allow consumers of the SDK to use a custom
cornerRadius
for thePaymentButton
Summary of changes
custom(CGFloat)
case toPaymentButtonEdges
Checklist
Authors