Skip to content

Commit

Permalink
Updates based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
davidme-stripe committed Oct 26, 2024
1 parent 9f7cc8d commit de9c74c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,15 @@ extension LinkPaymentMethodPicker {
contentView.paymentMethod = paymentMethod
updateAccessibilityContent()

guard let paymentMethod = paymentMethod else {
guard let paymentMethod else {
return
}

var hasExpired: Bool {
switch paymentMethod.details {
case .card(let card):
return card.hasExpired
case .bankAccount:
return false
case .unparsable:
case .bankAccount, .unparsable:
return false
}
}
Expand All @@ -228,7 +226,7 @@ extension LinkPaymentMethodPicker {
}

private func updateAccessibilityContent() {
guard let paymentMethod = paymentMethod else {
guard let paymentMethod else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

@_spi(STP) import StripeCore
@_spi(STP) import StripeUICore

protocol LinkPaymentMethodPickerDelegate: AnyObject {
Expand Down Expand Up @@ -55,6 +56,7 @@ final class LinkPaymentMethodPicker: UIView {
let count = dataSource?.numberOfPaymentMethods(in: self) ?? 0

guard selectedIndex >= 0 && selectedIndex < count else {
stpAssertionFailure()
return nil
}

Expand Down Expand Up @@ -142,7 +144,7 @@ final class LinkPaymentMethodPicker: UIView {

// Prevent double header animation
if headerView.isExpanded {
// TODO(ramont): revise layout margin placement and remove conditional
// TODO(link): revise layout margin placement and remove conditional
setNeedsLayout()
layoutIfNeeded()
} else {
Expand Down Expand Up @@ -199,11 +201,12 @@ extension LinkPaymentMethodPicker {

func reloadCell(at index: Int) {
guard let cell = listView.arrangedSubviews[index] as? Cell else {
preconditionFailure("Cell not found at index: \(index)")
stpAssertionFailure("Cell not found at index: \(index)")
return
}

guard let dataSource = dataSource else {
assertionFailure("Data source not configured.")
stpAssertionFailure("Data source not configured.")
return
}

Expand All @@ -216,15 +219,17 @@ extension LinkPaymentMethodPicker {

func showLoader(at index: Int) {
guard let cell = listView.arrangedSubviews[index] as? Cell else {
preconditionFailure("Cell not found at index: \(index)")
stpAssertionFailure("Cell not found at index: \(index)")
return
}

cell.isLoading = true
}

func hideLoader(at index: Int) {
guard let cell = listView.arrangedSubviews[index] as? Cell else {
preconditionFailure("Cell not found at index: \(index)")
stpAssertionFailure("Cell not found at index: \(index)")
return
}

cell.isLoading = false
Expand Down Expand Up @@ -308,7 +313,7 @@ extension LinkPaymentMethodPicker: LinkPaymentMethodPickerCellDelegate {

func savedPaymentPickerCell(_ cell: Cell, didTapMenuButton button: UIButton) {
guard let index = index(for: cell) else {
assertionFailure("Index not found")
stpAssertionFailure("Index not found")
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@_spi(STP) import StripeUICore
import UIKit

// TODO(ramont): Remove after migrating to modern bindings
// TODO(link): Remove after migrating to modern bindings
fileprivate extension ConsumerPaymentDetails {
var cardDetails: Details.Card? {
switch details {
Expand Down Expand Up @@ -58,7 +58,7 @@ final class LinkCardEditElement: Element {
return nil
}

// TODO(ramont): Replace `STPPaymentMethodBillingDetails` with a custom struct for Link.
// TODO(link): Replace `STPPaymentMethodBillingDetails` with a custom struct for Link.
// This matches the object that was returned by CardDetailsEditView, but won't work
// with `collectionMode: .all`, because extra fields won't match what expected by Link.
let billingDetails = STPPaymentMethodBillingDetails()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ final class LinkVerificationView: UIView {
}()

private(set) lazy var codeField: OneTimeCodeTextField = {
let codeField = OneTimeCodeTextField(configuration:
.init(numberOfDigits: 6),
let codeField = OneTimeCodeTextField(configuration: .init(numberOfDigits: 6),
theme: LinkUI.appearance.asElementsTheme)
codeField.addTarget(self, action: #selector(oneTimeCodeFieldChanged(_:)), for: .valueChanged)
return codeField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension LinkVerificationViewController {
///
/// This is always equals to the container view safe area minus `padding` on eat edge.
private var safeFrame: CGRect {
guard let containerView = containerView else {
guard let containerView else {
return .zero
}

Expand All @@ -52,7 +52,7 @@ extension LinkVerificationViewController {
}

override var frameOfPresentedViewInContainerView: CGRect {
guard let containerView = containerView else {
guard let containerView else {
return .zero
}

Expand Down Expand Up @@ -95,7 +95,7 @@ extension LinkVerificationViewController {
override func containerViewWillLayoutSubviews() {
super.containerViewWillLayoutSubviews()

guard let containerView = containerView else {
guard let containerView else {
return
}

Expand All @@ -106,7 +106,7 @@ extension LinkVerificationViewController {
override func presentationTransitionWillBegin() {
super.presentationTransitionWillBegin()

guard let containerView = containerView,
guard let containerView,
let transitionCoordinator = presentedViewController.transitionCoordinator else {
return
}
Expand Down Expand Up @@ -188,7 +188,7 @@ extension LinkVerificationViewController.PresentationController {
let userInfo = notification.userInfo

guard let keyboardFrame = userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
let containerView = containerView else {
let containerView else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BottomSheetPresentationController: UIPresentationController {
return presentedViewController as? BottomSheetPresentable
}
private lazy var fullHeightConstraint: NSLayoutConstraint = {
guard let containerView = containerView else {
guard let containerView else {
assertionFailure()
return NSLayoutConstraint()
}
Expand Down Expand Up @@ -135,7 +135,7 @@ class BottomSheetPresentationController: UIPresentationController {
extension BottomSheetPresentationController {

fileprivate func installConstraints() {
guard let containerView = containerView else { return }
guard let containerView else { return }

// Add a dimmed view behind the view controller
containerView.addAndPinSubview(backgroundView)
Expand Down

0 comments on commit de9c74c

Please sign in to comment.