Updated on 2026-08-14
This commit is contained in:
parent
8b15662f33
commit
54d38c6bf0
6 changed files with 30 additions and 15 deletions
|
|
@ -15,6 +15,7 @@ import com.tangem.features.send.impl.R
|
|||
import com.tangem.features.send.impl.presentation.domain.AvailableWallet
|
||||
import com.tangem.features.send.impl.presentation.state.amount.SendAmountStateConverter
|
||||
import com.tangem.features.send.impl.presentation.state.confirm.SendConfirmStateConverter
|
||||
import com.tangem.features.send.impl.presentation.state.fee.FeeSelectorState
|
||||
import com.tangem.features.send.impl.presentation.state.fee.SendFeeStateConverter
|
||||
import com.tangem.features.send.impl.presentation.state.fields.SendAmountFieldConverter
|
||||
import com.tangem.features.send.impl.presentation.state.recipient.SendRecipientHistoryListConverter
|
||||
|
|
@ -263,7 +264,7 @@ internal class SendStateFactory(
|
|||
return state.copy(
|
||||
sendState = state.sendState?.copy(
|
||||
isSending = isSending,
|
||||
isPrimaryButtonEnabled = !isSending,
|
||||
isPrimaryButtonEnabled = isPrimaryButtonEnabled(state, state.sendState.notifications),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -285,10 +286,9 @@ internal class SendStateFactory(
|
|||
fun getSendNotificationState(notifications: ImmutableList<SendNotification>): SendUiState {
|
||||
val state = currentStateProvider()
|
||||
val sendState = state.sendState ?: return state
|
||||
val hasErrorNotifications = notifications.any { it is SendNotification.Error }
|
||||
return state.copy(
|
||||
sendState = sendState.copy(
|
||||
isPrimaryButtonEnabled = !hasErrorNotifications,
|
||||
isPrimaryButtonEnabled = isPrimaryButtonEnabled(state, notifications),
|
||||
notifications = notifications,
|
||||
showTapHelp = sendState.showTapHelp && notifications.isEmpty(),
|
||||
),
|
||||
|
|
@ -302,5 +302,12 @@ internal class SendStateFactory(
|
|||
sendState = sendState.copy(showTapHelp = false),
|
||||
)
|
||||
}
|
||||
|
||||
private fun isPrimaryButtonEnabled(state: SendUiState, notifications: ImmutableList<SendNotification>): Boolean {
|
||||
val sendState = state.sendState ?: return false
|
||||
val feeState = state.feeState ?: return false
|
||||
val hasErrorNotifications = notifications.any { it is SendNotification.Error }
|
||||
return !hasErrorNotifications && !sendState.isSending && feeState.feeSelectorState is FeeSelectorState.Content
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ internal sealed class SendStates {
|
|||
@Stable
|
||||
data class SendState(
|
||||
override val type: SendUiStateType = SendUiStateType.Send,
|
||||
override val isPrimaryButtonEnabled: Boolean = true,
|
||||
override val isPrimaryButtonEnabled: Boolean = false,
|
||||
val isSending: Boolean,
|
||||
val isSuccess: Boolean,
|
||||
val transactionDate: Long,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ internal class SendConfirmStateConverter(
|
|||
) : Converter<Unit, SendStates.SendState> {
|
||||
override fun convert(value: Unit): SendStates.SendState {
|
||||
return SendStates.SendState(
|
||||
isPrimaryButtonEnabled = true,
|
||||
isPrimaryButtonEnabled = false,
|
||||
isSending = false,
|
||||
isSuccess = false,
|
||||
transactionDate = 0L,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ internal class FeeStateFactory(
|
|||
val state = currentStateProvider()
|
||||
val feeState = state.feeState ?: return state
|
||||
return state.copy(
|
||||
sendState = state.sendState?.copy(
|
||||
isPrimaryButtonEnabled = false,
|
||||
),
|
||||
feeState = feeState.copy(
|
||||
feeSelectorState = if (feeState.feeSelectorState is FeeSelectorState.Content) {
|
||||
feeState.feeSelectorState
|
||||
|
|
@ -77,6 +80,9 @@ internal class FeeStateFactory(
|
|||
|
||||
val fee = feeConverter.convert(updatedFeeSelectorState)
|
||||
return state.copy(
|
||||
sendState = state.sendState?.copy(
|
||||
isPrimaryButtonEnabled = true,
|
||||
),
|
||||
feeState = feeState.copy(
|
||||
feeSelectorState = updatedFeeSelectorState,
|
||||
fee = fee,
|
||||
|
|
@ -91,6 +97,9 @@ internal class FeeStateFactory(
|
|||
feeState = state.feeState?.copy(
|
||||
feeSelectorState = FeeSelectorState.Error,
|
||||
),
|
||||
sendState = state.sendState?.copy(
|
||||
isPrimaryButtonEnabled = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -692,9 +692,6 @@ internal class SendViewModel @Inject constructor(
|
|||
updateNotifications()
|
||||
updateFeeNotifications()
|
||||
}.saveIn(feeJobHolder)
|
||||
.invokeOnCompletion {
|
||||
// todo
|
||||
}
|
||||
}
|
||||
|
||||
private fun onFeeLoadFailed(isShowStatus: Boolean) {
|
||||
|
|
@ -713,12 +710,14 @@ internal class SendViewModel @Inject constructor(
|
|||
val recipientState = uiState.recipientState ?: return null
|
||||
val amount = amountState.amountTextField.cryptoAmount.value ?: return null
|
||||
|
||||
return getFeeUseCase.invoke(
|
||||
amount = amount,
|
||||
destination = recipientState.addressTextField.value,
|
||||
userWallet = userWallet,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
)
|
||||
return feeCryptoCurrencyStatus?.let { feeCurrencyStatus ->
|
||||
getFeeUseCase.invoke(
|
||||
amount = amount,
|
||||
destination = recipientState.addressTextField.value,
|
||||
userWallet = userWallet,
|
||||
cryptoCurrency = feeCurrencyStatus.currency,
|
||||
)
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ leakcanary = "2.13"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "release-app_5.9-605"
|
||||
tangemBlockchainSdk = "release-app_5.9-608"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.9-343"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue