Skip to content

Commit

Permalink
MBL-1327: Currency conversion shows regardless of if necessary (#2014)
Browse files Browse the repository at this point in the history
* fix conversion

* lint

---------

Co-authored-by: Leigh Douglas <[email protected]>
Co-authored-by: Isabel Martin <[email protected]>
Co-authored-by: mtgriego <[email protected]>
  • Loading branch information
4 people authored Apr 16, 2024
1 parent f82a05f commit c6fe8d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,19 @@ fun AddOnsScreen(
project,
true,
) ?: "",
conversionAmount = environment.ksString()?.format(
stringResource(R.string.About_reward_amount),
"reward_amount",
environment.ksCurrency()?.format(
reward.convertedMinimum(),
project,
true,
RoundingMode.HALF_UP,
true
conversionAmount = if (project.currentCurrency() == project.currency()) "" else {
environment.ksString()?.format(
stringResource(R.string.About_reward_amount),
"reward_amount",
environment.ksCurrency()?.format(
reward.convertedMinimum(),
project,
true,
RoundingMode.HALF_UP,
true
)
)
),
},
shippingAmount = environment.ksCurrency()?.let {
getShippingCost(
reward = reward,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,14 @@ fun CheckoutScreen(
).toString()
} ?: ""

val totalAmountConvertedString = environment.ksCurrency()?.formatWithUserPreference(
totalAmount,
project,
RoundingMode.UP,
2
) ?: ""
val totalAmountConvertedString = if (project.currentCurrency() == project.currency()) "" else {
environment.ksCurrency()?.formatWithUserPreference(
totalAmount,
project,
RoundingMode.UP,
2
) ?: ""
}

val shippingAmountString = environment.ksCurrency()?.let {
RewardViewUtils.styleCurrency(
Expand Down Expand Up @@ -449,7 +451,7 @@ fun CheckoutScreen(
shippingAmountString = shippingAmountString,
initialShippingLocation = shippingLocation,
totalAmount = totalAmountString,
totalAmountCurrencyConverted = totalAmountConvertedString,
totalAmountCurrencyConverted = aboutTotalString,
initialBonusSupport = initialBonusSupportString,
totalBonusSupport = totalBonusSupportString,
deliveryDateString = deliveryDateString,
Expand All @@ -458,7 +460,7 @@ fun CheckoutScreen(
} else {
ItemizedRewardListContainer(
totalAmount = totalAmountString,
totalAmountCurrencyConverted = totalAmountConvertedString,
totalAmountCurrencyConverted = aboutTotalString,
initialBonusSupport = initialBonusSupportString,
totalBonusSupport = totalBonusSupportString,
shippingAmount = shippingAmount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,13 @@ fun ConfirmPledgeDetailsScreen(
2
) ?: ""

val aboutTotalString = environment?.ksString()?.format(
stringResource(id = R.string.About_reward_amount),
"reward_amount",
totalAmountConvertedString
) ?: "About $totalAmountConvertedString"
val aboutTotalString = if (project.currentCurrency() == project.currency()) "" else {
environment?.ksString()?.format(
stringResource(id = R.string.About_reward_amount),
"reward_amount",
totalAmountConvertedString
) ?: "About $totalAmountConvertedString"
}

val shippingAmountString = environment?.ksCurrency()?.let {
RewardViewUtils.styleCurrency(
Expand Down Expand Up @@ -467,7 +469,7 @@ fun ConfirmPledgeDetailsScreen(
color = colors.textPrimary
)

if (aboutTotalString.isNotEmpty()) {
if (!aboutTotalString.isNullOrEmpty()) {
Spacer(modifier = Modifier.height(dimensions.paddingXSmall))

Text(
Expand All @@ -489,7 +491,7 @@ fun ConfirmPledgeDetailsScreen(
shippingAmountString = shippingAmountString,
initialShippingLocation = shippingLocation,
totalAmount = totalAmountString,
totalAmountCurrencyConverted = totalAmountConvertedString,
totalAmountCurrencyConverted = aboutTotalString,
initialBonusSupport = initialBonusSupportString,
totalBonusSupport = totalBonusSupportString,
deliveryDateString = deliveryDateString,
Expand Down Expand Up @@ -730,11 +732,7 @@ fun ItemizedRewardListContainer(
Spacer(modifier = Modifier.height(dimensions.paddingXSmall))

Text(
text = ksString?.format(
stringResource(id = R.string.About_reward_amount),
"reward_amount",
totalAmountCurrencyConverted
) ?: "About $totalAmountCurrencyConverted",
text = totalAmountCurrencyConverted,
style = typography.footnote,
color = colors.textPrimary
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ fun RewardCarouselScreen(
it
).toString()
},
conversion = environment.ksCurrency()?.let {
it.format(
conversion = if (project.currentCurrency() == project.currency()) "" else {
val conversionAmount = environment.ksCurrency()?.format(
reward.convertedMinimum(),
project,
true,
RoundingMode.HALF_UP,
true
)
environment.ksString()?.format(stringResource(id = R.string.About_reward_amount), "reward_amount", conversionAmount)
},
description = reward.description(),
title = reward.title(),
Expand Down

0 comments on commit c6fe8d2

Please sign in to comment.