Updated on 2026-08-14
This commit is contained in:
parent
4ed210cd90
commit
1d0028f8b9
7 changed files with 133 additions and 110 deletions
|
|
@ -382,7 +382,7 @@ internal object WalletPreviewData {
|
|||
),
|
||||
notifications = persistentListOf(
|
||||
WalletNotification.Critical.DevCard,
|
||||
WalletNotification.MissingAddresses(missingAddressesCount = 0, onGenerateClick = {}),
|
||||
WalletNotification.Informational.MissingAddresses(missingAddressesCount = 0, onGenerateClick = {}),
|
||||
WalletNotification.Warning.NetworksUnreachable,
|
||||
),
|
||||
bottomSheetConfig = bottomSheet,
|
||||
|
|
|
|||
|
|
@ -31,16 +31,6 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
subtitle = resourceReference(id = R.string.warning_developer_card_message),
|
||||
)
|
||||
|
||||
object DemoCard : Critical(
|
||||
title = resourceReference(id = R.string.warning_demo_mode_title),
|
||||
subtitle = resourceReference(id = R.string.warning_demo_mode_message),
|
||||
)
|
||||
|
||||
object TestNetCard : Critical(
|
||||
title = resourceReference(id = R.string.warning_testnet_card_title),
|
||||
subtitle = resourceReference(id = R.string.warning_testnet_card_message),
|
||||
)
|
||||
|
||||
object FailedCardValidation : Critical(
|
||||
title = resourceReference(id = R.string.warning_failed_to_verify_card_title),
|
||||
subtitle = resourceReference(id = R.string.warning_failed_to_verify_card_message),
|
||||
|
|
@ -96,35 +86,53 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
subtitle = resourceReference(id = R.string.warning_number_of_signed_hashes_incorrect_message),
|
||||
onCloseClick = onCloseClick,
|
||||
)
|
||||
|
||||
object TestNetCard : Warning(
|
||||
title = resourceReference(id = R.string.warning_testnet_card_title),
|
||||
subtitle = resourceReference(id = R.string.warning_testnet_card_message),
|
||||
)
|
||||
}
|
||||
|
||||
data class MissingAddresses(val missingAddressesCount: Int, val onGenerateClick: () -> Unit) : WalletNotification(
|
||||
sealed class Informational(
|
||||
title: TextReference,
|
||||
subtitle: TextReference,
|
||||
buttonsState: NotificationConfig.ButtonsState? = null,
|
||||
) : WalletNotification(
|
||||
config = NotificationConfig(
|
||||
title = title,
|
||||
subtitle = subtitle,
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonsState = buttonsState,
|
||||
),
|
||||
) {
|
||||
|
||||
data class MissingAddresses(val missingAddressesCount: Int, val onGenerateClick: () -> Unit) : Informational(
|
||||
title = resourceReference(id = R.string.warning_missing_derivation_title),
|
||||
subtitle = pluralReference(
|
||||
id = R.plurals.warning_missing_derivation_message,
|
||||
count = missingAddressesCount,
|
||||
formatArgs = wrappedList(missingAddressesCount),
|
||||
),
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonsState = NotificationConfig.ButtonsState.PrimaryButtonConfig(
|
||||
text = resourceReference(id = R.string.common_generate_addresses),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
onClick = onGenerateClick,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
data class NoAccount(val network: String, val symbol: String, val amount: String) : WalletNotification(
|
||||
config = NotificationConfig(
|
||||
data class NoAccount(val network: String, val symbol: String, val amount: String) : Informational(
|
||||
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,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
object DemoCard : Informational(
|
||||
title = resourceReference(id = R.string.warning_demo_mode_title),
|
||||
subtitle = resourceReference(id = R.string.warning_demo_mode_message),
|
||||
)
|
||||
}
|
||||
|
||||
data class UnlockWallets(val onClick: () -> Unit) : WalletNotification(
|
||||
config = NotificationConfig(
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@ internal fun LazyListScope.notifications(configs: ImmutableList<WalletNotificati
|
|||
modifier = modifier.animateItemPlacement(),
|
||||
iconTint = when (it) {
|
||||
is WalletNotification.Critical -> TangemTheme.colors.icon.warning
|
||||
is WalletNotification.MissingAddresses -> TangemTheme.colors.icon.accent
|
||||
is WalletNotification.Informational -> 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
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ internal class WalletNotificationsListFactory(
|
|||
buildList {
|
||||
addCriticalNotifications(cardTypesResolver)
|
||||
|
||||
addMissingAddressesNotification(cryptoCurrencyList)
|
||||
|
||||
addRateTheAppNotification(isReadyToShowRating)
|
||||
addInformationalNotifications(cardTypesResolver, cryptoCurrencyList)
|
||||
|
||||
addWarningNotifications(cardTypesResolver, cryptoCurrencyList, wasCardScanned, isNeedToBackup)
|
||||
|
||||
addRateTheAppNotification(isReadyToShowRating)
|
||||
}.toImmutableList()
|
||||
}
|
||||
}
|
||||
|
|
@ -62,16 +62,6 @@ internal class WalletNotificationsListFactory(
|
|||
condition = !cardTypesResolver.isReleaseFirmwareType(),
|
||||
)
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Critical.DemoCard,
|
||||
condition = isDemoCardUseCase(cardId = cardTypesResolver.getCardId()),
|
||||
)
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Critical.TestNetCard,
|
||||
condition = cardTypesResolver.isTestCard(),
|
||||
)
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Critical.FailedCardValidation,
|
||||
condition = cardTypesResolver.isReleaseFirmwareType() && cardTypesResolver.isAttestationFailed(),
|
||||
|
|
@ -85,28 +75,6 @@ internal class WalletNotificationsListFactory(
|
|||
}
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addMissingAddressesNotification(
|
||||
cryptoCurrencyList: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
val missedAddressCurrencies = cryptoCurrencyList.getMissedAddressCurrencies()
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.MissingAddresses(
|
||||
missingAddressesCount = missedAddressCurrencies.count(),
|
||||
onGenerateClick = {
|
||||
clickIntents.onGenerateMissedAddressesClick(missedAddressCurrencies = missedAddressCurrencies)
|
||||
},
|
||||
),
|
||||
condition = missedAddressCurrencies.isNotEmpty(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun List<CryptoCurrencyStatus>.getMissedAddressCurrencies(): List<CryptoCurrency> {
|
||||
return this
|
||||
.filter { it.value is CryptoCurrencyStatus.MissedDerivation }
|
||||
.map(CryptoCurrencyStatus::currency)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addRateTheAppNotification(isReadyToShowRating: Boolean) {
|
||||
addIf(
|
||||
element = WalletNotification.RateApp(
|
||||
|
|
@ -131,6 +99,11 @@ internal class WalletNotificationsListFactory(
|
|||
condition = isNeedToBackup,
|
||||
)
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Warning.TestNetCard,
|
||||
condition = cardTypesResolver.isTestCard(),
|
||||
)
|
||||
|
||||
val isDemo = isDemoCardUseCase(cardId = cardTypesResolver.getCardId())
|
||||
if (cardTypesResolver.isMultiwalletAllowed()) {
|
||||
addIf(
|
||||
|
|
@ -158,10 +131,44 @@ internal class WalletNotificationsListFactory(
|
|||
}
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addInformationalNotifications(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
cryptoCurrencyList: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.Informational.DemoCard,
|
||||
condition = isDemoCardUseCase(cardId = cardTypesResolver.getCardId()),
|
||||
)
|
||||
|
||||
addMissingAddressesNotification(cryptoCurrencyList)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addIf(element: WalletNotification, condition: Boolean) {
|
||||
if (condition) add(element = element)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addMissingAddressesNotification(
|
||||
cryptoCurrencyList: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
val missedAddressCurrencies = cryptoCurrencyList.getMissedAddressCurrencies()
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Informational.MissingAddresses(
|
||||
missingAddressesCount = missedAddressCurrencies.count(),
|
||||
onGenerateClick = {
|
||||
clickIntents.onGenerateMissedAddressesClick(missedAddressCurrencies = missedAddressCurrencies)
|
||||
},
|
||||
),
|
||||
condition = missedAddressCurrencies.isNotEmpty(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun List<CryptoCurrencyStatus>.getMissedAddressCurrencies(): List<CryptoCurrency> {
|
||||
return this
|
||||
.filter { it.value is CryptoCurrencyStatus.MissedDerivation }
|
||||
.map(CryptoCurrencyStatus::currency)
|
||||
}
|
||||
|
||||
private fun List<CryptoCurrencyStatus>.hasUnreachableNetworks(): Boolean {
|
||||
return any { it.value is CryptoCurrencyStatus.Unreachable }
|
||||
}
|
||||
|
|
@ -172,7 +179,7 @@ internal class WalletNotificationsListFactory(
|
|||
val amountToCreateAccount = (noAccountNetwork.value as? CryptoCurrencyStatus.NoAccount)
|
||||
?.amountToCreateAccount.toString()
|
||||
add(
|
||||
element = WalletNotification.NoAccount(
|
||||
element = WalletNotification.Informational.NoAccount(
|
||||
network = noAccountNetwork.currency.name,
|
||||
amount = amountToCreateAccount,
|
||||
symbol = noAccountNetwork.currency.symbol,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue