Updated on 2026-08-14
This commit is contained in:
commit
300e06ab13
5 changed files with 23 additions and 6 deletions
|
|
@ -120,6 +120,12 @@ class AmountStateConverterV2(
|
|||
val crypto = maxEnterAmount.amount.format { crypto(cryptoCurrencyStatus.currency) }
|
||||
val noFeeRate = cryptoCurrencyStatus.value.fiatRate.isNullOrZero()
|
||||
|
||||
if (cryptoCurrencyStatus.value is CryptoCurrencyStatus.Loading) {
|
||||
return AmountState.Empty(
|
||||
isRedesignEnabled = isRedesignEnabled,
|
||||
)
|
||||
}
|
||||
|
||||
return AmountState.Data(
|
||||
title = value.title,
|
||||
availableBalance = if (isRedesignEnabled) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class AmountFieldChangeTransformer(
|
|||
|
||||
val amountTextField = prevState.amountTextField
|
||||
|
||||
if (value.isEmpty()) return prevState.emptyState()
|
||||
if (value.isEmpty()) return prevState.emptyState(maxEnterAmount.fiatRate)
|
||||
val cryptoDecimals = amountTextField.cryptoAmount.decimals
|
||||
val fiatDecimals = amountTextField.fiatAmount.decimals
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class AmountFieldChangeTransformer(
|
|||
error = when {
|
||||
isExceedBalance -> resourceReference(R.string.send_validation_amount_exceeds_balance)
|
||||
isLessThanMinimumIfProvided -> {
|
||||
val minimumAmount = minimumTransactionAmount?.amount.format {
|
||||
val minimumAmount = minimumTransactionAmount.amount.format {
|
||||
crypto(cryptoCurrencyStatus.currency)
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class AmountFieldChangeTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun AmountState.Data.emptyState(): AmountState.Data {
|
||||
private fun AmountState.Data.emptyState(fiatRate: BigDecimal?): AmountState.Data {
|
||||
return copy(
|
||||
isPrimaryButtonEnabled = false,
|
||||
reduceAmountBy = BigDecimal.ZERO,
|
||||
|
|
@ -104,7 +104,7 @@ class AmountFieldChangeTransformer(
|
|||
value = "",
|
||||
fiatValue = "",
|
||||
cryptoAmount = amountTextField.cryptoAmount.copy(value = BigDecimal.ZERO),
|
||||
fiatAmount = amountTextField.fiatAmount.copy(value = BigDecimal.ZERO),
|
||||
fiatAmount = amountTextField.fiatAmount.copy(value = if (fiatRate != null) BigDecimal.ZERO else null),
|
||||
isError = false,
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.None,
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ class AmountFieldConverterV2(
|
|||
val cryptoAmount = cryptoDecimal.convertToAmount(cryptoCurrencyStatus.currency)
|
||||
val fiatRate = cryptoCurrencyStatus.value.fiatRate
|
||||
val (fiatValue, fiatDecimal) = when {
|
||||
value.isEmpty() -> "" to BigDecimal.ZERO
|
||||
fiatRate.isNullOrZero() -> "" to null
|
||||
value.isEmpty() -> "" to BigDecimal.ZERO
|
||||
else -> {
|
||||
val fiatDecimal = fiatRate?.multiply(cryptoDecimal)
|
||||
val fiatValue = fiatDecimal?.parseBigDecimal(FIAT_DECIMALS).orEmpty()
|
||||
|
|
|
|||
|
|
@ -93,6 +93,13 @@ object AmountStatePreviewData {
|
|||
amountTextField = amountWithValueState.amountTextField.copy(isFiatValue = false),
|
||||
)
|
||||
|
||||
val amountStateV2WithoutRates = amountState.copy(
|
||||
amountTextField = amountState.amountTextField.copy(
|
||||
fiatAmount = amountState.amountTextField.fiatAmount.copy(
|
||||
value = null,
|
||||
),
|
||||
),
|
||||
)
|
||||
val amountErrorState = amountWithValueState.copy(
|
||||
amountTextField = amountWithValueState.amountTextField.copy(
|
||||
isError = true,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Alignment.Companion.BottomCenter
|
||||
import androidx.compose.ui.Alignment.Companion.TopCenter
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
|
|
@ -141,7 +142,6 @@ private fun AmountSecondary(amountUM: AmountState, onCurrencyChange: (Boolean) -
|
|||
AmountFieldCurrencyInfo(
|
||||
amountUM = amountUM,
|
||||
onCurrencyChange = onCurrencyChange,
|
||||
|
||||
)
|
||||
AmountFieldError(
|
||||
isError = amountUM.amountTextField.isError,
|
||||
|
|
@ -157,6 +157,8 @@ private fun AmountSecondary(amountUM: AmountState, onCurrencyChange: (Boolean) -
|
|||
|
||||
@Composable
|
||||
private fun BoxScope.AmountFieldCurrencyInfo(amountUM: AmountState.Data, onCurrencyChange: (Boolean) -> Unit) {
|
||||
val isFiatAvailable = amountUM.amountTextField.fiatAmount.value != null
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
|
|
@ -168,6 +170,7 @@ private fun BoxScope.AmountFieldCurrencyInfo(amountUM: AmountState.Data, onCurre
|
|||
indication = null,
|
||||
onClick = { onCurrencyChange(!amountUM.amountTextField.isFiatValue) },
|
||||
)
|
||||
.alpha(if (isFiatAvailable) 1f else 0f)
|
||||
.padding(4.dp),
|
||||
) {
|
||||
val iconRotateState by animateFloatAsState(
|
||||
|
|
@ -327,6 +330,7 @@ private class AmountFieldV2PreviewProvider : PreviewParameterProvider<AmountStat
|
|||
AmountStatePreviewData.emptyState,
|
||||
AmountStatePreviewData.amountState,
|
||||
AmountStatePreviewData.amountErrorState,
|
||||
AmountStatePreviewData.amountStateV2WithoutRates,
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
Loading…
Add table
Add a link
Reference in a new issue