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

Embedded SwiftUI example #4445

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

porter-stripe
Copy link
Collaborator

Summary

  • Adds a sample SwiftUI integration with embedded
  • Does not define the public API for the SwiftUI helpers yet. But we will likely expose something like EmbeddedPaymentElementView and a lightweight EmbeddedPaymentViewModel.
  • Few highlights/notable things
    • Use of a container view in makeUIView is required. Instead of directly attaching the embedded view to SwiftUI, we use a container. This container gives us a fixed point to apply layout constraints and measure the embedded view's size. If we skipped the container and used the embedded view directly, its height would be undefined, causing constraint breakages and leading SwiftUI to treat it as zero.
    • Passing a binding between the UIViewRepresentable and the SwiftUI: There is a workaround that would allow us to remove this, but we lose the ability to animate smoothly. Passing this binding to the SwfitUI view allows us to animate the height.

Payment

Simulator.Screen.Recording.-.iOS.18.-.2025-01-08.at.10.07.20.mp4

Height animation

Simulator.Screen.Recording.-.iOS.18.-.2025-01-08.at.10.08.43.mp4

Motivation

  • Embedded GA

Testing

  • Manual

Changelog

N/A

@porter-stripe porter-stripe marked this pull request as ready for review January 8, 2025 18:22
@porter-stripe porter-stripe requested review from a team as code owners January 8, 2025 18:22
@porter-stripe porter-stripe removed the request for review from yuki-stripe January 9, 2025 17:55
Copy link

github-actions bot commented Jan 9, 2025

🚨 New dead code detected in this PR:

EmbeddedPaymentElement.swift:485 warning: Parameter 'embeddedPaymentElement' is unused
EmbeddedPaymentElementDelegate.swift:27 warning: Parameter 'embeddedPaymentElement' is unused

Please remove the dead code before merging.

If this is intentional, you can bypass this check by adding the label skip dead code check to this PR.

ℹ️ If this comment appears to be left in error, double check that the flagged code is actually used and/or make sure your branch is up-to-date with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant