From bc3534c2771bcd84cc8a5ea7404ec16d2a2d0221 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 27 Sep 2023 18:06:27 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../data/settings/DefaultAppRatingRepository.kt | 3 ++- .../state/components/TokenDetailsNotification.kt | 6 +++++- .../factory/TokenDetailsNotificationConverter.kt | 11 +++++++++-- .../state/factory/TokenDetailsStateFactory.kt | 4 +++- .../tokendetails/ui/TokenDetailsScreen.kt | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/data/settings/src/main/java/com/tangem/data/settings/DefaultAppRatingRepository.kt b/data/settings/src/main/java/com/tangem/data/settings/DefaultAppRatingRepository.kt index 395542253b..e7bc353372 100644 --- a/data/settings/src/main/java/com/tangem/data/settings/DefaultAppRatingRepository.kt +++ b/data/settings/src/main/java/com/tangem/data/settings/DefaultAppRatingRepository.kt @@ -67,8 +67,9 @@ internal class DefaultAppRatingRepository( if (!isInteracting) { val diff = Calendar.getInstance().timeInMillis - fundsFoundDate val diffInDays = diff / DAY_IN_MILLIS + val isFundsFound = fundsFoundDate != FUNDS_FOUND_DATE_UNDEFINED - appLaunchCount >= ratingShowingCount && diffInDays >= FIRST_SHOWING_COUNT + appLaunchCount >= ratingShowingCount && diffInDays >= FIRST_SHOWING_COUNT && isFundsFound } else { appLaunchCount >= ratingShowingCount } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index 0b461acf11..070bc8d6dd 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -10,11 +10,15 @@ import com.tangem.features.tokendetails.impl.R // TODO: Finalize notification strings [REDACTED_JIRA] @Immutable -sealed class TokenDetailsNotification(open val config: NotificationConfig) { +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), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index 6dffee2a74..a379b3788f 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -1,5 +1,6 @@ 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 @@ -23,9 +24,15 @@ internal class TokenDetailsNotificationConverter( return newNotifications.toImmutableList() } - fun removeRentInfo(currentState: TokenDetailsState): ImmutableList { + fun getStateRentInfoVisibility( + currentState: TokenDetailsState, + isVisible: Boolean, + ): ImmutableList { val newNotifications = currentState.notifications.toMutableList() - newNotifications.removeBy { it is TokenDetailsNotification.RentInfo } + val oldNotification = newNotifications.find { it is TokenDetailsNotification.RentInfo } + oldNotification?.let { + newNotifications.add(it.cast().copy(isVisible = isVisible)) + } return newNotifications.toImmutableList() } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt index 4a54ef00de..fde99ca794 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt @@ -141,7 +141,9 @@ internal class TokenDetailsStateFactory( } fun getRefreshedState(): TokenDetailsState { + val state = currentStateProvider() return refreshStateConverter.convert(false) + .copy(notifications = notificationConverter.getStateRentInfoVisibility(state, true)) } fun getStateWithReceiveBottomSheet( @@ -223,6 +225,6 @@ internal class TokenDetailsStateFactory( fun getStateWithRemovedRentNotification(): TokenDetailsState { val state = currentStateProvider() - return state.copy(notifications = notificationConverter.removeRentInfo(state)) + return state.copy(notifications = notificationConverter.getStateRentInfoVisibility(state, false)) } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt index 7a7d535d15..908501c1d0 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt @@ -81,7 +81,7 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) { } item { TokenDetailsBalanceBlock(modifier = itemModifier, state = state.tokenBalanceBlockState) } items( - items = state.notifications, + items = state.notifications.filter { it.isVisible }, key = { it.config::class.java }, contentType = { it.config::class.java }, itemContent = { Notification(config = it.config, modifier = itemModifier.animateItemPlacement()) },