diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt index 93a6d16058..f28a081419 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt @@ -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( diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt index 4045bf505e..7e5efdd446 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt @@ -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( collection = listOf( - EmptyTransactionsBlockState.Empty(onClick = {}), + EmptyTransactionsBlockState.Empty, EmptyTransactionsBlockState.FailedToLoad(onClick = {}), EmptyTransactionsBlockState.NotImplemented(onClick = {}), ), diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionsBlockState.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionsBlockState.kt index d4c4dad238..6aa8c653c2 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionsBlockState.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionsBlockState.kt @@ -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, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/state/TxHistoryState.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/state/TxHistoryState.kt index a6035f48dc..c6a42aacbb 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/state/TxHistoryState.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/state/TxHistoryState.kt @@ -13,12 +13,8 @@ sealed interface TxHistoryState { */ data class Content(val contentItems: MutableStateFlow>) : 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 diff --git a/core/ui/src/main/res/drawable/ic_empty_token_64.xml b/core/ui/src/main/res/drawable/ic_empty_token_64.xml new file mode 100644 index 0000000000..51821ac760 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_empty_token_64.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadingTxHistoryConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadingTxHistoryConverter.kt index 2f82ffe2ce..599d55f418 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadingTxHistoryConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadingTxHistoryConverter.kt @@ -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) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt index 60f57fd065..22a3e6872f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt @@ -214,15 +214,9 @@ internal class WalletStateFactory( } } - fun getLoadingTxHistoryState( - itemsCountEither: Either, - cryptoCurrencyStatus: CryptoCurrencyStatus, - ): WalletState { + fun getLoadingTxHistoryState(itemsCountEither: Either): WalletState { return loadingTransactionsStateConverter.convert( - WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel( - historyLoadingState = itemsCountEither, - cryptoCurrencyStatus = cryptoCurrencyStatus, - ), + WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel(historyLoadingState = itemsCountEither), ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt index 09c79f69f3..65e92212f3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt @@ -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, - val cryptoCurrencyStatus: CryptoCurrencyStatus, - ) + data class WalletLoadingTxHistoryModel(val historyLoadingState: Either) } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt index b9b6ac5d58..86273d595e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt @@ -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) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 4565a8703d..d185f34bb4 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -711,7 +711,6 @@ internal class WalletViewModel @Inject constructor( uiState = stateFactory.getLoadingTxHistoryState( itemsCountEither = txHistoryItemsCountEither, - cryptoCurrencyStatus = singleWalletCryptoCurrencyStatus ?: return@launch, ) txHistoryItemsCountEither.onRight {