Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-19 16:53:39 +03:00
parent d30abc9aea
commit 4a9062821b
7 changed files with 27 additions and 23 deletions

View file

@ -48,6 +48,7 @@ internal sealed class SendStates {
val walletBalance: TextReference,
val tokenIconState: TokenIconState,
val segmentedButtonConfig: PersistentList<SendAmountSegmentedButtonsConfig>,
val isSegmentedButtonsEnabled: Boolean,
val amountTextField: SendTextField.AmountField,
val notifications: ImmutableList<SendNotification>,
val appCurrencyCode: String,

View file

@ -42,22 +42,19 @@ internal class SendAmountStateConverter(
isFeeLoading = false,
appCurrencyCode = appCurrency.code,
subtractedFee = null,
segmentedButtonConfig = if (status.value.fiatRate.isNullOrZero()) {
persistentListOf()
} else {
persistentListOf(
SendAmountSegmentedButtonsConfig(
title = stringReference(status.currency.symbol),
iconState = iconStateConverter.convert(status),
isFiat = false,
),
SendAmountSegmentedButtonsConfig(
title = stringReference(appCurrency.code),
iconUrl = appCurrency.iconSmallUrl,
isFiat = true,
),
)
},
segmentedButtonConfig = persistentListOf(
SendAmountSegmentedButtonsConfig(
title = stringReference(status.currency.symbol),
iconState = iconStateConverter.convert(status),
isFiat = false,
),
SendAmountSegmentedButtonsConfig(
title = stringReference(appCurrency.code),
iconUrl = appCurrency.iconSmallUrl,
isFiat = true,
),
),
isSegmentedButtonsEnabled = !status.value.fiatRate.isNullOrZero(),
)
}
}

View file

@ -49,6 +49,7 @@ internal object AmountStatePreviewData {
isError = false,
error = TextReference.EMPTY,
),
isSegmentedButtonsEnabled = true,
)
val fiatAmountState = amountState.copy(

View file

@ -29,6 +29,7 @@ internal fun LazyListScope.buttons(
segmentedButtonConfig: PersistentList<SendAmountSegmentedButtonsConfig>,
clickIntents: SendClickIntents,
isMaxButtonEnabled: Boolean,
isSegmentedButtonsEnabled: Boolean,
) {
item(
key = AMOUNT_BUTTONS_KEY,
@ -48,6 +49,7 @@ internal fun LazyListScope.buttons(
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
clickIntents.onCurrencyChangeClick(it.isFiat)
},
isEnabled = isSegmentedButtonsEnabled,
) {
SendAmountCurrencyButton(it)
}

View file

@ -36,6 +36,7 @@ internal fun SendAmountContent(
segmentedButtonConfig = amountState.segmentedButtonConfig,
clickIntents = clickIntents,
isMaxButtonEnabled = !amountState.isFeeLoading,
isSegmentedButtonsEnabled = amountState.isSegmentedButtonsEnabled,
)
notifications(amountState.notifications)
}