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

Link v3: Add components for card editing and verification #4158

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

davidme-stripe
Copy link
Contributor

Summary

Add Card Edit, Payment Method Picker, and Verification components.

Motivation

Link v3

Testing

Added snapshot tests.

Changelog

None

@davidme-stripe davidme-stripe changed the base branch from master to relink/datamodel October 17, 2024 22:16
Copy link

emerge-tools bot commented Oct 17, 2024

⚠️ 1 new unused protocol, 1 build increased size, 5 builds had no size change

Name Version Download Change Install Change Approval
StripeSize
com.stripe.StripeSize
1.0 (1) 2.1 MB ⬇️ 6 B 6.8 MB - N/A
StripeApplePaySize
com.stripe.StripeApplePaySize
1.0 (1) 438.1 kB - 1.6 MB - N/A
StripeFinancialConnectionsSize
com.stripe.StripeFinancialConnectionsSize
1.0 (1) 1.3 MB ⬇️ 1 B 4.3 MB - N/A
StripePaymentsSize
com.stripe.StripePaymentsSize
1.0 (1) 1.2 MB - 4.1 MB - N/A
StripePaymentsUISize
com.stripe.StripePaymentsUISize
1.0 (1) 1.9 MB ⬇️ 2 B 6.3 MB - N/A
StripePaymentSheetSize
com.stripe.StripePaymentSheetSize
1.0 (1) 3.5 MB ⬆️ 59.0 kB (1.7%) 10.6 MB ⬆️ 137.7 kB (1.33%) N/A

StripeSize 1.0 (1)
com.stripe.StripeSize

No changes to report

StripeApplePaySize 1.0 (1)
com.stripe.StripeApplePaySize

No changes to report

StripeFinancialConnectionsSize 1.0 (1)
com.stripe.StripeFinancialConnectionsSize

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: ⬆️ 137.7 kB (1.33%)
Total download size change: ⬆️ 59.0 kB (1.7%)

Largest size changes

Item Install Size Change
Localizable.strings ⬆️ 4.1 kB
Code Signature ⬆️ 3.3 kB
📝 StripePaymentSheet.LinkPaymentMethodPicker.Cell.setupUI ⬆️ 3.0 kB
📝 StripePaymentSheet.LinkUI.appearance ⬆️ 2.4 kB
📝 StripePaymentSheet.LinkPaymentMethodPicker.CellContentView.iconCo... ⬆️ 2.3 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

Copy link

github-actions bot commented Oct 17, 2024

🚨 New dead code detected in this PR:

LinkPaymentMethodPicker-Cell.swift:25 warning: Property 'menuSpacing' is unused
LinkPaymentMethodPicker-Cell.swift:244 warning: Parameter 'sender' is unused
LinkPaymentMethodPicker-Header.swift:71 warning: Property 'cardNumberLabel' is unused
LinkPaymentMethodPicker.swift:175 warning: Parameter 'sender' is unused
LinkPaymentMethodPicker.swift:219 warning: Function 'showLoader(at:)' is unused
LinkPaymentMethodPicker.swift:228 warning: Function 'hideLoader(at:)' is unused
LinkPaymentMethodPicker.swift:237 warning: Function 'setAddPaymentMethodButtonEnabled(_:)' is unused
LinkPaymentMethodPicker.swift:273 warning: Function 'removePaymentMethod(at:animated:)' is unused
LinkCardEditElement.swift:29 warning: Class 'LinkCardEditElement' is unused
LinkCardEditElement.swift:204 warning: Extension 'LinkCardEditElement' is unused
LinkVerificationController.swift:12 warning: Class 'LinkVerificationController' is unused
LinkVerificationController.swift:37 warning: Extension 'LinkVerificationController' is unused
LinkVerificationView-LogoutView.swift:9 warning: Imported module 'StripeCore' is unused
LinkVerificationView.swift:11 warning: Imported module 'StripeCore' is unused
LinkVerificationView.swift:18 warning: Parameter 'view' is unused
LinkVerificationView.swift:153 warning: Parameter 'sender' is unused
LinkVerificationViewController.swift:59 warning: Initializer 'init(mode:linkAccount:)' is unused
LinkVerificationViewController.swift:199 warning: Parameter 'view' is unused
LinkVerificationViewController.swift:236 warning: Class 'TransitioningDelegate' is unused
LinkKeyboardAvoidingScrollView.swift:31 warning: Initializer 'init(contentView:)' 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.

Copy link

⚠️ Public API changes detected:

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:

  • Do these APIs need to be public or can they be protected with @_spi(STP)?
  • If these APIs need to be public, assess whether they require an API review.

If you are modifying or removing a public API:

  • Does this require a breaking version change?
  • Do these changes require API review?

If you confirm these APIs need to be added/updated and have undergone necessary review, add the label modifies public API to this PR to acknowledge and bypass this check.

ℹ️ If this comment appears to be left in error, make sure your branch is up-to-date with master.

@davidme-stripe davidme-stripe marked this pull request as ready for review October 23, 2024 19:35
@davidme-stripe davidme-stripe requested review from a team as code owners October 23, 2024 19:35
Base automatically changed from relink/datamodel to master October 25, 2024 22:11
Comment on lines +60 to +65
3147CECA2CC1BF550067B5E4 /* LinkPaymentMethodPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC32CC1BF550067B5E4 /* LinkPaymentMethodPicker.swift */; };
3147CECB2CC1BF550067B5E4 /* LinkPaymentMethodPicker-CellContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC62CC1BF550067B5E4 /* LinkPaymentMethodPicker-CellContentView.swift */; };
3147CECC2CC1BF550067B5E4 /* LinkPaymentMethodPicker-Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC52CC1BF550067B5E4 /* LinkPaymentMethodPicker-Cell.swift */; };
3147CECD2CC1BF550067B5E4 /* LinkPaymentMethodPicker-Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC72CC1BF550067B5E4 /* LinkPaymentMethodPicker-Header.swift */; };
3147CECE2CC1BF550067B5E4 /* LinkPaymentMethodPicker-RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC82CC1BF550067B5E4 /* LinkPaymentMethodPicker-RadioButton.swift */; };
3147CECF2CC1BF550067B5E4 /* LinkPaymentMethodPicker-AddButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3147CEC42CC1BF550067B5E4 /* LinkPaymentMethodPicker-AddButton.swift */; };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would prefer these file names to be +CellContentView.swift or +Cell.swift, etc.., but I guess we can keep them using the '-' symbol?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think + is usually reserved for extensions. (Like UIView+StripeAdditions.) If I were starting over today I would make this a folder structure (e.g. LinkPaymentMethodPicker/AddButton.swift), but the - is fine too

Comment on lines +54 to +60
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if self.point(inside: point, with: event) {
return self
}

return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now, assuming it "works", but hoping to get rid of it at some point in time. In the past, hitTest() was causing us issues with views that were being recycled -- my guess is that we'll go through a dogfooding/QA cycle, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was just because we were calling it during reloadData() in that case? Overriding hitTest in general shouldn't be a problem

contentView.paymentMethod = paymentMethod
updateAccessibilityContent()

guard let paymentMethod = paymentMethod else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
guard let paymentMethod else {
}

Comment on lines 204 to 207
case .bankAccount:
return false
case .unparsable:
return false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be combined to
case .bankAccount, .unparsable:

Comment on lines +87 to +90
bankIconView.leadingAnchor.constraint(greaterThanOrEqualTo: view.leadingAnchor),
bankIconView.topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor),
bankIconView.trailingAnchor.constraint(lessThanOrEqualTo: view.trailingAnchor),
bankIconView.bottomAnchor.constraint(lessThanOrEqualTo: view.bottomAnchor),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would have expected these to all be just equalTo not greaterThanOr/lessThanOr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense, you want the icon to be:

  • Centered (with the centerXAnchor and centerYAnchor)
  • To follow their intrinsic size
  • To not extend beyond the leading, trailing, top, or bottom anchors

If you set this as equalTo, you'd be requiring that the view extend to the edges of the containing view, which may not be correct depending on its intrinsic size.

Comment on lines 83 to 84
let codeField = OneTimeCodeTextField(configuration:
.init(numberOfDigits: 6),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing looks off.

}

override var frameOfPresentedViewInContainerView: CGRect {
guard let containerView = containerView else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove = containerView

}

private func calculateModalFrame(forContainerSize containerSize: CGSize) -> CGRect {
guard let contentView = contentView else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove = contentView

///
/// This is always equals to the container view safe area minus `padding` on eat edge.
private var safeFrame: CGRect {
guard let containerView = containerView else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove = containerView

wooj-stripe
wooj-stripe previously approved these changes Oct 26, 2024
@davidme-stripe davidme-stripe enabled auto-merge (squash) October 26, 2024 00:57
@davidme-stripe davidme-stripe merged commit bf85c49 into master Oct 26, 2024
7 checks passed
@davidme-stripe davidme-stripe deleted the relink/vcs branch October 26, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants