Updated on 2026-08-14

This commit is contained in:
Tangem 2020-09-14 15:59:44 +03:00
parent be2bc3064b
commit 00400a72dd
3 changed files with 64 additions and 63 deletions

View file

@ -4,6 +4,7 @@ import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Wallet
import com.tangem.tap.common.CurrencyConverter
import com.tangem.tap.common.entities.TapCurrency
import com.tangem.tap.common.extensions.stripZeroPlainString
import com.tangem.tap.features.send.redux.ReceiptAction.RefreshReceipt
import com.tangem.tap.features.send.redux.SendScreenAction
import com.tangem.tap.features.send.redux.states.*
@ -54,10 +55,10 @@ class ReceiptReducer : SendInternalReducer {
val amountFiat = converter.toFiat(amountState.amountToSendCrypto.minus(feeCrypto))
val totalFiat = converter.toFiat(amountState.amountToSendCrypto)
ReceiptFiat(
amountFiat = amountFiat,
feeFiat = feeFiat,
totalFiat = totalFiat,
willSentCrypto = amountState.amountToSendCrypto.stripTrailingZeros(),
amountFiat = amountFiat.stripZeroPlainString(),
feeFiat = feeFiat.stripZeroPlainString(),
totalFiat = totalFiat.stripZeroPlainString(),
willSentCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
symbols = symbols
)
} else {
@ -65,10 +66,10 @@ class ReceiptReducer : SendInternalReducer {
val amountFiat = converter.toFiat(amountState.amountToSendCrypto)
val totalFiat = converter.toFiat(totalAmountCrypto)
ReceiptFiat(
amountFiat = amountFiat,
feeFiat = feeFiat,
totalFiat = totalFiat,
willSentCrypto = totalAmountCrypto.stripTrailingZeros(),
amountFiat = amountFiat.stripZeroPlainString(),
feeFiat = feeFiat.stripZeroPlainString(),
totalFiat = totalFiat.stripZeroPlainString(),
willSentCrypto = totalAmountCrypto.stripZeroPlainString(),
symbols = symbols
)
}
@ -84,19 +85,21 @@ class ReceiptReducer : SendInternalReducer {
if (feeState.feeIsIncluded) {
return ReceiptCrypto(
amountCrypto = amountState.amountToSendCrypto.minus(feeCrypto).stripTrailingZeros(),
feeCrypto = feeCrypto.stripTrailingZeros(),
totalCrypto = amountState.amountToSendCrypto.stripTrailingZeros(),
willSentFiat = converter.toFiat(amountState.amountToSendCrypto),
amountCrypto = amountState.amountToSendCrypto.minus(feeCrypto).stripZeroPlainString(),
feeCrypto = feeCrypto.stripZeroPlainString(),
totalCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
feeFiat = converter.toFiat(feeCrypto).stripZeroPlainString(),
willSentFiat = converter.toFiat(amountState.amountToSendCrypto).stripZeroPlainString(),
symbols = symbols
)
} else {
val totalCrypto = amountState.amountToSendCrypto.plus(feeCrypto)
return ReceiptCrypto(
amountCrypto = amountState.amountToSendCrypto.stripTrailingZeros(),
feeCrypto = feeCrypto.stripTrailingZeros(),
totalCrypto = totalCrypto.stripTrailingZeros(),
willSentFiat = converter.toFiat(totalCrypto),
amountCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
feeCrypto = feeCrypto.stripZeroPlainString(),
totalCrypto = totalCrypto.stripZeroPlainString(),
feeFiat = converter.toFiat(feeCrypto).stripZeroPlainString(),
willSentFiat = converter.toFiat(totalCrypto).stripZeroPlainString(),
symbols = symbols
)
}
@ -112,11 +115,11 @@ class ReceiptReducer : SendInternalReducer {
val amountFiat = converter.toFiat(amountState.amountToSendCrypto)
val feeFiat = converter.toFiat(feeCrypto)
return ReceiptTokenFiat(
amountFiat = amountFiat,
feeFiat = feeFiat,
totalFiat = amountFiat.plus(feeFiat),
willSentTokenCrypto = amountState.amountToSendCrypto.stripTrailingZeros(),
willSentFeeCrypto = feeCrypto.stripTrailingZeros(),
amountFiat = amountFiat.stripZeroPlainString(),
feeFiat = feeFiat.stripZeroPlainString(),
totalFiat = amountFiat.plus(feeFiat).stripZeroPlainString(),
willSentTokenCrypto = amountState.amountToSendCrypto.stripZeroPlainString(),
willSentFeeCrypto = feeCrypto.stripZeroPlainString(),
symbols = symbols
)
}
@ -130,9 +133,9 @@ class ReceiptReducer : SendInternalReducer {
val feeCrypto = feeState.getCurrentFee()
val totalFiat = converter.toFiat(amountState.amountToSendCrypto).plus(converter.toFiat(feeCrypto))
return ReceiptTokenCrypto(
amountToken = amountState.amountToSendCrypto.stripTrailingZeros(),
feeCrypto = feeCrypto.stripTrailingZeros(),
totalFiat = totalFiat.stripTrailingZeros(),
amountToken = amountState.amountToSendCrypto.stripZeroPlainString(),
feeCrypto = feeCrypto.stripZeroPlainString(),
totalFiat = totalFiat.stripZeroPlainString(),
symbols = symbols
)
}

View file

@ -1,7 +1,6 @@
package com.tangem.tap.features.send.redux.states
import org.rekotlin.StateType
import java.math.BigDecimal
// Shows only one type of the layout
enum class ReceiptLayoutType {
@ -25,33 +24,34 @@ data class ReceiptSymbols(
)
data class ReceiptFiat(
val amountFiat: BigDecimal,
val feeFiat: BigDecimal,
val totalFiat: BigDecimal,
val willSentCrypto: BigDecimal,
val amountFiat: String,
val feeFiat: String,
val totalFiat: String,
val willSentCrypto: String,
val symbols: ReceiptSymbols
)
data class ReceiptCrypto(
val amountCrypto: BigDecimal,
val feeCrypto: BigDecimal,
val totalCrypto: BigDecimal,
val willSentFiat: BigDecimal,
val amountCrypto: String,
val feeCrypto: String,
val totalCrypto: String,
val feeFiat: String,
val willSentFiat: String,
val symbols: ReceiptSymbols
)
data class ReceiptTokenCrypto(
val amountToken: BigDecimal,
val feeCrypto: BigDecimal,
val totalFiat: BigDecimal,
val amountToken: String,
val feeCrypto: String,
val totalFiat: String,
val symbols: ReceiptSymbols
)
data class ReceiptTokenFiat(
val amountFiat: BigDecimal,
val feeFiat: BigDecimal,
val totalFiat: BigDecimal,
val willSentTokenCrypto: BigDecimal,
val willSentFeeCrypto: BigDecimal,
val amountFiat: String,
val feeFiat: String,
val totalFiat: String,
val willSentTokenCrypto: String,
val willSentFeeCrypto: String,
val symbols: ReceiptSymbols
)

View file

@ -166,12 +166,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
totalLayout.show(true)
totalTokenLayout.show(false)
fg.tvReceiptAmountValue.update("${receipt.amountFiat.toPlainString()} ${receipt.symbols.fiat}")
fg.tvReceiptFeeValue.update("${receipt.feeFiat.toPlainString()} ${receipt.symbols.fiat}")
totalLayout.tvTotalValue.update("${receipt.totalFiat.toPlainString()} ${receipt.symbols.fiat}")
fg.tvReceiptAmountValue.update("${receipt.amountFiat} ${receipt.symbols.fiat}")
fg.tvReceiptFeeValue.update("${receipt.feeFiat} ${receipt.symbols.fiat}")
totalLayout.tvTotalValue.update("${receipt.totalFiat} ${receipt.symbols.fiat}")
val willSent = SpannableStringBuilder()
.bold { append(receipt.willSentCrypto.toPlainString()) }.append(" ")
.bold { append(receipt.willSentCrypto) }.append(" ")
.append(receipt.symbols.crypto).append(" ")
.append(getString(R.string.send_total_will_be_sent))
totalLayout.tvWillBeSentValue.update(willSent)
@ -182,17 +182,17 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
totalLayout.show(true)
totalTokenLayout.show(false)
fg.tvReceiptAmountValue.update("${receipt.amountCrypto.toPlainString()} ${receipt.symbols.crypto}")
fg.tvReceiptFeeValue.update("${receipt.feeCrypto.toPlainString()} ${receipt.symbols.crypto}")
totalLayout.tvTotalValue.update("${receipt.totalCrypto.toPlainString()} ${receipt.symbols.crypto}")
fg.tvReceiptAmountValue.update("${receipt.amountCrypto} ${receipt.symbols.crypto}")
fg.tvReceiptFeeValue.update("${receipt.feeCrypto} ${receipt.symbols.crypto}")
totalLayout.tvTotalValue.update("${receipt.totalCrypto} ${receipt.symbols.crypto}")
val willSent = SpannableStringBuilder()
.bold {
append(getString(R.string.sign_rough))
append(" ")
append(receipt.willSentFiat.toPlainString())
append(" ")
append(getString(R.string.sign_rough)).append(" ")
append(receipt.willSentFiat).append(" ")
append(receipt.symbols.fiat)
append(" (fee: ${receipt.feeFiat} ")
append(receipt.symbols.fiat).append(")")
}
totalLayout.tvWillBeSentValue.update(willSent)
}
@ -201,19 +201,19 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
totalLayout.show(true)
totalTokenLayout.show(false)
fg.tvReceiptAmountValue.update("${receipt.amountFiat.toPlainString()} ${receipt.symbols.fiat}")
fg.tvReceiptFeeValue.update("${receipt.feeFiat.toPlainString()} ${receipt.symbols.fiat}")
totalLayout.tvTotalValue.update("${receipt.totalFiat.toPlainString()} ${receipt.symbols.fiat}")
fg.tvReceiptAmountValue.update("${receipt.amountFiat} ${receipt.symbols.fiat}")
fg.tvReceiptFeeValue.update("${receipt.feeFiat} ${receipt.symbols.fiat}")
totalLayout.tvTotalValue.update("${receipt.totalFiat} ${receipt.symbols.fiat}")
val willSent = SpannableStringBuilder()
.bold {
append(receipt.symbols.token)
append(" ")
append(receipt.willSentFeeCrypto.toPlainString())
append(receipt.willSentFeeCrypto)
}.append(" ").append(getString(R.string.generic_and)).append(" ")
.bold {
append(receipt.symbols.crypto).append(" ")
append(receipt.willSentFeeCrypto.toPlainString()).append(" ")
append(receipt.willSentFeeCrypto).append(" ")
}
.append(mainLayout.context.getString(R.string.send_total_will_be_sent))
totalLayout.tvWillBeSentValue.update(willSent)
@ -224,15 +224,13 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
totalLayout.show(false)
totalTokenLayout.show(true)
fg.tvReceiptAmountValue.update("${receipt.amountToken.toPlainString()} ${receipt.symbols.token}")
fg.tvReceiptFeeValue.update("${receipt.feeCrypto.toPlainString()} ${receipt.symbols.crypto}")
fg.tvReceiptAmountValue.update("${receipt.amountToken} ${receipt.symbols.token}")
fg.tvReceiptFeeValue.update("${receipt.feeCrypto} ${receipt.symbols.crypto}")
val willSent = SpannableStringBuilder()
.bold {
append(getString(R.string.sign_rough))
append(" ")
append(receipt.totalFiat.toPlainString())
append(" ")
append(getString(R.string.sign_rough)).append(" ")
append(receipt.totalFiat).append(" ")
append(receipt.symbols.fiat)
}
totalTokenLayout.tvTotalTokenCryptoValue.update(willSent)