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 new file mode 100644 index 0000000000..4bb5a8f0b1 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt @@ -0,0 +1,92 @@ +package com.tangem.core.ui.components.transactions.empty + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign +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.buttons.actions.ActionButtonConfig +import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.R + +@Composable +fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: 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), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Image( + modifier = Modifier.size(TangemTheme.dimens.size64), + painter = painterResource(id = state.iconRes), + contentDescription = null, + ) + Text( + modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing32), + textAlign = TextAlign.Center, + text = state.text.resolveReference(), + style = TangemTheme.typography.body2, + color = TangemTheme.colors.text.secondary, + ) + ActionButton(config = state.actionButtonConfig) + } +} + +@Preview +@Composable +private fun EmptyTransactionBlock_Light( + @PreviewParameter(EmptyTransactionBlockStateProvider::class) state: EmptyTransactionsBlockState, +) { + TangemTheme { + EmptyTransactionBlock(state = state) + } +} + +@Preview +@Composable +private fun EmptyTransactionBlock_Dark( + @PreviewParameter(EmptyTransactionBlockStateProvider::class) state: EmptyTransactionsBlockState, +) { + TangemTheme(isDark = true) { + EmptyTransactionBlock(state = state) + } +} + +private class EmptyTransactionBlockStateProvider : CollectionPreviewParameterProvider( + collection = listOf( + EmptyTransactionsBlockState.Empty( + actionButtonConfig = ActionButtonConfig( + text = "Buy", + iconResId = R.drawable.ic_plus_24, + onClick = {}, + ), + ), + EmptyTransactionsBlockState.FailedToLoad( + actionButtonConfig = ActionButtonConfig( + text = "Reload", + iconResId = R.drawable.ic_refresh_24, + onClick = {}, + ), + ), + EmptyTransactionsBlockState.NotImplemented( + actionButtonConfig = ActionButtonConfig( + text = "Explore transaction history", + iconResId = R.drawable.ic_arrow_top_right_24, + onClick = {}, + ), + ), + ), +) \ No newline at end of file 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 new file mode 100644 index 0000000000..bb26676865 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionsBlockState.kt @@ -0,0 +1,37 @@ +package com.tangem.core.ui.components.transactions.empty + +import androidx.annotation.DrawableRes +import com.tangem.core.ui.R +import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig +import com.tangem.core.ui.extensions.TextReference + +sealed class EmptyTransactionsBlockState { + + @get:DrawableRes + abstract val iconRes: Int + + abstract val text: TextReference + + abstract val actionButtonConfig: ActionButtonConfig + + data class FailedToLoad( + override val actionButtonConfig: ActionButtonConfig, + ) : EmptyTransactionsBlockState() { + override val iconRes: Int = R.drawable.ic_alert_history_64 + override val text: TextReference = TextReference.Res(R.string.transaction_history_error_failed_to_load) + } + + data class Empty( + override val actionButtonConfig: ActionButtonConfig, + ) : EmptyTransactionsBlockState() { + override val iconRes: Int = R.drawable.img_coin_64 + override val text: TextReference = TextReference.Res(R.string.transaction_history_empty_transactions) + } + + data class NotImplemented( + override val actionButtonConfig: ActionButtonConfig, + ) : EmptyTransactionsBlockState() { + override val iconRes: Int = R.drawable.ic_compass_64 + override val text: TextReference = TextReference.Res(R.string.transaction_history_not_supported_description) + } +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt index 8e17a060f2..ddba0a20cd 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt @@ -63,6 +63,7 @@ data class TangemDimens internal constructor( val size52: Dp = 52.dp, val size56: Dp = 56.dp, val size62: Dp = 62.dp, + val size64: Dp = 64.dp, val size68: Dp = 68.dp, val size70: Dp = 70.dp, val size72: Dp = 72.dp, diff --git a/core/ui/src/main/res/drawable/ic_alert_history_64.xml b/core/ui/src/main/res/drawable/ic_alert_history_64.xml new file mode 100644 index 0000000000..51e0bb6e57 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_alert_history_64.xml @@ -0,0 +1,10 @@ + + + diff --git a/core/ui/src/main/res/drawable/ic_compass_64.xml b/core/ui/src/main/res/drawable/ic_compass_64.xml new file mode 100644 index 0000000000..0d10b40a2c --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_compass_64.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/core/ui/src/main/res/drawable/img_coin_64.xml b/core/ui/src/main/res/drawable/img_coin_64.xml new file mode 100644 index 0000000000..c036101c31 --- /dev/null +++ b/core/ui/src/main/res/drawable/img_coin_64.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + +