-
Notifications
You must be signed in to change notification settings - Fork 976
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 update pt 2 - update view #4150
Conversation
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.
Few non blocking Q's, nice!
StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Embedded/EmbeddedPaymentElement.swift
Show resolved
Hide resolved
/// The view that's vended to the merchant, containing the embedded view. We use this to be able to swap out the embedded view with an animation when `update` is called. | ||
class EmbeddedPaymentElementContainerView: UIView { | ||
var updateSuperviewHeight: () -> Void = {} | ||
var view: UIView |
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.
Any reason these aren't private (excluding updateSuperviewHeight
, although that feels like it should come in at init time and be optional)? Also wondering it it ever makes sense to use this class when view
is not of type EmbeddedPaymentMethodsView
. Should it just be EmbeddedPaymentMethodsView
over UIView
in this class?
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.
updateSuperviewHeight
is a var for convenience; self
isn't available when EmbeddedPaymentElement
initializes this.
Will make them private & change the UIView type though!
@_spi(STP) @testable import StripeUICore | ||
import XCTest | ||
|
||
class EmbeddedPaymentElementSnapshotTests: STPSnapshotTestCase, EmbeddedPaymentElementDelegate { |
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.
Are we planning to add more tests to this file? If so do we have a ticket or will that happen as a follow up?
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.
Yep will add more tests with the next PRs (see bullets in summary)!
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.
ACK, saw bullets just didn't think they'd be snapshot tests? Haven't thought much about 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.
Oh, missed "in this file". I think we'll eventually add but I don't have any specific tests in mind for update
.
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.
Is all the transparent padding expected? Would that be the merchant's UI/background in the real world?
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.
Padding is expected; that is the default layoutMargins
. Whether it should be transparent or appearance.colors.background, IDK. But the background color of the view can be set by the merchant so I think it doesn't matter?
StripePaymentSheet- public var paymentMethodLayout: StripePaymentSheet.PaymentSheet.PaymentMethodLayout
- public enum PaymentMethodLayout {
- case horizontal
- case vertical
- case automatic
- public static func == (a: StripePaymentSheet.PaymentSheet.PaymentMethodLayout, b: StripePaymentSheet.PaymentSheet.PaymentMethodLayout) -> Swift.Bool
- public func hash(into hasher: inout Swift.Hasher)
- public var hashValue: Swift.Int {
- get
- }
- } If you are adding a new public API consider the following:
If you are modifying or removing a public API:
If you confirm these APIs need to be added/updated and have undergone necessary review, add the label ℹ️ If this comment appears to be left in error, make sure your branch is up-to-date with |
## Summary Previous PR: #4150 Makes EmbeddedPaymentElement view a view that contains embedded view so we can swap to the updated embedded view with an animation. Makes EmbeddedPaymentElement restore previous customer in **_payment method list selection_ (1)** on `update`, call `didUpdateHeight` and `didUpdatePaymentOption` if necessary. Still to come: - Restore previous customer input in ***form (2)*** + E2E tests (e.g. load PI -> fill out card form -> update to SI -> expect form to be preserved but w/o checkbox) - Make confirm handle in-flight and failed update calls. - (Bonus) Cancel network calls etc. from previous update to reduce battery/network usage. Can apply this to FC.update as well. ## Motivation https://jira.corp.stripe.com/browse/MOBILESDK-2583 ## Testing See test ## Changelog Not user facing
Summary
Previous PR: #4141
Makes EmbeddedPaymentElement view a view that contains embedded view so we can swap to the updated embedded view with an animation.
Simulator.Screen.Recording.-.snapshot.tester.iPhone.12.mini.16.4.-.2024-10-16.at.11.40.47.mp4
Still to come:
Motivation
https://jira.corp.stripe.com/browse/MOBILESDK-2583
Testing
See snapshot test.
Changelog
Not user facing