Updated on 2026-08-14
This commit is contained in:
parent
2317703e37
commit
f2ab3a948d
6 changed files with 225 additions and 0 deletions
|
|
@ -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<EmptyTransactionsBlockState>(
|
||||
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 = {},
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
10
core/ui/src/main/res/drawable/ic_alert_history_64.xml
Normal file
10
core/ui/src/main/res/drawable/ic_alert_history_64.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="64"
|
||||
android:viewportHeight="64">
|
||||
<path
|
||||
android:pathData="M13.599,10.389V34.249C13.858,34.215 14.108,34.197 14.35,34.197C14.608,34.18 14.867,34.171 15.126,34.171C15.402,34.171 15.669,34.18 15.928,34.197C16.187,34.215 16.472,34.232 16.782,34.249V10.466C16.782,9.034 17.162,7.922 17.921,7.128C18.68,6.334 19.81,5.938 21.311,5.938H33.448V21.542C33.448,23.009 33.811,24.104 34.535,24.829C35.26,25.537 36.347,25.89 37.796,25.89H53.194V50.242C53.194,51.691 52.814,52.796 52.055,53.555C51.296,54.331 50.166,54.719 48.665,54.719H30.239C30.084,55.289 29.894,55.841 29.67,56.375C29.463,56.91 29.213,57.419 28.919,57.902H48.82C51.322,57.902 53.202,57.264 54.462,55.987C55.739,54.711 56.377,52.813 56.377,50.294V26.02C56.377,25.071 56.325,24.277 56.222,23.639C56.118,23 55.911,22.422 55.601,21.905C55.307,21.37 54.867,20.809 54.281,20.223L39.09,4.851C38.538,4.281 37.994,3.85 37.459,3.557C36.942,3.263 36.373,3.056 35.751,2.936C35.13,2.815 34.406,2.754 33.578,2.754H21.156C18.654,2.754 16.765,3.401 15.488,4.695C14.229,5.972 13.599,7.87 13.599,10.389ZM36.838,22.5C36.58,22.241 36.45,21.81 36.45,21.206V6.584L52.547,22.862H38.106C37.52,22.862 37.097,22.742 36.838,22.5ZM10.393,61.714C11.946,62.387 13.602,62.724 15.362,62.724C17.104,62.724 18.752,62.387 20.305,61.714C21.857,61.042 23.229,60.11 24.419,58.919C25.61,57.746 26.542,56.383 27.214,54.831C27.887,53.278 28.224,51.622 28.224,49.862C28.224,48.085 27.887,46.42 27.214,44.867C26.559,43.314 25.636,41.951 24.445,40.778C23.272,39.588 21.909,38.665 20.356,38.009C18.804,37.336 17.139,37 15.362,37C13.602,37 11.946,37.336 10.393,38.009C8.84,38.665 7.469,39.588 6.278,40.778C5.105,41.969 4.182,43.34 3.509,44.893C2.836,46.446 2.5,48.102 2.5,49.862C2.5,51.622 2.836,53.286 3.509,54.856C4.182,56.409 5.105,57.772 6.278,58.945C7.469,60.136 8.84,61.059 10.393,61.714ZM16.759,57.418C16.362,57.815 15.888,58.014 15.336,58.014C14.784,58.014 14.309,57.815 13.913,57.418C13.516,57.022 13.317,56.547 13.317,55.995C13.317,55.426 13.516,54.943 13.913,54.546C14.327,54.149 14.801,53.951 15.336,53.951C15.905,53.951 16.388,54.158 16.785,54.572C17.182,54.969 17.38,55.443 17.38,55.995C17.38,56.547 17.173,57.022 16.759,57.418ZM16.319,51.751C16.078,52.01 15.759,52.139 15.362,52.139C14.948,52.139 14.611,52.01 14.352,51.751C14.111,51.492 13.982,51.173 13.964,50.793L13.809,43.107C13.792,42.642 13.921,42.262 14.197,41.969C14.491,41.675 14.879,41.529 15.362,41.529C15.828,41.529 16.207,41.675 16.5,41.969C16.794,42.262 16.932,42.642 16.915,43.107L16.733,50.793C16.716,51.173 16.578,51.492 16.319,51.751Z"
|
||||
android:fillColor="#909090"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
28
core/ui/src/main/res/drawable/ic_compass_64.xml
Normal file
28
core/ui/src/main/res/drawable/ic_compass_64.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="64"
|
||||
android:viewportHeight="64">
|
||||
<path
|
||||
android:pathData="M32,3.84C24.531,3.84 17.369,6.807 12.088,12.088C6.807,17.369 3.84,24.531 3.84,32C3.84,39.468 6.807,46.631 12.088,51.912C17.369,57.193 24.531,60.16 32,60.16C39.468,60.16 46.631,57.193 51.912,51.912C57.193,46.631 60.16,39.468 60.16,32C60.16,24.531 57.193,17.369 51.912,12.088C46.631,6.807 39.468,3.84 32,3.84V3.84Z"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#909090"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M16.64,47.36L29.025,29.025L47.36,16.64L34.976,34.975L16.64,47.36Z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#909090"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M29.025,29.025L47.36,16.64L34.976,34.975L29.025,29.025Z"
|
||||
android:fillColor="#909090"/>
|
||||
<path
|
||||
android:pathData="M32,3.84V6.4M32,57.6V60.16M60.16,32H57.6M6.4,32H3.84"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#909090"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
57
core/ui/src/main/res/drawable/img_coin_64.xml
Normal file
57
core/ui/src/main/res/drawable/img_coin_64.xml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue