Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
toluo-stripe committed Nov 20, 2024
1 parent 50a5c60 commit 36b7739
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ internal val ConsumerPaymentDetails.PaymentDetails.removeLabel

internal val ConsumerPaymentDetails.PaymentDetails.removeConfirmation
get() = when (this) {
is ConsumerPaymentDetails.Passthrough, is ConsumerPaymentDetails.Card -> R.string.stripe_wallet_remove_card_confirmation
is ConsumerPaymentDetails.Passthrough, is ConsumerPaymentDetails.Card -> {
R.string.stripe_wallet_remove_card_confirmation
}
is ConsumerPaymentDetails.BankAccount -> R.string.stripe_wallet_remove_account_confirmation
}
170 changes: 95 additions & 75 deletions link/src/main/java/com/stripe/android/link/ui/wallet/PaymentDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,95 +51,115 @@ internal fun PaymentDetailsListItem(
onClick: () -> Unit,
onMenuButtonClick: () -> Unit
) {
Row(
modifier = Modifier
.fillMaxWidth()
.defaultMinSize(minHeight = 56.dp)
.clickable(enabled = enabled, onClick = onClick),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = isSelected,
onClick = null,
modifier = Modifier.padding(start = 20.dp, end = 6.dp),
colors = RadioButtonDefaults.colors(
selectedColor = MaterialTheme.linkColors.actionLabelLight,
unselectedColor = MaterialTheme.linkColors.disabledText
)
)
Column(
Column {
Row(
modifier = Modifier
.padding(vertical = 8.dp)
.weight(1f)
.fillMaxWidth()
.defaultMinSize(minHeight = 56.dp)
.clickable(enabled = enabled, onClick = onClick),
verticalAlignment = Alignment.CenterVertically
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
RadioButton(
selected = isSelected,
onClick = null,
modifier = Modifier.padding(start = 20.dp, end = 6.dp),
colors = RadioButtonDefaults.colors(
selectedColor = MaterialTheme.linkColors.actionLabelLight,
unselectedColor = MaterialTheme.linkColors.disabledText
)
)
Column(
modifier = Modifier
.padding(vertical = 8.dp)
.weight(1f)
) {
PaymentDetails(paymentDetails = paymentDetails)
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
PaymentDetails(paymentDetails = paymentDetails)

if (paymentDetails.isDefault) {
Box(
modifier = Modifier
.background(
color = MaterialTheme.colors.secondary,
shape = MaterialTheme.linkShapes.extraSmall
),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(id = R.string.stripe_wallet_default),
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp),
color = MaterialTheme.linkColors.disabledText,
fontSize = 12.sp,
fontWeight = FontWeight.Medium
)
if (paymentDetails.isDefault) {
DefaultTag()
}
}

val showWarning = (paymentDetails as? Card)?.isExpired ?: false
if (showWarning && !isSelected) {
Icon(
painter = painterResource(R.drawable.stripe_link_error),
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = MaterialTheme.linkColors.errorText
)
val showWarning = (paymentDetails as? Card)?.isExpired ?: false
if (showWarning && !isSelected) {
Icon(
painter = painterResource(R.drawable.stripe_link_error),
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = MaterialTheme.linkColors.errorText
)
}
}
}

MenuAndLoader(
enabled = enabled,
isUpdating = isUpdating,
onMenuButtonClick = onMenuButtonClick
)
}
TabRowDefaults.Divider(
modifier = Modifier.padding(horizontal = 20.dp),
color = MaterialTheme.linkColors.componentDivider,
thickness = 1.dp
)
}
}

Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(MinimumTouchTargetSize)
.padding(end = 12.dp)
) {
if (isUpdating) {
CircularProgressIndicator(
modifier = Modifier.size(24.dp),
strokeWidth = 2.dp
@Composable
private fun MenuAndLoader(
enabled: Boolean,
isUpdating: Boolean,
onMenuButtonClick: () -> Unit
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(MinimumTouchTargetSize)
.padding(end = 12.dp)
) {
if (isUpdating) {
CircularProgressIndicator(
modifier = Modifier.size(24.dp),
strokeWidth = 2.dp
)
} else {
IconButton(
onClick = onMenuButtonClick,
enabled = enabled
) {
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = stringResource(StripeR.string.stripe_edit),
tint = MaterialTheme.linkColors.actionLabelLight,
modifier = Modifier.size(24.dp)
)
} else {
IconButton(
onClick = onMenuButtonClick,
enabled = enabled
) {
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = stringResource(StripeR.string.stripe_edit),
tint = MaterialTheme.linkColors.actionLabelLight,
modifier = Modifier.size(24.dp)
)
}
}
}
}
TabRowDefaults.Divider(
modifier = Modifier.padding(horizontal = 20.dp),
color = MaterialTheme.linkColors.componentDivider,
thickness = 1.dp
)
}

@Composable
private fun DefaultTag() {
Box(
modifier = Modifier
.background(
color = MaterialTheme.colors.secondary,
shape = MaterialTheme.linkShapes.extraSmall
),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(id = R.string.stripe_wallet_default),
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp),
color = MaterialTheme.linkColors.disabledText,
fontSize = 12.sp,
fontWeight = FontWeight.Medium
)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ internal class PaymentDetailsListItemScreenShotTest(
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
@SuppressWarnings("LongMethod")
fun data(): List<TestCase> {
return listOf(
TestCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import android.view.View
import android.widget.EditText
import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting
import com.stripe.android.core.utils.DateUtils
import com.stripe.android.R
import com.stripe.android.core.utils.DateUtils
import com.stripe.android.model.ExpirationDate
import kotlin.math.min
import kotlin.properties.Delegates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.stripe.android.model

import android.os.Parcelable
import androidx.annotation.RestrictTo
import com.stripe.android.core.utils.DateUtils
import com.stripe.android.core.model.CountryCode
import com.stripe.android.core.model.StripeModel
import com.stripe.android.core.utils.DateUtils
import kotlinx.parcelize.Parcelize

@Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting
import java.util.Calendar

@SuppressWarnings("MagicNumber")
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
object DateUtils {

Expand Down

0 comments on commit 36b7739

Please sign in to comment.