Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-13 13:51:55 +03:00
parent 3f3a114dad
commit 355acaea56
14 changed files with 80 additions and 35 deletions

View file

@ -2,7 +2,10 @@ package com.tangem.feature.wallet.presentation.wallet.state.components
import androidx.compose.runtime.Immutable
import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.pluralReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.feature.wallet.impl.R
/**
@ -88,11 +91,6 @@ sealed class WalletNotification(val config: NotificationConfig) {
subtitle = resourceReference(id = R.string.warning_some_networks_unreachable_message),
)
data class TopUpNote(val errorMessage: String) : Warning(
title = resourceReference(id = R.string.warning_title_note_top_up),
subtitle = stringReference(value = errorMessage),
)
data class NumberOfSignedHashesIncorrect(val onCloseClick: () -> Unit) : Warning(
title = resourceReference(id = R.string.common_warning),
subtitle = resourceReference(id = R.string.alert_card_signed_transactions),
@ -117,6 +115,17 @@ sealed class WalletNotification(val config: NotificationConfig) {
),
)
data class NoAccount(val network: String, val symbol: String, val amount: String) : WalletNotification(
config = NotificationConfig(
title = resourceReference(id = R.string.warning_no_account_title),
subtitle = resourceReference(
id = R.string.no_account_generic,
wrappedList(network, amount, symbol),
),
iconResId = R.drawable.ic_alert_circle_24,
),
)
data class UnlockWallets(val onClick: () -> Unit) : WalletNotification(
config = NotificationConfig(
title = resourceReference(id = R.string.common_unlock_needed),

View file

@ -32,6 +32,7 @@ internal fun LazyListScope.notifications(configs: ImmutableList<WalletNotificati
is WalletNotification.MissingAddresses -> TangemTheme.colors.icon.accent
is WalletNotification.RateApp -> TangemTheme.colors.icon.attention
is WalletNotification.UnlockWallets -> TangemTheme.colors.icon.primary1
is WalletNotification.NoAccount -> TangemTheme.colors.icon.accent
is WalletNotification.Warning -> null
},
)

View file

@ -143,10 +143,7 @@ internal class WalletNotificationsListFactory(
condition = cryptoCurrencyList.hasUnreachableNetworks(),
)
val errorMessage = cryptoCurrencyList.geNoAccountStatusMessage()
if (errorMessage != null) {
add(element = WalletNotification.Warning.TopUpNote(errorMessage = errorMessage))
}
addNoAccountWarning(cryptoCurrencyList)
addIf(
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect(
@ -169,12 +166,19 @@ internal class WalletNotificationsListFactory(
return any { it.value is CryptoCurrencyStatus.Unreachable }
}
private fun List<CryptoCurrencyStatus>.geNoAccountStatusMessage(): String? {
return this
.map(CryptoCurrencyStatus::value)
.filterIsInstance<CryptoCurrencyStatus.NoAccount>()
.firstOrNull()
?.errorMessage
private fun MutableList<WalletNotification>.addNoAccountWarning(cryptoCurrencyList: List<CryptoCurrencyStatus>) {
val noAccountNetwork = cryptoCurrencyList.firstOrNull { it.value is CryptoCurrencyStatus.NoAccount }
if (noAccountNetwork != null) {
val amountToCreateAccount = (noAccountNetwork.value as? CryptoCurrencyStatus.NoAccount)
?.amountToCreateAccount.toString()
add(
element = WalletNotification.NoAccount(
network = noAccountNetwork.currency.name,
amount = amountToCreateAccount,
symbol = noAccountNetwork.currency.symbol,
),
)
}
}
/**