Updated on 2026-08-14
This commit is contained in:
parent
864d524841
commit
9b294366d4
10 changed files with 48 additions and 52 deletions
|
|
@ -35,10 +35,7 @@ fun LazyListScope.txHistoryItems(
|
|||
)
|
||||
}
|
||||
is TxHistoryState.Empty -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.Empty(onClick = state.onBuyClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
nonContentItem(state = EmptyTransactionsBlockState.Empty, modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.Error -> {
|
||||
nonContentItem(
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
color = TangemTheme.colors.text.secondary,
|
||||
)
|
||||
|
||||
ActionButton(config = state.actionButtonConfig)
|
||||
state.actionButtonConfig?.let {
|
||||
ActionButton(config = it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +75,7 @@ private fun EmptyTransactionBlock_Dark(
|
|||
|
||||
private class EmptyTransactionBlockStateProvider : CollectionPreviewParameterProvider<EmptyTransactionsBlockState>(
|
||||
collection = listOf(
|
||||
EmptyTransactionsBlockState.Empty(onClick = {}),
|
||||
EmptyTransactionsBlockState.Empty,
|
||||
EmptyTransactionsBlockState.FailedToLoad(onClick = {}),
|
||||
EmptyTransactionsBlockState.NotImplemented(onClick = {}),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
|||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
sealed class EmptyTransactionsBlockState(
|
||||
val actionButtonConfig: ActionButtonConfig? = null,
|
||||
val iconRes: Int,
|
||||
val text: TextReference,
|
||||
val actionButtonConfig: ActionButtonConfig,
|
||||
) {
|
||||
|
||||
class FailedToLoad(onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
data class FailedToLoad(val onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_reload),
|
||||
iconResId = R.drawable.ic_refresh_24,
|
||||
|
|
@ -21,18 +21,12 @@ sealed class EmptyTransactionsBlockState(
|
|||
text = TextReference.Res(R.string.transaction_history_error_failed_to_load),
|
||||
)
|
||||
|
||||
class Empty(onClick: (() -> Unit)?) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_buy),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = onClick ?: {},
|
||||
enabled = onClick != null,
|
||||
),
|
||||
iconRes = R.drawable.img_coin_64,
|
||||
object Empty : EmptyTransactionsBlockState(
|
||||
iconRes = R.drawable.ic_empty_token_64,
|
||||
text = TextReference.Res(R.string.transaction_history_empty_transactions),
|
||||
)
|
||||
|
||||
class NotImplemented(onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
data class NotImplemented(val onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_explore_transaction_history),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
|
|
|
|||
|
|
@ -13,12 +13,8 @@ sealed interface TxHistoryState {
|
|||
*/
|
||||
data class Content(val contentItems: MutableStateFlow<PagingData<TxHistoryItemState>>) : TxHistoryState
|
||||
|
||||
/**
|
||||
* Empty state
|
||||
*
|
||||
* @property onBuyClick lambda be invoke when buy button was clicked
|
||||
*/
|
||||
data class Empty(val onBuyClick: () -> Unit) : TxHistoryState
|
||||
/** Empty state */
|
||||
object Empty : TxHistoryState
|
||||
|
||||
/**
|
||||
* Not supported tx history state
|
||||
|
|
|
|||
24
core/ui/src/main/res/drawable/ic_empty_token_64.xml
Normal file
24
core/ui/src/main/res/drawable/ic_empty_token_64.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="64"
|
||||
android:viewportHeight="64">
|
||||
<group>
|
||||
<clip-path android:pathData="M0,0h64v64h-64z" />
|
||||
<path
|
||||
android:pathData="M37.84,55.346C50.625,52.278 58.482,39.342 55.389,26.453C52.296,13.564 39.424,5.603 26.639,8.671C20.067,10.248 14.797,14.433 11.647,19.879M11.647,19.879L22.5,19.879M11.647,19.879L11.647,8.001"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#C9C9C9"
|
||||
android:strokeLineCap="round" />
|
||||
<path
|
||||
android:pathData="M9.945,22.612C10.593,22.85 10.926,23.568 10.688,24.216L10.651,24.317C10.416,24.966 9.699,25.302 9.05,25.067C8.401,24.832 8.065,24.115 8.3,23.466L8.341,23.354C8.579,22.706 9.297,22.374 9.945,22.612ZM8.025,31.53C8.715,31.509 9.291,32.051 9.312,32.742L9.314,32.795L9.315,32.84C9.339,33.53 8.799,34.108 8.109,34.132C7.419,34.156 6.84,33.616 6.816,32.926L6.815,32.877L6.813,32.817C6.792,32.127 7.335,31.551 8.025,31.53ZM9.036,38.993C9.686,38.759 10.401,39.097 10.634,39.747L10.665,39.83C10.9,40.479 10.565,41.196 9.917,41.432C9.268,41.667 8.551,41.333 8.315,40.684L8.282,40.591C8.048,39.942 8.386,39.226 9.036,38.993ZM12.309,45.763C12.854,45.34 13.639,45.439 14.062,45.984L14.116,46.054C14.542,46.598 14.446,47.383 13.902,47.808C13.358,48.234 12.572,48.138 12.147,47.594L12.087,47.516C11.664,46.971 11.763,46.186 12.309,45.763ZM17.512,51.191C17.901,50.621 18.679,50.474 19.249,50.863L19.322,50.912C19.894,51.299 20.044,52.076 19.658,52.648C19.271,53.22 18.494,53.37 17.922,52.983L17.841,52.928C17.271,52.539 17.124,51.762 17.512,51.191ZM24.135,54.753C24.328,54.09 25.022,53.709 25.685,53.902L25.769,53.927C26.433,54.117 26.817,54.81 26.626,55.473C26.436,56.137 25.743,56.52 25.08,56.33L24.986,56.303C24.323,56.11 23.942,55.416 24.135,54.753ZM31.537,56.082C31.516,55.392 32.058,54.815 32.748,54.794L32.792,54.792L32.837,54.791C33.527,54.767 34.105,55.307 34.129,55.997C34.153,56.687 33.613,57.266 32.923,57.29L32.874,57.291L32.825,57.293C32.134,57.314 31.558,56.772 31.537,56.082Z"
|
||||
android:fillColor="#C9C9C9"
|
||||
android:fillType="evenOdd" />
|
||||
<path
|
||||
android:pathData="M23.528,30.572L32.5,19.036L41.472,30.572L32.5,44.672L23.528,30.572Z"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#C9C9C9" />
|
||||
</group>
|
||||
</vector>
|
||||
|
|
@ -23,12 +23,8 @@ internal class TokenDetailsLoadingTxHistoryConverter(
|
|||
private fun convertError(error: TxHistoryStateError): TokenDetailsState {
|
||||
return currentStateProvider().copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryStateError.EmptyTxHistories -> {
|
||||
TxHistoryState.Empty(onBuyClick = clickIntents::onBuyClick)
|
||||
}
|
||||
is TxHistoryStateError.DataError -> {
|
||||
TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
}
|
||||
is TxHistoryStateError.EmptyTxHistories -> TxHistoryState.Empty
|
||||
is TxHistoryStateError.DataError -> TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
is TxHistoryStateError.TxHistoryNotImplemented -> {
|
||||
TxHistoryState.NotSupported(onExploreClick = clickIntents::onExploreClick)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>)
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -711,7 +711,6 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
uiState = stateFactory.getLoadingTxHistoryState(
|
||||
itemsCountEither = txHistoryItemsCountEither,
|
||||
cryptoCurrencyStatus = singleWalletCryptoCurrencyStatus ?: return@launch,
|
||||
)
|
||||
|
||||
txHistoryItemsCountEither.onRight {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue