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

pass content tapped in payment sheet #2231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extension PaymentSheet {
/// - Parameter content: The content of the view.
public struct PaymentButton<Content: View>: View {
private let paymentSheet: PaymentSheet
private let contentTapped: () -> Void
private let onCompletion: (PaymentSheetResult) -> Void
private let content: Content

Expand All @@ -110,17 +111,20 @@ extension PaymentSheet {
/// Initialize a `PaymentButton` with required parameters.
public init(
paymentSheet: PaymentSheet,
contentTapped: @escaping () -> Void,
onCompletion: @escaping (PaymentSheetResult) -> Void,
@ViewBuilder content: () -> Content
) {
self.paymentSheet = paymentSheet
self.contentTapped = contentTapped
self.onCompletion = onCompletion
self.content = content()
}

public var body: some View {
Button(action: {
showingPaymentSheet = true
contentTapped()
}) {
content
}.paymentSheet(
Expand Down