Updated on 2026-08-14
This commit is contained in:
parent
fa1a34efa9
commit
521305d2b7
3 changed files with 40 additions and 1 deletions
|
|
@ -5,7 +5,15 @@ import com.tangem.feature.swap.domain.models.domain.CryptoCurrencySwapInfo
|
|||
data class TokensDataStateExpress(
|
||||
val fromGroup: CurrenciesGroup,
|
||||
val toGroup: CurrenciesGroup,
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
val EMPTY =
|
||||
TokensDataStateExpress(
|
||||
fromGroup = CurrenciesGroup(emptyList(), emptyList()),
|
||||
toGroup = CurrenciesGroup(emptyList(), emptyList()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class CurrenciesGroup(
|
||||
val available: List<CryptoCurrencySwapInfo>,
|
||||
|
|
|
|||
|
|
@ -567,6 +567,24 @@ internal class StateBuilder(
|
|||
}
|
||||
}
|
||||
|
||||
fun createInitialErrorState(uiState: SwapStateHolder, onRefreshClick: () -> Unit): SwapStateHolder {
|
||||
return uiState.copy(
|
||||
warnings = listOf(
|
||||
SwapWarning.GeneralWarning(
|
||||
notificationConfig = NotificationConfig(
|
||||
title = TextReference.Res(R.string.warning_express_refresh_required_title),
|
||||
subtitle = TextReference.EMPTY,
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonsState = NotificationConfig.ButtonsState.PrimaryButtonConfig(
|
||||
text = TextReference.Res(R.string.warning_button_refresh),
|
||||
onClick = onRefreshClick,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createFeeState(txFeeState: TxFeeState, feeType: FeeType): FeeItemState {
|
||||
val isClickable: Boolean
|
||||
val fee = when (txFeeState) {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,19 @@ internal class SwapViewModel @Inject constructor(
|
|||
)
|
||||
}.onFailure {
|
||||
Timber.tag(loggingTag).e(it)
|
||||
|
||||
applyInitialTokenChoice(
|
||||
state = TokensDataStateExpress.EMPTY,
|
||||
selectedCurrency = null,
|
||||
)
|
||||
|
||||
uiState = stateBuilder.createInitialErrorState(uiState) {
|
||||
uiState = stateBuilder.createInitialLoadingState(
|
||||
initialCurrency = initialCryptoCurrency,
|
||||
networkInfo = blockchainInteractor.getBlockchainInfo(initialCryptoCurrency.network.backendId),
|
||||
)
|
||||
initTokens()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue