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 42 commits into
base: master
Choose a base branch
from
Open

Conversation

porter-stripe
Copy link
Collaborator

@porter-stripe porter-stripe commented Jan 8, 2025

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.
  • Adds 1 E2E UI test for SwiftUI example and some snapshot tests.

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

Updates

Simulator.Screen.Recording.-.iOS.18.-.2025-01-10.at.10.48.30.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
@stripe stripe deleted a comment from github-actions bot Jan 10, 2025
Copy link

github-actions bot commented Jan 15, 2025

🚨 New dead code detected in this PR:

EmbeddedPaymentElement+SwiftUI.swift:205 warning: Property 'parent' is assigned, but never used

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.

@stripe stripe deleted a comment from github-actions bot Jan 15, 2025
Copy link

emerge-tools bot commented Jan 16, 2025

1 build increased size, 2 builds decreased size, 5 builds had no size change

Name Version Download Change Install Change Approval
StripeSize
com.stripe.StripeSize
1.0 (1) 2.1 MB ⬇️ 9 B 6.9 MB - N/A
StripePaymentsSize
com.stripe.StripePaymentsSize
1.0 (1) 1.2 MB - 4.2 MB - N/A
StripePaymentsUISize
com.stripe.StripePaymentsUISize
1.0 (1) 1.9 MB ⬇️ 4 B 6.4 MB - N/A
StripePaymentSheetSize
com.stripe.StripePaymentSheetSize
1.0 (1) 3.7 MB ⬆️ 8.4 kB (0.23%) 11.1 MB ⬆️ 26.1 kB (0.24%) N/A
StripeIdentitySize
com.stripe.StripeIdentitySize
1.0 (1) 1.4 MB ⬇️ 1 B 4.3 MB - N/A
StripeApplePaySize
com.stripe.StripeApplePaySize
1.0 (1) 484.8 kB - 1.7 MB - N/A
StripeFinancialConnectionsSize
com.stripe.StripeFinancialConnectionsSize
1.0 (1) 1.4 MB ⬇️ 66.3 kB (-4.53%) 4.5 MB ⬇️ 191.4 kB (-4.1%) N/A
StripeConnectSize
com.stripe.StripeConnectSize
1.0 (1) 1.6 MB ⬇️ 67.6 kB (-4.16%) 5.0 MB ⬇️ 193.3 kB (-3.74%) N/A

StripeSize 1.0 (1)
com.stripe.StripeSize

No changes to report

StripePaymentsSize 1.0 (1)
com.stripe.StripePaymentsSize

No changes to report

StripePaymentsUISize 1.0 (1)
com.stripe.StripePaymentsUISize

No changes to report

StripePaymentSheetSize 1.0 (1)
com.stripe.StripePaymentSheetSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 26.1 kB (0.24%)
Total download size change: ⬆️ 8.4 kB (0.23%)

Largest size changes

Item Install Size Change
📝 StripePaymentSheet.EmbeddedPaymentElementViewModel.EmbeddedPaymen... ⬆️ 2.3 kB
DYLD.Exports ⬆️ 1.7 kB
DYLD.Fixups ⬆️ 1.5 kB
DYLD.String Table ⬆️ 1.4 kB
StripePaymentSheet.EmbeddedFormViewController.paymentMethodFormVi... ⬇️ -1.4 kB
View Treemap

Image of diff

StripeIdentitySize 1.0 (1)
com.stripe.StripeIdentitySize

No changes to report

StripeApplePaySize 1.0 (1)
com.stripe.StripeApplePaySize

No changes to report

StripeFinancialConnectionsSize 1.0 (1)
com.stripe.StripeFinancialConnectionsSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 191.4 kB (-4.1%)
Total download size change: ⬇️ 66.3 kB (-4.53%)

Largest size changes

Item Install Size Change
🗑 StripeFinancialConnections.FinancialConnectionsAsyncAPIClient ⬇️ -13.5 kB
Swift._NativeDictionary.merge(isUnique,uniquingKeysWith) ⬇️ -4.4 kB
Code Signature ⬇️ -4.2 kB
📝 StripeFinancialConnections.NativeFlowAPIDataManager.manifest.dids... ⬆️ 2.0 kB
StripeFinancialConnections.NativeFlowAPIDataManager.init(manifest... ⬆️ 1.8 kB
View Treemap

Image of diff

StripeConnectSize 1.0 (1)
com.stripe.StripeConnectSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 193.3 kB (-3.74%)
Total download size change: ⬇️ 67.6 kB (-4.16%)

Largest size changes

Item Install Size Change
🗑 StripeFinancialConnections.FinancialConnectionsAsyncAPIClient ⬇️ -13.6 kB
Code Signature ⬇️ -5.0 kB
Swift._NativeDictionary.merge(isUnique,uniquingKeysWith) ⬇️ -4.4 kB
📝 StripeFinancialConnections.NativeFlowAPIDataManager.manifest.dids... ⬆️ 2.0 kB
StripeFinancialConnections.NativeFlowAPIDataManager.init(manifest... ⬆️ 1.8 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

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