Updated on 2026-08-14
This commit is contained in:
commit
7f0e78f06c
10 changed files with 53 additions and 27 deletions
|
|
@ -45,11 +45,14 @@ fun LazyListScope.txHistoryItems(
|
|||
)
|
||||
}
|
||||
is TxHistoryState.Empty -> {
|
||||
nonContentItem(state = EmptyTransactionsBlockState.Empty, modifier = modifier)
|
||||
nonContentItem(state = EmptyTransactionsBlockState.Empty(state.onExploreClick), modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.Error -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.FailedToLoad(onClick = state.onReloadClick),
|
||||
state = EmptyTransactionsBlockState.FailedToLoad(
|
||||
onClick = state.onReloadClick,
|
||||
onExplore = state.onExploreClick,
|
||||
),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal fun TxHistoryListItem(
|
|||
TxHistoryGroupTitle(config = state, modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.TxHistoryItemState.Title -> {
|
||||
TxHistoryTitle(config = state, modifier = modifier)
|
||||
TxHistoryTitle(onExploreClick = state.onExploreClick, modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.TxHistoryItemState.Transaction -> {
|
||||
Transaction(
|
||||
|
|
|
|||
|
|
@ -11,17 +11,16 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
/**
|
||||
* Transactions block title
|
||||
*
|
||||
* @param config config
|
||||
* @param onExploreClick lambda be invoke when explore button was clicked
|
||||
* @param modifier modifier
|
||||
*/
|
||||
@Composable
|
||||
internal fun TxHistoryTitle(config: TxHistoryState.TxHistoryItemState.Title, modifier: Modifier = Modifier) {
|
||||
internal fun TxHistoryTitle(onExploreClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.primary)
|
||||
|
|
@ -37,7 +36,7 @@ internal fun TxHistoryTitle(config: TxHistoryState.TxHistoryItemState.Title, mod
|
|||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier.clickable(onClick = config.onExploreClick),
|
||||
modifier = Modifier.clickable(onClick = onExploreClick),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4),
|
||||
) {
|
||||
Icon(
|
||||
|
|
@ -59,7 +58,7 @@ internal fun TxHistoryTitle(config: TxHistoryState.TxHistoryItemState.Title, mod
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockTitle_Light() {
|
||||
TangemTheme(isDark = false) {
|
||||
TxHistoryTitle(config = TxHistoryState.TxHistoryItemState.Title(onExploreClick = {}))
|
||||
TxHistoryTitle(onExploreClick = {})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +66,6 @@ private fun Preview_TransactionsBlockTitle_Light() {
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockTitle_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
TxHistoryTitle(config = TxHistoryState.TxHistoryItemState.Title(onExploreClick = {}))
|
||||
TxHistoryTitle(onExploreClick = {})
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButton
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryTitle
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
|
|
@ -28,19 +29,23 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
Column(
|
||||
modifier = modifier
|
||||
.clip(TangemTheme.shapes.roundedCornersXMedium)
|
||||
.background(color = TangemTheme.colors.background.primary)
|
||||
.padding(vertical = TangemTheme.dimens.spacing24),
|
||||
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing24),
|
||||
.background(color = TangemTheme.colors.background.primary),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
if (state.onExploreClick != null) {
|
||||
TxHistoryTitle(onExploreClick = state.onExploreClick, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Image(
|
||||
modifier = Modifier.size(TangemTheme.dimens.size64),
|
||||
modifier = Modifier
|
||||
.padding(top = TangemTheme.dimens.spacing24)
|
||||
.size(TangemTheme.dimens.size64),
|
||||
painter = painterResource(id = state.iconRes),
|
||||
contentDescription = null,
|
||||
)
|
||||
|
||||
Text(
|
||||
modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing32),
|
||||
modifier = Modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing32, vertical = TangemTheme.dimens.spacing24),
|
||||
textAlign = TextAlign.Center,
|
||||
text = state.text.resolveReference(),
|
||||
style = TangemTheme.typography.body2,
|
||||
|
|
@ -48,7 +53,7 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
)
|
||||
|
||||
state.actionButtonConfig?.let {
|
||||
ActionButton(config = it)
|
||||
ActionButton(config = it, modifier = Modifier.padding(bottom = TangemTheme.dimens.spacing24))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,8 +80,8 @@ private fun EmptyTransactionBlock_Dark(
|
|||
|
||||
private class EmptyTransactionBlockStateProvider : CollectionPreviewParameterProvider<EmptyTransactionsBlockState>(
|
||||
collection = listOf(
|
||||
EmptyTransactionsBlockState.Empty,
|
||||
EmptyTransactionsBlockState.FailedToLoad(onClick = {}),
|
||||
EmptyTransactionsBlockState.Empty {},
|
||||
EmptyTransactionsBlockState.FailedToLoad(onClick = {}, onExplore = {}),
|
||||
EmptyTransactionsBlockState.NotImplemented(onClick = {}),
|
||||
),
|
||||
)
|
||||
|
|
@ -8,9 +8,13 @@ sealed class EmptyTransactionsBlockState(
|
|||
val actionButtonConfig: ActionButtonConfig? = null,
|
||||
val iconRes: Int,
|
||||
val text: TextReference,
|
||||
val onExploreClick: (() -> Unit)?,
|
||||
) {
|
||||
|
||||
data class FailedToLoad(val onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
data class FailedToLoad(
|
||||
val onClick: () -> Unit,
|
||||
val onExplore: () -> Unit,
|
||||
) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_reload),
|
||||
iconResId = R.drawable.ic_refresh_24,
|
||||
|
|
@ -19,11 +23,13 @@ sealed class EmptyTransactionsBlockState(
|
|||
),
|
||||
iconRes = R.drawable.ic_alert_history_64,
|
||||
text = TextReference.Res(R.string.transaction_history_error_failed_to_load),
|
||||
onExploreClick = onExplore,
|
||||
)
|
||||
|
||||
object Empty : EmptyTransactionsBlockState(
|
||||
data class Empty(val onExplore: (() -> Unit)) : EmptyTransactionsBlockState(
|
||||
iconRes = R.drawable.ic_empty_token_64,
|
||||
text = TextReference.Res(R.string.transaction_history_empty_transactions),
|
||||
onExploreClick = onExplore,
|
||||
)
|
||||
|
||||
data class NotImplemented(val onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
|
|
@ -35,5 +41,6 @@ sealed class EmptyTransactionsBlockState(
|
|||
),
|
||||
iconRes = R.drawable.ic_compass_64,
|
||||
text = TextReference.Res(R.string.transaction_history_not_supported_description),
|
||||
onExploreClick = null,
|
||||
)
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ sealed interface TxHistoryState {
|
|||
data class Content(val contentItems: MutableStateFlow<PagingData<TxHistoryItemState>>) : TxHistoryState
|
||||
|
||||
/** Empty state */
|
||||
object Empty : TxHistoryState
|
||||
data class Empty(val onExploreClick: () -> Unit) : TxHistoryState
|
||||
|
||||
/**
|
||||
* Not supported tx history state
|
||||
|
|
@ -33,7 +33,7 @@ sealed interface TxHistoryState {
|
|||
*
|
||||
* @property onReloadClick lambda be invoke when reload button was clicked
|
||||
*/
|
||||
data class Error(val onReloadClick: () -> Unit) : TxHistoryState
|
||||
data class Error(val onReloadClick: () -> Unit, val onExploreClick: () -> Unit) : TxHistoryState
|
||||
|
||||
/** Transactions history item state */
|
||||
sealed interface TxHistoryItemState {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ internal class TokenDetailsLoadedTxHistoryConverter(
|
|||
private fun convertError(error: TxHistoryListError): TxHistoryState {
|
||||
return when (error) {
|
||||
is TxHistoryListError.DataError -> {
|
||||
TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
TxHistoryState.Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,11 @@ internal class TokenDetailsLoadingTxHistoryConverter(
|
|||
): TokenDetailsState {
|
||||
return currentStateProvider().copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryStateError.EmptyTxHistories -> TxHistoryState.Empty
|
||||
is TxHistoryStateError.DataError -> TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
is TxHistoryStateError.EmptyTxHistories -> TxHistoryState.Empty(clickIntents::onExploreClick)
|
||||
is TxHistoryStateError.DataError -> TxHistoryState.Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
is TxHistoryStateError.TxHistoryNotImplemented -> {
|
||||
TxHistoryState.NotSupported(
|
||||
pendingTransactions = pendingTransactions.toImmutableList(),
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ internal class WalletLoadedTxHistoryConverter(
|
|||
state.copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryListError.DataError -> {
|
||||
TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
TxHistoryState.Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -52,8 +52,11 @@ internal class WalletLoadingTxHistoryConverter(
|
|||
return if (state is WalletSingleCurrencyState.Content) {
|
||||
state.copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryStateError.EmptyTxHistories -> Empty
|
||||
is TxHistoryStateError.DataError -> Error(onReloadClick = clickIntents::onReloadClick)
|
||||
is TxHistoryStateError.EmptyTxHistories -> Empty(onExploreClick = clickIntents::onExploreClick)
|
||||
is TxHistoryStateError.DataError -> Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
is TxHistoryStateError.TxHistoryNotImplemented -> {
|
||||
NotSupported(
|
||||
pendingTransactions = txHistoryItemConverter.convertList(pendingTransactions)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue