Skip to content

Commit

Permalink
Update transformToPaymentSelection signature to use resources rather …
Browse files Browse the repository at this point in the history
…than context (#6927)
  • Loading branch information
jameswoo-stripe authored Jun 26, 2023
1 parent a6f7da8 commit 950e79a
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android.paymentsheet.ui

import android.content.Context
import androidx.annotation.VisibleForTesting
import android.content.res.Resources
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -105,7 +104,7 @@ internal fun AddPaymentMethod(
formArguments = arguments,
onFormFieldValuesChanged = { formValues ->
val newSelection = formValues?.transformToPaymentSelection(
context = context,
resources = context.resources,
paymentMethod = selectedItem,
)
sheetViewModel.updateSelection(newSelection)
Expand Down Expand Up @@ -141,9 +140,8 @@ private fun BaseSheetViewModel.showLinkInlineSignupView(
(linkAccountStatus in validStatusStates || linkInlineSelectionValid)
}

@VisibleForTesting
internal fun FormFieldValues.transformToPaymentSelection(
context: Context,
resources: Resources,
paymentMethod: LpmRepository.SupportedPaymentMethod
): PaymentSelection.New {
val params = FieldValuesToParamsMapConverter.transformToPaymentMethodCreateParams(
Expand All @@ -162,7 +160,7 @@ internal fun FormFieldValues.transformToPaymentSelection(
)
} else {
PaymentSelection.New.GenericPaymentMethod(
labelResource = context.getString(paymentMethod.displayNameResource),
labelResource = resources.getString(paymentMethod.displayNameResource),
iconResource = paymentMethod.iconResource,
lightThemeIconUrl = paymentMethod.lightThemeIconUrl,
darkThemeIconUrl = paymentMethod.darkThemeIconUrl,
Expand Down

0 comments on commit 950e79a

Please sign in to comment.