Updated on 2026-08-14

This commit is contained in:
Tangem 2023-09-20 16:57:15 +08:00
parent 864d524841
commit 9b294366d4
10 changed files with 48 additions and 52 deletions

View file

@ -214,15 +214,9 @@ internal class WalletStateFactory(
}
}
fun getLoadingTxHistoryState(
itemsCountEither: Either<TxHistoryStateError, Int>,
cryptoCurrencyStatus: CryptoCurrencyStatus,
): WalletState {
fun getLoadingTxHistoryState(itemsCountEither: Either<TxHistoryStateError, Int>): WalletState {
return loadingTransactionsStateConverter.convert(
WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel(
historyLoadingState = itemsCountEither,
cryptoCurrencyStatus = cryptoCurrencyStatus,
),
WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel(historyLoadingState = itemsCountEither),
)
}

View file

@ -6,7 +6,6 @@ import com.tangem.common.Converter
import com.tangem.common.Provider
import com.tangem.core.ui.components.transactions.state.TransactionState
import com.tangem.core.ui.components.transactions.state.TxHistoryState.*
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.txhistory.models.TxHistoryStateError
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
@ -28,23 +27,19 @@ internal class WalletLoadingTxHistoryConverter(
override fun convert(value: WalletLoadingTxHistoryModel): WalletState {
return value.historyLoadingState.fold(
ifLeft = { convertError(it, value.cryptoCurrencyStatus) },
ifLeft = ::convertError,
ifRight = ::convertRight,
)
}
private fun convertError(error: TxHistoryStateError, cryptoCurrencyStatus: CryptoCurrencyStatus): WalletState {
private fun convertError(error: TxHistoryStateError): WalletState {
val state = currentStateProvider()
return if (state is WalletSingleCurrencyState.Content) {
state.copy(
txHistoryState = when (error) {
is TxHistoryStateError.EmptyTxHistories -> {
Empty(onBuyClick = { clickIntents.onBuyClick(cryptoCurrencyStatus) })
}
is TxHistoryStateError.DataError -> {
Error(onReloadClick = clickIntents::onReloadClick)
}
is TxHistoryStateError.EmptyTxHistories -> Empty
is TxHistoryStateError.DataError -> Error(onReloadClick = clickIntents::onReloadClick)
is TxHistoryStateError.TxHistoryNotImplemented -> {
NotSupported(onExploreClick = clickIntents::onExploreClick)
}
@ -76,8 +71,5 @@ internal class WalletLoadingTxHistoryConverter(
return state
}
data class WalletLoadingTxHistoryModel(
val historyLoadingState: Either<TxHistoryStateError, Int>,
val cryptoCurrencyStatus: CryptoCurrencyStatus,
)
data class WalletLoadingTxHistoryModel(val historyLoadingState: Either<TxHistoryStateError, Int>)
}

View file

@ -303,7 +303,9 @@ private fun NonContentBalanceText(text: TextReference) {
}
private fun Modifier.nonContentBalanceSize(dimens: TangemDimens): Modifier {
return size(width = dimens.size102, height = dimens.size32)
return this
.padding(vertical = dimens.spacing4)
.size(width = dimens.size102, height = dimens.size24)
}
@OptIn(ExperimentalAnimationApi::class)

View file

@ -711,7 +711,6 @@ internal class WalletViewModel @Inject constructor(
uiState = stateFactory.getLoadingTxHistoryState(
itemsCountEither = txHistoryItemsCountEither,
cryptoCurrencyStatus = singleWalletCryptoCurrencyStatus ?: return@launch,
)
txHistoryItemsCountEither.onRight {