Updated on 2026-08-14
This commit is contained in:
parent
c775c12aad
commit
2806489bd8
4 changed files with 83 additions and 34 deletions
|
|
@ -86,6 +86,7 @@
|
|||
<string name="common_error">Error</string>
|
||||
<string name="common_exchange">Exchange</string>
|
||||
<string name="common_explore_transaction_history">Explore transaction history</string>
|
||||
<string name="common_explore">Explore</string>
|
||||
<string name="common_explorer">Explorer</string>
|
||||
<string name="common_fee_selector_title">Speed and fee</string>
|
||||
<string name="common_fee_selector_footer">Network transaction fees are used to support network security, incentivize validators, allocate resources, and determine transaction priority</string>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ fun LazyListScope.txHistoryItems(
|
|||
is TxHistoryState.Error -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.FailedToLoad(
|
||||
onClick = state.onReloadClick,
|
||||
onReload = state.onReloadClick,
|
||||
onExplore = state.onExploreClick,
|
||||
),
|
||||
modifier = modifier,
|
||||
|
|
@ -64,7 +64,7 @@ fun LazyListScope.txHistoryItems(
|
|||
}
|
||||
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.NotImplemented(onClick = state.onExploreClick),
|
||||
state = EmptyTransactionsBlockState.NotImplemented(onExplore = state.onExploreClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ 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
|
||||
|
||||
|
|
@ -29,33 +28,60 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
Column(
|
||||
modifier = modifier
|
||||
.clip(TangemTheme.shapes.roundedCornersXMedium)
|
||||
.background(color = TangemTheme.colors.background.primary),
|
||||
.background(color = TangemTheme.colors.background.primary)
|
||||
.padding(vertical = TangemTheme.dimens.spacing24),
|
||||
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing24),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
if (state.onExploreClick != null) {
|
||||
TxHistoryTitle(onExploreClick = state.onExploreClick, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Image(
|
||||
modifier = Modifier
|
||||
.padding(top = TangemTheme.dimens.spacing24)
|
||||
.size(TangemTheme.dimens.size64),
|
||||
modifier = Modifier.size(TangemTheme.dimens.size64),
|
||||
painter = painterResource(id = state.iconRes),
|
||||
contentDescription = null,
|
||||
)
|
||||
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing32, vertical = TangemTheme.dimens.spacing24),
|
||||
modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing32),
|
||||
textAlign = TextAlign.Center,
|
||||
text = state.text.resolveReference(),
|
||||
style = TangemTheme.typography.body2,
|
||||
color = TangemTheme.colors.text.secondary,
|
||||
)
|
||||
|
||||
state.actionButtonConfig?.let {
|
||||
ActionButton(config = it, modifier = Modifier.padding(bottom = TangemTheme.dimens.spacing24))
|
||||
Buttons(
|
||||
modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing18),
|
||||
state = state.buttonsState,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Buttons(state: EmptyTransactionsBlockState.ButtonsState, modifier: Modifier = Modifier) {
|
||||
when (state) {
|
||||
is EmptyTransactionsBlockState.ButtonsState.SingleButton -> SingleButton(state = state, modifier = modifier)
|
||||
is EmptyTransactionsBlockState.ButtonsState.PairButtons -> PairButtons(state = state, modifier = modifier)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SingleButton(state: EmptyTransactionsBlockState.ButtonsState.SingleButton, modifier: Modifier = Modifier) {
|
||||
ActionButton(modifier = modifier, config = state.actionButtonConfig)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PairButtons(state: EmptyTransactionsBlockState.ButtonsState.PairButtons, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8),
|
||||
) {
|
||||
ActionButton(
|
||||
modifier = Modifier.weight(1F),
|
||||
config = state.firstButtonConfig,
|
||||
)
|
||||
ActionButton(
|
||||
modifier = Modifier.weight(1F),
|
||||
config = state.secondButtonConfig,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
|
@ -81,7 +107,7 @@ private fun EmptyTransactionBlock_Dark(
|
|||
private class EmptyTransactionBlockStateProvider : CollectionPreviewParameterProvider<EmptyTransactionsBlockState>(
|
||||
collection = listOf(
|
||||
EmptyTransactionsBlockState.Empty {},
|
||||
EmptyTransactionsBlockState.FailedToLoad(onClick = {}, onExplore = {}),
|
||||
EmptyTransactionsBlockState.NotImplemented(onClick = {}),
|
||||
EmptyTransactionsBlockState.FailedToLoad(onReload = {}, onExplore = {}),
|
||||
EmptyTransactionsBlockState.NotImplemented(onExplore = {}),
|
||||
),
|
||||
)
|
||||
|
|
@ -5,42 +5,64 @@ import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
|||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
sealed class EmptyTransactionsBlockState(
|
||||
val actionButtonConfig: ActionButtonConfig? = null,
|
||||
val buttonsState: ButtonsState,
|
||||
val iconRes: Int,
|
||||
val text: TextReference,
|
||||
val onExploreClick: (() -> Unit)?,
|
||||
) {
|
||||
|
||||
sealed class ButtonsState {
|
||||
data class SingleButton(val actionButtonConfig: ActionButtonConfig) : ButtonsState()
|
||||
data class PairButtons(
|
||||
val firstButtonConfig: ActionButtonConfig,
|
||||
val secondButtonConfig: ActionButtonConfig,
|
||||
) : ButtonsState()
|
||||
}
|
||||
|
||||
data class FailedToLoad(
|
||||
val onClick: () -> Unit,
|
||||
val onReload: () -> Unit,
|
||||
val onExplore: () -> Unit,
|
||||
) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
buttonsState = ButtonsState.PairButtons(
|
||||
firstButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_reload),
|
||||
iconResId = R.drawable.ic_refresh_24,
|
||||
onClick = onClick,
|
||||
onClick = onReload,
|
||||
enabled = true,
|
||||
),
|
||||
secondButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_explore),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = onExplore,
|
||||
enabled = true,
|
||||
),
|
||||
),
|
||||
iconRes = R.drawable.ic_alert_history_64,
|
||||
text = TextReference.Res(R.string.transaction_history_error_failed_to_load),
|
||||
onExploreClick = onExplore,
|
||||
)
|
||||
|
||||
data class Empty(val onExplore: (() -> Unit)) : EmptyTransactionsBlockState(
|
||||
buttonsState = ButtonsState.SingleButton(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_explore),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = onExplore,
|
||||
enabled = true,
|
||||
),
|
||||
),
|
||||
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(
|
||||
data class NotImplemented(val onExplore: () -> Unit) : EmptyTransactionsBlockState(
|
||||
buttonsState = ButtonsState.SingleButton(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_explore_transaction_history),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = onClick,
|
||||
onClick = onExplore,
|
||||
enabled = true,
|
||||
),
|
||||
),
|
||||
iconRes = R.drawable.ic_compass_64,
|
||||
text = TextReference.Res(R.string.transaction_history_not_supported_description),
|
||||
onExploreClick = null,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue