Updated on 2026-08-14
This commit is contained in:
parent
d36d3f5427
commit
56590d9345
5 changed files with 6 additions and 16 deletions
|
|
@ -11,14 +11,12 @@ import com.tangem.features.tokendetails.impl.R
|
|||
// TODO: Finalize notification strings [REDACTED_JIRA]
|
||||
@Immutable
|
||||
sealed class TokenDetailsNotification(
|
||||
open val isVisible: Boolean = true,
|
||||
open val config: NotificationConfig,
|
||||
) {
|
||||
|
||||
data class RentInfo(
|
||||
private val rentInfo: CryptoCurrencyWarning.Rent,
|
||||
private val onCloseClick: () -> Unit,
|
||||
override val isVisible: Boolean = true,
|
||||
) : TokenDetailsNotification(
|
||||
config = NotificationConfig(
|
||||
title = TextReference.Res(R.string.send_network_fee_title),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory
|
||||
|
||||
import com.tangem.common.extensions.cast
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.removeBy
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
|
|
@ -17,15 +17,9 @@ internal class TokenDetailsNotificationConverter(
|
|||
return value.map(::mapToNotification).toImmutableList()
|
||||
}
|
||||
|
||||
fun getStateRentInfoVisibility(
|
||||
currentState: TokenDetailsState,
|
||||
isVisible: Boolean,
|
||||
): ImmutableList<TokenDetailsNotification> {
|
||||
fun removeRentInfo(currentState: TokenDetailsState): ImmutableList<TokenDetailsNotification> {
|
||||
val newNotifications = currentState.notifications.toMutableList()
|
||||
val oldNotification = newNotifications.find { it is TokenDetailsNotification.RentInfo }
|
||||
oldNotification?.let {
|
||||
newNotifications.add(it.cast<TokenDetailsNotification.RentInfo>().copy(isVisible = isVisible))
|
||||
}
|
||||
newNotifications.removeBy { it is TokenDetailsNotification.RentInfo }
|
||||
return newNotifications.toImmutableList()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,9 +139,7 @@ internal class TokenDetailsStateFactory(
|
|||
}
|
||||
|
||||
fun getRefreshedState(): TokenDetailsState {
|
||||
val state = currentStateProvider()
|
||||
return refreshStateConverter.convert(false)
|
||||
.copy(notifications = notificationConverter.getStateRentInfoVisibility(state, true))
|
||||
}
|
||||
|
||||
fun getStateWithReceiveBottomSheet(
|
||||
|
|
@ -212,6 +210,6 @@ internal class TokenDetailsStateFactory(
|
|||
|
||||
fun getStateWithRemovedRentNotification(): TokenDetailsState {
|
||||
val state = currentStateProvider()
|
||||
return state.copy(notifications = notificationConverter.getStateRentInfoVisibility(state, false))
|
||||
return state.copy(notifications = notificationConverter.removeRentInfo(state))
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) {
|
|||
)
|
||||
}
|
||||
items(
|
||||
items = state.notifications.filter { it.isVisible },
|
||||
items = state.notifications,
|
||||
key = { it.config::class.java },
|
||||
contentType = { it.config::class.java },
|
||||
itemContent = { Notification(config = it.config, modifier = itemModifier.animateItemPlacement()) },
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
refresh = true,
|
||||
)
|
||||
updateTxHistory(refresh = true)
|
||||
|
||||
updateWarnings(wallet)
|
||||
uiState = stateFactory.getRefreshedState()
|
||||
}.saveIn(refreshStateJobHolder)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue