Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-08 18:55:01 +03:00
parent 06d08b8f2e
commit b6585c69a9
8 changed files with 27 additions and 27 deletions

View file

@ -50,10 +50,10 @@ internal class SendEventStateFactory(
is TransactionFee.Single -> fee.normal
is TransactionFee.Choosable -> {
when (feeSelector.selectedFee) {
FeeType.SLOW -> fee.minimum
FeeType.MARKET -> fee.normal
FeeType.FAST -> fee.priority
FeeType.CUSTOM -> return state
FeeType.Slow -> fee.minimum
FeeType.Market -> fee.normal
FeeType.Fast -> fee.priority
FeeType.Custom -> return state
}
}
}

View file

@ -28,10 +28,10 @@ internal class FeeConverter(
return when (val fees = value.fees) {
is TransactionFee.Choosable -> {
when (value.selectedFee) {
FeeType.SLOW -> fees.minimum
FeeType.MARKET -> fees.normal
FeeType.FAST -> fees.priority
FeeType.CUSTOM -> convertCustom(value, fees)
FeeType.Slow -> fees.minimum
FeeType.Market -> fees.normal
FeeType.Fast -> fees.priority
FeeType.Custom -> convertCustom(value, fees)
}
}
is TransactionFee.Single -> fees.normal

View file

@ -69,7 +69,7 @@ internal class FeeNotificationFactory(
val minimumValue = multipleFees.minimum.amount.value ?: return
val customAmount = customFee.firstOrNull() ?: return
val customValue = customAmount.value.parseToBigDecimal(customAmount.decimals)
if (selectedFee == FeeType.CUSTOM && minimumValue > customValue) {
if (selectedFee == FeeType.Custom && minimumValue > customValue) {
add(SendFeeNotification.Warning.TooLow)
}
}
@ -84,7 +84,7 @@ internal class FeeNotificationFactory(
val customAmount = customFee.firstOrNull() ?: return
val customValue = customAmount.value.parseToBigDecimal(customAmount.decimals)
val diff = customValue / highValue
if (selectedFee == FeeType.CUSTOM && diff > FEE_MAX_DIFF) {
if (selectedFee == FeeType.Custom && diff > FEE_MAX_DIFF) {
add(SendFeeNotification.Warning.TooHigh(diff.toFormattedString(HIGH_FEE_DIFF_DECIMALS)))
}
}

View file

@ -13,7 +13,7 @@ internal sealed class FeeSelectorState {
data class Content(
val fees: TransactionFee,
val selectedFee: FeeType = FeeType.MARKET,
val selectedFee: FeeType = FeeType.Market,
val customValues: ImmutableList<SendTextField.CustomFee> = persistentListOf(),
) : FeeSelectorState()
@ -21,8 +21,8 @@ internal sealed class FeeSelectorState {
}
enum class FeeType {
SLOW,
MARKET,
FAST,
CUSTOM,
Slow,
Market,
Fast,
Custom,
}

View file

@ -191,7 +191,7 @@ internal class FeeStateFactory(
val fee = feeConverter.convert(feeSelectorState)
val feeValue = fee.amount.value ?: BigDecimal.ZERO
val isNotCustom = feeSelectorState.selectedFee != FeeType.CUSTOM
val isNotCustom = feeSelectorState.selectedFee != FeeType.Custom
val isNotEmptyCustom = if (customValue != null) {
!customValue.value.parseToBigDecimal(customValue.decimals).isZero() && !isNotCustom
} else {

View file

@ -20,7 +20,7 @@ internal fun SendCustomFeeEthereum(
selectedFee: FeeType,
modifier: Modifier = Modifier,
) {
if (selectedFee == FeeType.CUSTOM && customValues.isNotEmpty()) {
if (selectedFee == FeeType.Custom && customValues.isNotEmpty()) {
Column(
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing12),
modifier = modifier,

View file

@ -175,7 +175,7 @@ internal fun LazyListScope.subtractButton(
item {
val feeStateContent = feeSendState as? FeeSelectorState.Content
val isCustomAvailable = feeStateContent?.customValues.isNullOrEmpty().not()
val isCustomSelected = feeStateContent?.selectedFee == FeeType.CUSTOM
val isCustomSelected = feeStateContent?.selectedFee == FeeType.Custom
val topPadding = if (isCustomSelected && isCustomAvailable) {
TangemTheme.dimens.spacing12
} else {

View file

@ -88,8 +88,8 @@ internal fun SendSpeedSelector(
amount = getCryptoReference(minimumAmount, state.isFeeApproximate),
fiatAmount = getFiatReference(minimumAmount, state.rate, state.appCurrency),
symbolLength = minimumAmount.currencySymbol.length,
isSelected = isSelected == FeeType.SLOW,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.SLOW) },
isSelected = isSelected == FeeType.Slow,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.Slow) },
)
val normalAmount = fees.normal.amount
SendSpeedSelectorItem(
@ -98,8 +98,8 @@ internal fun SendSpeedSelector(
amount = getCryptoReference(normalAmount, state.isFeeApproximate),
fiatAmount = getFiatReference(normalAmount, state.rate, state.appCurrency),
symbolLength = normalAmount.currencySymbol.length,
isSelected = isSelected == FeeType.MARKET,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.MARKET) },
isSelected = isSelected == FeeType.Market,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.Market) },
)
val priorityAmount = fees.priority.amount
SendSpeedSelectorItem(
@ -108,8 +108,8 @@ internal fun SendSpeedSelector(
amount = getCryptoReference(priorityAmount, state.isFeeApproximate),
fiatAmount = getFiatReference(priorityAmount, state.rate, state.appCurrency),
symbolLength = priorityAmount.currencySymbol.length,
isSelected = isSelected == FeeType.FAST,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.FAST) },
isSelected = isSelected == FeeType.Fast,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.Fast) },
showDivider = fees.normal is Fee.Ethereum,
)
AnimatedVisibility(
@ -123,8 +123,8 @@ internal fun SendSpeedSelector(
SendSpeedSelectorItem(
titleRes = R.string.common_fee_selector_option_custom,
iconRes = R.drawable.ic_edit_24,
isSelected = isSelected == FeeType.CUSTOM,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.CUSTOM) },
isSelected = isSelected == FeeType.Custom,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.Custom) },
showDivider = fees.normal !is Fee.Ethereum,
showWarning = showWarning,
)
@ -139,7 +139,7 @@ internal fun SendSpeedSelector(
amount = getCryptoReference(normalAmount, state.isFeeApproximate),
fiatAmount = getFiatReference(normalAmount, state.rate, state.appCurrency),
symbolLength = normalAmount.currencySymbol.length,
onSelect = { clickIntents.onFeeSelectorClick(FeeType.MARKET) },
onSelect = { clickIntents.onFeeSelectorClick(FeeType.Market) },
showDivider = false,
)
}