diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataStateExpress.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataStateExpress.kt index b2c0d0c359..1d29633fec 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataStateExpress.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataStateExpress.kt @@ -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, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt index 0f31b4c6d7..bb0f7e892c 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt @@ -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) { diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt index c87574b344..631bdb18a8 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt @@ -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() + } } } }