Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-06 16:10:36 +03:00
parent 1bd432de87
commit 5d381ed902
2 changed files with 37 additions and 0 deletions

View file

@ -784,6 +784,36 @@ internal class StateBuilder(
)
}
fun updateProvidersBottomSheetContent(
uiState: SwapStateHolder,
tokenSwapInfoForProviders: Map<String, TokenSwapInfo>,
): SwapStateHolder {
val config = uiState.bottomSheetConfig?.content as? ChooseProviderBottomSheetConfig
return if (config != null) {
val providers = config.providers
uiState.copy(
bottomSheetConfig = uiState.bottomSheetConfig.copy(
content = config.copy(
providers = providers.map {
val tokenInfo = tokenSwapInfoForProviders[it.id]
if (it is ProviderState.Content && tokenInfo != null) {
val rateString = tokenInfo.tokenAmount
.getFormattedCryptoAmount(tokenInfo.cryptoCurrencyStatus.currency)
it.copy(
subtitle = stringReference(rateString),
)
} else {
it
}
}.toImmutableList(),
),
),
)
} else {
uiState
}
}
fun updateSelectedProvider(uiState: SwapStateHolder, selectedProviderId: String): SwapStateHolder {
val config = uiState.bottomSheetConfig?.content as? ChooseProviderBottomSheetConfig
return if (config != null) {

View file

@ -271,6 +271,13 @@ internal class SwapViewModel @Inject constructor(
if (providersState.isNotEmpty()) {
val (provider, state) = updateLoadedQuotes(providersState)
setupLoadedState(provider, state, fromToken)
uiState = stateBuilder.updateProvidersBottomSheetContent(
uiState = uiState,
tokenSwapInfoForProviders = providersState
.getLastLoadedSuccessStates()
.entries
.associate { it.key.providerId to it.value.toTokenInfo },
)
} else {
Timber.e("Accidentally empty quotes list")
}