Skip to content

Commit

Permalink
Fix FlatWithCheckmark Row Style (#10261)
Browse files Browse the repository at this point in the history
* Align FlatWithCheck view more CTA

* Default checkmarkInsetDp to 0
  • Loading branch information
tjclawson-stripe authored Feb 24, 2025
1 parent ef9b4cb commit 27bdb23
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal data class EmbeddedAppearance(
val endSeparatorInset: Float = 0.0f,
val additionalVerticalInsetsDp: Float = 4.0f,
val horizontalInsetsDp: Float = 0.0f,
val checkmarkInsetsDp: Float = 12.0f,
val checkmarkInsetsDp: Float = 0.0f,
val floatingButtonSpacingDp: Float = 12.0f,
val topSeparatorEnabled: Boolean = true,
val bottomSeparatorEnabled: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
Expand Down Expand Up @@ -262,7 +263,7 @@ private fun RowButtonCheckmarkOuterContent(
content()
Row {
if (trailingContent != null) {
Spacer(Modifier.width(iconWidth + 16.dp))
Spacer(Modifier.width(iconWidth + 9.dp))
trailingContent()
}
}
Expand All @@ -274,7 +275,8 @@ private fun RowButtonCheckmarkOuterContent(
contentDescription = null,
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(end = style.checkmarkInsetDp.dp),
.padding(end = style.checkmarkInsetDp.dp)
.offset(3.dp),
tint = Color(style.checkmarkColor)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
package com.stripe.android.paymentsheet.verticalmode

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi
import com.stripe.android.paymentsheet.PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark
import com.stripe.android.paymentsheet.ui.PaymentMethodIconFromResource
import com.stripe.android.paymentsheet.verticalmode.UIConstants.iconHeight
import com.stripe.android.paymentsheet.verticalmode.UIConstants.iconWidth
import com.stripe.android.screenshottesting.FontSize
import com.stripe.android.screenshottesting.PaparazziRule
import com.stripe.android.ui.core.R
Expand All @@ -35,10 +48,7 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = null,
Expand All @@ -57,10 +67,7 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = false,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = null,
Expand All @@ -79,10 +86,7 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = true,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = null,
Expand All @@ -101,10 +105,7 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = "Please click me, I'm fancy",
Expand All @@ -123,10 +124,7 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = "Please click me, I'm fancy, but I shouldn't extend a a a a a a a a a a a a a a a a " +
Expand All @@ -146,18 +144,15 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = null,
promoText = null,
onClick = {},
style = FlatWithCheckmark.defaultLight,
trailingContent = {
Text(text = "View more")
TrailingContent()
},
shouldShowDefaultBadge = false,
)
Expand All @@ -183,21 +178,52 @@ internal class PaymentMethodRowCheckmarkButtonScreenshotTest {
isEnabled = true,
isSelected = false,
iconContent = {
Image(
painter = painterResource(id = R.drawable.stripe_ic_paymentsheet_pm_card),
contentDescription = null
)
Icon()
},
title = "**** 4242",
subtitle = null,
promoText = null,
onClick = {},
style = style,
trailingContent = {
Text(text = "View more")
TrailingContent()
},
shouldShowDefaultBadge = false,
)
}
}

@Composable
private fun Icon() {
PaymentMethodIconFromResource(
iconRes = R.drawable.stripe_ic_paymentsheet_pm_card,
colorFilter = null,
alignment = Alignment.Center,
modifier = Modifier
.height(iconHeight)
.width(iconWidth)
)
}

@Composable
private fun TrailingContent() {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.testTag(TEST_TAG_VIEW_MORE)
.padding(4.dp)
) {
Text(
stringResource(id = com.stripe.android.paymentsheet.R.string.stripe_view_more),
color = MaterialTheme.colors.primary,
style = MaterialTheme.typography.subtitle1,
fontWeight = FontWeight.Medium,
)
Icon(
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
contentDescription = null,
tint = MaterialTheme.colors.primary,
)
}
}
}
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ object StripeThemeDefaults {
val embeddedCommon = EmbeddedInsets(
additionalVerticalInsetsDp = 0.0f,
horizontalInsetsDp = 0.0f,
checkmarkInsetDp = 12.0f
checkmarkInsetDp = 0.0f
)

val floating = EmbeddedFloatingStyle(
Expand Down

0 comments on commit 27bdb23

Please sign in to comment.