Updated on 2026-08-14
This commit is contained in:
commit
0598dd8e16
19 changed files with 177 additions and 68 deletions
|
|
@ -2,6 +2,8 @@ package com.tangem.feature.wallet.presentation.common.preview
|
|||
|
||||
import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig
|
||||
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
|
||||
import com.tangem.core.ui.ds.button.TangemButtonShape
|
||||
import com.tangem.core.ui.ds.button.TangemButtonSize
|
||||
import com.tangem.core.ui.ds.button.TangemButtonType
|
||||
import com.tangem.core.ui.ds.button.TangemButtonUM
|
||||
import com.tangem.core.ui.ds.image.TangemIconUM
|
||||
|
|
@ -50,14 +52,19 @@ internal object WalletScreenPreviewData {
|
|||
text = resourceReference(R.string.organize_tokens_title),
|
||||
type = TangemButtonType.Secondary,
|
||||
onClick = {},
|
||||
iconRes = R.drawable.ic_filter_default_24,
|
||||
size = TangemButtonSize.X9,
|
||||
shape = TangemButtonShape.Rounded,
|
||||
),
|
||||
)
|
||||
|
||||
private val walletLocked = WalletUM.Locked(
|
||||
walletsBalanceUM = WalletBalancePreview.content,
|
||||
buttons = WalletPreviewData.actionButtons,
|
||||
walletsBalanceUM = WalletBalancePreview.empty,
|
||||
buttons = WalletPreviewData.disabledActionButtons,
|
||||
type = WalletType.Cold,
|
||||
notifications = persistentListOf(),
|
||||
notifications = persistentListOf(
|
||||
WalletNotificationUM.UnlockWallets({}),
|
||||
),
|
||||
)
|
||||
|
||||
private val walletDefault = WalletUM.Content(
|
||||
|
|
@ -82,13 +89,29 @@ internal object WalletScreenPreviewData {
|
|||
tangemPayState = TangemPayState.Loading,
|
||||
)
|
||||
|
||||
internal val defaultState = WalletScreenState(
|
||||
private val walletEmpty = WalletUM.Content(
|
||||
walletsBalanceUM = WalletBalancePreview.empty,
|
||||
buttons = WalletPreviewData.disabledActionButtons,
|
||||
type = WalletType.Cold,
|
||||
pullToRefreshConfig = PullToRefreshConfig(
|
||||
isRefreshing = false,
|
||||
onRefresh = {},
|
||||
),
|
||||
notifications = persistentListOf(),
|
||||
notificationsCarousel = persistentListOf(),
|
||||
tokensListUM = WalletTokensListUM.Empty,
|
||||
nftState = WalletNFTItemUM.Hidden,
|
||||
tangemPayState = TangemPayState.Empty,
|
||||
)
|
||||
|
||||
val defaultState = WalletScreenState(
|
||||
topBarConfig = topBarConfig,
|
||||
selectedWalletIndex = 0,
|
||||
wallets = persistentListOf(),
|
||||
wallets2 = persistentListOf(
|
||||
walletLocked,
|
||||
walletDefault,
|
||||
walletEmpty,
|
||||
walletLocked,
|
||||
),
|
||||
onWalletChange = { _, _ -> },
|
||||
event = consumedEvent(),
|
||||
|
|
@ -96,4 +119,12 @@ internal object WalletScreenPreviewData {
|
|||
showMarketsOnboarding = false,
|
||||
onDismissMarketsTooltip = {},
|
||||
)
|
||||
|
||||
val emptyState = defaultState.copy(
|
||||
selectedWalletIndex = 1,
|
||||
)
|
||||
|
||||
val lockedState = defaultState.copy(
|
||||
selectedWalletIndex = 2,
|
||||
)
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.feature.wallet.presentation.preview
|
|||
import androidx.compose.ui.text.SpanStyle
|
||||
import com.tangem.core.ui.ds.image.DeviceIconUM
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.orMaskWithStars
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.styledStringReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
|
@ -37,6 +38,8 @@ internal object WalletBalancePreview {
|
|||
isZeroBalance = false,
|
||||
)
|
||||
|
||||
val hiddenBalanceContent = content.copy(balance = content.balance.orMaskWithStars(true))
|
||||
|
||||
val loading: WalletBalanceUM.Loading = WalletBalanceUM.Loading(
|
||||
id = UserWalletId("1"),
|
||||
name = "My Wallet",
|
||||
|
|
@ -48,4 +51,10 @@ internal object WalletBalancePreview {
|
|||
name = "My Wallet",
|
||||
deviceIcon = DeviceIconUM.Stub(cardsCount = 3),
|
||||
)
|
||||
|
||||
val empty: WalletBalanceUM.Empty = WalletBalanceUM.Empty(
|
||||
id = UserWalletId("2"),
|
||||
name = "My Wallet",
|
||||
deviceIcon = DeviceIconUM.Stub(cardsCount = 3),
|
||||
)
|
||||
}
|
||||
|
|
@ -15,6 +15,12 @@ internal object WalletPreviewData {
|
|||
}
|
||||
|
||||
val actionButtons = persistentListOf(
|
||||
WalletActionButtons.Buy({}, true).buttonUM,
|
||||
WalletActionButtons.Swap({}, true).buttonUM,
|
||||
WalletActionButtons.Sell({}, true).buttonUM,
|
||||
)
|
||||
|
||||
val disabledActionButtons = persistentListOf(
|
||||
WalletActionButtons.Buy({}, false).buttonUM,
|
||||
WalletActionButtons.Swap({}, false).buttonUM,
|
||||
WalletActionButtons.Sell({}, false).buttonUM,
|
||||
|
|
|
|||
|
|
@ -69,11 +69,24 @@ internal sealed interface WalletBalanceUM {
|
|||
override val deviceIcon: DeviceIconUM,
|
||||
) : WalletBalanceUM
|
||||
|
||||
/**
|
||||
* Wallet card loading state
|
||||
*
|
||||
* @property id wallet id
|
||||
* @property name wallet name
|
||||
*/
|
||||
data class Empty(
|
||||
override val id: UserWalletId,
|
||||
override val name: String,
|
||||
override val deviceIcon: DeviceIconUM,
|
||||
) : WalletBalanceUM
|
||||
|
||||
fun copySealed(name: String): WalletBalanceUM {
|
||||
return when (this) {
|
||||
is Content -> copy(name = name)
|
||||
is Error -> copy(name = name)
|
||||
is Loading -> copy(name = name)
|
||||
is Empty -> copy(name = name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +343,13 @@ internal sealed class WalletNotificationUM(val messageUM: TangemMessageUM, val t
|
|||
resourceReference(R.string.common_biometrics),
|
||||
),
|
||||
),
|
||||
onClick = onClick,
|
||||
buttonsUM = persistentListOf(
|
||||
TangemMessageButtonUM(
|
||||
text = resourceReference(R.string.common_unlock),
|
||||
onClick = onClick,
|
||||
type = TangemButtonType.Primary,
|
||||
),
|
||||
),
|
||||
messageEffect = TangemMessageEffect.Card,
|
||||
isCentered = true,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,24 @@ internal sealed class WalletTokensListUM {
|
|||
override val organizeButtonUM: TangemButtonUM? = null
|
||||
}
|
||||
|
||||
data object Locked : WalletTokensListUM() {
|
||||
override val tokenList: ImmutableList<TokensListItemUM2.Portfolio> = persistentListOf(
|
||||
TokensListItemUM2.Portfolio(
|
||||
tokenRowUM = TangemTokenRowUM.Empty(id = "0"),
|
||||
tokenList = persistentListOf(),
|
||||
isExpanded = false,
|
||||
isCollapsable = true,
|
||||
),
|
||||
TokensListItemUM2.Portfolio(
|
||||
tokenRowUM = TangemTokenRowUM.Empty(id = "1"),
|
||||
tokenList = persistentListOf(),
|
||||
isExpanded = false,
|
||||
isCollapsable = true,
|
||||
),
|
||||
)
|
||||
override val organizeButtonUM: TangemButtonUM? = null
|
||||
}
|
||||
|
||||
data object Loading : WalletTokensListUM() {
|
||||
override val tokenList: ImmutableList<TokensListItemUM2> = persistentListOf(
|
||||
TokensListItemUM2.Portfolio(
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ internal sealed interface WalletUM {
|
|||
) : WalletUM {
|
||||
override val notificationsCarousel: ImmutableList<WalletNotificationUM> = persistentListOf()
|
||||
override val pullToRefreshConfig = PullToRefreshConfig(false, {})
|
||||
override val tokensListUM: WalletTokensListUM = WalletTokensListUM.Empty // todo redesign main locked state
|
||||
override val tokensListUM: WalletTokensListUM = WalletTokensListUM.Locked
|
||||
override val nftState: WalletNFTItemUM = WalletNFTItemUM.Hidden
|
||||
override val tangemPayState: TangemPayState = TangemPayState.Empty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.R as CoreUiR
|
||||
import com.tangem.common.ui.userwallet.converter.WalletIconUMConverter
|
||||
import com.tangem.core.ui.ds.button.TangemButtonUM
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBarActionUM
|
||||
|
|
@ -20,6 +19,7 @@ import kotlinx.collections.immutable.PersistentList
|
|||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import com.tangem.core.ui.R as CoreUiR
|
||||
|
||||
internal class InitializeWalletsTransformer(
|
||||
private val selectedWalletIndex: Int,
|
||||
|
|
@ -128,7 +128,7 @@ internal class InitializeWalletsTransformer(
|
|||
|
||||
private fun UserWallet.toLockedWalletUM(): WalletUM.Locked {
|
||||
return WalletUM.Locked(
|
||||
walletsBalanceUM = WalletBalanceUM.Loading(
|
||||
walletsBalanceUM = WalletBalanceUM.Empty(
|
||||
id = walletId,
|
||||
name = name,
|
||||
deviceIcon = getWalletIconUseCase.invoke(userWallet = this)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ internal class WalletTokensListUMConverter(
|
|||
|
||||
override fun convert(value: AccountStatusList): WalletTokensListUM {
|
||||
val promoCryptoCurrency = yieldSupplyPromoBannerConverter.convert2(value = value)
|
||||
return if (value.accountStatuses.isEmpty()) {
|
||||
return if (value.flattenCurrencies().isEmpty()) {
|
||||
WalletTokensListUM.Empty
|
||||
} else {
|
||||
val isCollapsable = value.accountStatuses.count {
|
||||
|
|
@ -163,7 +163,7 @@ internal class WalletTokensListUMConverter(
|
|||
return if (accountList.flattenCurrencies().size > 1 && !selectedWallet.isSingleWalletWithToken()) {
|
||||
TangemButtonUM(
|
||||
text = resourceReference(R.string.organize_tokens_title),
|
||||
isEnabled = accountList.totalFiatBalance !is TotalFiatBalance.Loading,
|
||||
isEnabled = accountList.totalFiatBalance is TotalFiatBalance.Loading,
|
||||
size = TangemButtonSize.X9,
|
||||
shape = TangemButtonShape.Rounded,
|
||||
type = TangemButtonType.PrimaryInverse,
|
||||
|
|
|
|||
|
|
@ -578,7 +578,8 @@ private class WalletScreen2PreviewProvider : PreviewParameterProvider<WalletScre
|
|||
override val values: Sequence<WalletScreenState>
|
||||
get() = sequenceOf(
|
||||
WalletScreenPreviewData.defaultState,
|
||||
WalletScreenPreviewData.defaultState.copy(selectedWalletIndex = 1),
|
||||
WalletScreenPreviewData.emptyState,
|
||||
WalletScreenPreviewData.lockedState,
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
|
|
@ -29,6 +29,7 @@ import com.tangem.core.ui.ds.button.SecondaryTangemButton
|
|||
import com.tangem.core.ui.ds.button.TangemButtonShape
|
||||
import com.tangem.core.ui.ds.button.TangemButtonUM
|
||||
import com.tangem.core.ui.ds.image.TangemDeviceIcon
|
||||
import com.tangem.core.ui.ds.placeholder.TextPlaceholder
|
||||
import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingAppBarBehavior
|
||||
import com.tangem.core.ui.ds.topbar.collapsing.rememberTangemExitUntilCollapsedScrollBehavior
|
||||
import com.tangem.core.ui.ds.topbar.collapsing.snapToExitUntilCollapsed
|
||||
|
|
@ -113,43 +114,40 @@ private fun Balance(walletBalanceUM: WalletBalanceUM, isBalanceHidden: Boolean,
|
|||
},
|
||||
) { balanceUM ->
|
||||
when (balanceUM) {
|
||||
is WalletBalanceUM.Content -> {
|
||||
Text(
|
||||
text = balanceUM.balance.orMaskWithStars(isBalanceHidden).resolveAnnotatedReference(),
|
||||
style = TangemTheme.typography2.titleRegular44.applyBladeBrush(
|
||||
isEnabled = balanceUM.isBalanceFlickering,
|
||||
textColor = TangemTheme.colors2.text.neutral.primary,
|
||||
),
|
||||
color = TangemTheme.colors2.text.neutral.primary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
autoSize = TextAutoSize.StepBased(
|
||||
minFontSize = TangemTheme.typography2.bodySemibold15.fontSize,
|
||||
maxFontSize = TangemTheme.typography2.titleRegular44.fontSize,
|
||||
),
|
||||
)
|
||||
}
|
||||
is WalletBalanceUM.Error -> {
|
||||
Text(
|
||||
text = StringsSigns.DASH_SIGN,
|
||||
style = TangemTheme.typography2.titleRegular44,
|
||||
color = TangemTheme.colors2.text.neutral.primary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
autoSize = TextAutoSize.StepBased(
|
||||
minFontSize = TangemTheme.typography2.bodySemibold15.fontSize,
|
||||
maxFontSize = TangemTheme.typography2.titleRegular44.fontSize,
|
||||
),
|
||||
)
|
||||
}
|
||||
is WalletBalanceUM.Loading,
|
||||
-> {
|
||||
TextShimmer(
|
||||
text = "123456",
|
||||
style = TangemTheme.typography2.titleRegular44,
|
||||
radius = TangemTheme.dimens2.x25,
|
||||
)
|
||||
}
|
||||
is WalletBalanceUM.Content -> Text(
|
||||
text = balanceUM.balance.orMaskWithStars(isBalanceHidden).resolveAnnotatedReference(),
|
||||
style = TangemTheme.typography2.titleRegular44.applyBladeBrush(
|
||||
isEnabled = balanceUM.isBalanceFlickering,
|
||||
textColor = TangemTheme.colors2.text.neutral.primary,
|
||||
),
|
||||
color = TangemTheme.colors2.text.neutral.primary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
autoSize = TextAutoSize.StepBased(
|
||||
minFontSize = TangemTheme.typography2.bodySemibold15.fontSize,
|
||||
maxFontSize = TangemTheme.typography2.titleRegular44.fontSize,
|
||||
),
|
||||
)
|
||||
is WalletBalanceUM.Error -> Text(
|
||||
text = StringsSigns.DASH_SIGN,
|
||||
style = TangemTheme.typography2.titleRegular44,
|
||||
color = TangemTheme.colors2.text.neutral.primary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
autoSize = TextAutoSize.StepBased(
|
||||
minFontSize = TangemTheme.typography2.bodySemibold15.fontSize,
|
||||
maxFontSize = TangemTheme.typography2.titleRegular44.fontSize,
|
||||
),
|
||||
)
|
||||
is WalletBalanceUM.Loading -> TextShimmer(
|
||||
text = "123456",
|
||||
style = TangemTheme.typography2.titleRegular44,
|
||||
radius = TangemTheme.dimens2.x25,
|
||||
)
|
||||
is WalletBalanceUM.Empty -> TextPlaceholder(
|
||||
textStyle = TangemTheme.typography2.titleRegular44,
|
||||
width = 200.dp,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,6 +160,11 @@ private fun ActionButtons(buttons: ImmutableList<TangemButtonUM>) {
|
|||
) {
|
||||
buttons.fastForEach { button ->
|
||||
key(button.text) {
|
||||
val textColor = if (button.isEnabled) {
|
||||
TangemTheme.colors2.text.neutral.primary
|
||||
} else {
|
||||
TangemTheme.colors2.text.status.disabled
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x2_5),
|
||||
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens2.x2),
|
||||
|
|
@ -170,12 +173,13 @@ private fun ActionButtons(buttons: ImmutableList<TangemButtonUM>) {
|
|||
SecondaryTangemButton(
|
||||
iconRes = button.iconRes,
|
||||
onClick = button.onClick,
|
||||
isEnabled = button.isEnabled,
|
||||
shape = TangemButtonShape.Rounded,
|
||||
)
|
||||
Text(
|
||||
text = button.text.orEmpty().resolveReference(),
|
||||
style = TangemTheme.typography2.bodySemibold15,
|
||||
color = TangemTheme.colors2.text.neutral.primary,
|
||||
color = textColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -187,25 +191,34 @@ private fun ActionButtons(buttons: ImmutableList<TangemButtonUM>) {
|
|||
@Composable
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun WalletBalance_Preview(@PreviewParameter(WalletBalancePreviewProvider::class) params: WalletBalanceUM) {
|
||||
private fun WalletBalance_Preview(
|
||||
@PreviewParameter(WalletBalancePreviewProvider::class)
|
||||
params: WalletBalancePreviewData,
|
||||
) {
|
||||
TangemThemePreviewRedesign {
|
||||
WalletBalance(
|
||||
walletBalanceUM = params,
|
||||
walletBalanceUM = params.walletBalanceUM,
|
||||
behavior = rememberTangemExitUntilCollapsedScrollBehavior(),
|
||||
buttons = WalletPreviewData.actionButtons,
|
||||
buttons = params.actionsList,
|
||||
isBalanceHidden = false,
|
||||
modifier = Modifier.background(TangemTheme.colors2.surface.level1),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class WalletBalancePreviewProvider : PreviewParameterProvider<WalletBalanceUM> {
|
||||
override val values: Sequence<WalletBalanceUM>
|
||||
private data class WalletBalancePreviewData(
|
||||
val walletBalanceUM: WalletBalanceUM,
|
||||
val actionsList: ImmutableList<TangemButtonUM>,
|
||||
)
|
||||
|
||||
private class WalletBalancePreviewProvider : PreviewParameterProvider<WalletBalancePreviewData> {
|
||||
override val values: Sequence<WalletBalancePreviewData>
|
||||
get() = sequenceOf(
|
||||
WalletBalancePreview.content,
|
||||
WalletBalancePreview.content.copy(isBalanceFlickering = true),
|
||||
WalletBalancePreview.loading,
|
||||
WalletBalancePreview.error,
|
||||
WalletBalancePreviewData(WalletBalancePreview.content, WalletPreviewData.actionButtons),
|
||||
WalletBalancePreviewData(WalletBalancePreview.hiddenBalanceContent, WalletPreviewData.actionButtons),
|
||||
WalletBalancePreviewData(WalletBalancePreview.loading, WalletPreviewData.disabledActionButtons),
|
||||
WalletBalancePreviewData(WalletBalancePreview.error, WalletPreviewData.disabledActionButtons),
|
||||
WalletBalancePreviewData(WalletBalancePreview.empty, WalletPreviewData.disabledActionButtons),
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
|
|
@ -98,6 +98,7 @@ internal fun LazyListScope.tokensListItems2(
|
|||
when (walletTokensListUM) {
|
||||
is WalletTokensListUM.Loading,
|
||||
is WalletTokensListUM.Content,
|
||||
WalletTokensListUM.Locked,
|
||||
-> {
|
||||
walletTokensListUM.tokenList.fastForEachIndexed { index, listItem ->
|
||||
when (listItem) {
|
||||
|
|
@ -337,11 +338,15 @@ internal fun PortfolioRowItem(
|
|||
|
||||
TangemIcon(
|
||||
tangemIconUM = sizedHeadIcon,
|
||||
modifier = modifier.sharedBounds(
|
||||
sharedContentState = iconSharedContentState,
|
||||
animatedVisibilityScope = animatedContentScope,
|
||||
boundsTransform = boundsTransform,
|
||||
),
|
||||
modifier = modifier
|
||||
.conditionalCompose(headIcon is TangemIconUM.Empty) {
|
||||
size(TangemTheme.dimens2.x9)
|
||||
}
|
||||
.sharedBounds(
|
||||
sharedContentState = iconSharedContentState,
|
||||
animatedVisibilityScope = animatedContentScope,
|
||||
boundsTransform = boundsTransform,
|
||||
),
|
||||
)
|
||||
},
|
||||
title = { modifier ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue