Skip to content

Commit

Permalink
Default Payment Method Label (#9845)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianzhao-stripe authored Jan 3, 2025
1 parent c794da1 commit a41b5d9
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions paymentsheet/api/paymentsheet.api
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,13 @@ public final class com/stripe/android/paymentsheet/state/PaymentSheetState$Loadi
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/paymentsheet/ui/ComposableSingletons$DefaultPaymentMethodLabelKt {
public static final field INSTANCE Lcom/stripe/android/paymentsheet/ui/ComposableSingletons$DefaultPaymentMethodLabelKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$paymentsheet_release ()Lkotlin/jvm/functions/Function2;
}

public final class com/stripe/android/paymentsheet/ui/ComposableSingletons$EditPaymentMethodKt {
public static final field INSTANCE Lcom/stripe/android/paymentsheet/ui/ComposableSingletons$EditPaymentMethodKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.stripe.android.paymentsheet.ui

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import com.stripe.android.paymentsheet.R
import com.stripe.android.uicore.DefaultStripeTheme
import com.stripe.android.uicore.stripeColors

@Composable
internal fun DefaultPaymentMethodLabel(
modifier: Modifier,
) {
Text(
modifier = modifier
.testTag(
TEST_TAG_DEFAULT_PAYMENT_METHOD_LABEL
),
text = stringResource(id = R.string.stripe_wallet_default),
style = MaterialTheme.typography.caption.copy(fontWeight = FontWeight.Medium),
color = MaterialTheme.stripeColors.placeholderText,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}

@Composable
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Preview
private fun DefaultPaymentMethodLabelPreview() {
DefaultStripeTheme {
Row(
modifier = Modifier.background(color = MaterialTheme.stripeColors.component)
) {
DefaultPaymentMethodLabel(
modifier = Modifier
)
}
}
}

internal const val TEST_TAG_DEFAULT_PAYMENT_METHOD_LABEL = "default_payment_method_label"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.stripe.android.paymentsheet.ui

import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.stripe.android.screenshottesting.FontSize
import com.stripe.android.screenshottesting.PaparazziRule
import com.stripe.android.screenshottesting.SystemAppearance
import com.stripe.android.utils.screenshots.PaymentSheetAppearance
import org.junit.Rule
import org.junit.Test

internal class DefaultPaymentMethodLabelScreenshotTest {

@get:Rule
val paparazziRule = PaparazziRule(
SystemAppearance.entries,
PaymentSheetAppearance.entries,
FontSize.entries,
)

@Test
fun testDefaultPaymentMethodLabel() {
paparazziRule.snapshot {
DefaultPaymentMethodLabel(
modifier = Modifier
.padding(horizontal = 4.dp, vertical = 4.dp)
)
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a41b5d9

Please sign in to comment.