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 Wallet payment method list UI #9691

Merged
merged 14 commits into from
Nov 28, 2024
9 changes: 7 additions & 2 deletions link/api/link.api
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,11 @@ public final class com/stripe/android/link/ui/ComposableSingletons$LinkContentKt
public static field lambda-2 Lkotlin/jvm/functions/Function4;
public static field lambda-3 Lkotlin/jvm/functions/Function4;
public static field lambda-4 Lkotlin/jvm/functions/Function4;
public static field lambda-5 Lkotlin/jvm/functions/Function4;
public fun <init> ()V
public final fun getLambda-1$link_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$link_release ()Lkotlin/jvm/functions/Function4;
public final fun getLambda-3$link_release ()Lkotlin/jvm/functions/Function4;
public final fun getLambda-4$link_release ()Lkotlin/jvm/functions/Function4;
public final fun getLambda-5$link_release ()Lkotlin/jvm/functions/Function4;
}

public final class com/stripe/android/link/ui/ComposableSingletons$LinkTermsKt {
Expand Down Expand Up @@ -223,6 +221,13 @@ public final class com/stripe/android/link/ui/wallet/ComposableSingletons$Paymen
public final fun getLambda-1$link_release ()Lkotlin/jvm/functions/Function2;
}

public final class com/stripe/android/link/ui/wallet/ComposableSingletons$WalletScreenKt {
public static final field INSTANCE Lcom/stripe/android/link/ui/wallet/ComposableSingletons$WalletScreenKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$link_release ()Lkotlin/jvm/functions/Function3;
}

public final class com/stripe/android/link/utils/ComposableSingletons$InlineContentTemplateBuilderKt {
public static final field INSTANCE Lcom/stripe/android/link/utils/ComposableSingletons$InlineContentTemplateBuilderKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
Expand Down
1 change: 1 addition & 0 deletions link/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@
<string name="stripe_wallet_update_card">Update card</string>
<!-- A text notice shown when the user selects an expired card. -->
<string name="stripe_wallet_update_expired_card_error">This card has expired. Update your card info or choose a different payment method.</string>
<string name="stripe_wallet_expand_accessibility">Change selection</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private val LocalColors = staticCompositionLocalOf { LinkThemeConfig.colors(fals
internal val MinimumTouchTargetSize = 48.dp
internal val PrimaryButtonHeight = 56.dp
internal val AppBarHeight = 56.dp
internal val HorizontalPadding = 20.dp

@Composable
internal fun DefaultLinkTheme(
Expand Down
13 changes: 12 additions & 1 deletion link/src/main/java/com/stripe/android/link/ui/LinkContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.stripe.android.link.ui.signup.SignUpViewModel
import com.stripe.android.link.ui.verification.VerificationScreen
import com.stripe.android.link.ui.verification.VerificationViewModel
import com.stripe.android.link.ui.wallet.WalletScreen
import com.stripe.android.link.ui.wallet.WalletViewModel
import com.stripe.android.ui.core.CircularProgressIndicator
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -155,7 +156,17 @@ private fun Screens(
}

composable(LinkScreen.Wallet.route) {
WalletScreen()
val linkAccount = getLinkAccount()
?: return@composable dismissWithResult(LinkActivityResult.Failed(NoLinkAccountFoundException()))
val viewModel: WalletViewModel = linkViewModel { parentComponent ->
WalletViewModel.factory(
parentComponent = parentComponent,
linkAccount = linkAccount,
navigateAndClearStack = navigateAndClearStack,
dismissWithResult = dismissWithResult
)
}
WalletScreen(viewModel)
}

composable(LinkScreen.CardEdit.route) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -42,6 +43,7 @@ import com.stripe.android.ui.core.R as StripeUiCoreR

@Composable
internal fun PaymentDetailsListItem(
modifier: Modifier = Modifier,
paymentDetails: ConsumerPaymentDetails.PaymentDetails,
enabled: Boolean,
isSelected: Boolean,
Expand All @@ -50,7 +52,7 @@ internal fun PaymentDetailsListItem(
onMenuButtonClick: () -> Unit
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.defaultMinSize(minHeight = 56.dp)
.clickable(enabled = enabled, onClick = onClick),
Expand All @@ -59,7 +61,9 @@ internal fun PaymentDetailsListItem(
RadioButton(
selected = isSelected,
onClick = null,
modifier = Modifier.padding(start = 20.dp, end = 6.dp),
modifier = Modifier
.testTag(WALLET_PAYMENT_DETAIL_ITEM_RADIO_BUTTON)
.padding(start = 20.dp, end = 6.dp),
colors = RadioButtonDefaults.colors(
selectedColor = MaterialTheme.linkColors.actionLabelLight,
unselectedColor = MaterialTheme.linkColors.disabledText
Expand Down Expand Up @@ -154,12 +158,14 @@ private fun DefaultTag() {
}

@Composable
private fun RowScope.PaymentDetails(
internal fun RowScope.PaymentDetails(
modifier: Modifier = Modifier,
paymentDetails: ConsumerPaymentDetails.PaymentDetails,
) {
when (paymentDetails) {
is Card -> {
CardInfo(
modifier = modifier,
last4 = paymentDetails.last4,
icon = paymentDetails.brand.icon,
contentDescription = paymentDetails.brand.displayName
Expand All @@ -170,6 +176,7 @@ private fun RowScope.PaymentDetails(
}
is ConsumerPaymentDetails.Passthrough -> {
CardInfo(
modifier = modifier,
last4 = paymentDetails.last4,
icon = R.drawable.stripe_link_bank,
contentDescription = stringResource(R.string.stripe_wallet_passthrough_description)
Expand All @@ -180,12 +187,13 @@ private fun RowScope.PaymentDetails(

@Composable
private fun RowScope.CardInfo(
modifier: Modifier = Modifier,
last4: String,
icon: Int,
contentDescription: String? = null
contentDescription: String? = null,
) {
Row(
modifier = Modifier.weight(1f),
modifier = modifier.weight(1f),
verticalAlignment = Alignment.CenterVertically
) {
Image(
Expand All @@ -210,10 +218,11 @@ private fun RowScope.CardInfo(

@Composable
private fun RowScope.BankAccountInfo(
modifier: Modifier = Modifier,
bankAccount: ConsumerPaymentDetails.BankAccount,
) {
Row(
modifier = Modifier.weight(1f),
modifier = modifier.weight(1f),
verticalAlignment = Alignment.CenterVertically
) {
Image(
Expand Down Expand Up @@ -248,3 +257,5 @@ private fun RowScope.BankAccountInfo(
}
}
}

internal const val WALLET_PAYMENT_DETAIL_ITEM_RADIO_BUTTON = "wallet_payment_detail_item_radio_button"
Loading
Loading