From 6b874dda676231453b45c0839f67a50f972871f8 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 16 Mar 2026 12:25:46 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/core/ui/components/Fade.kt | 13 ++++++-- .../tangem/core/ui/components/haze/HazeExt.kt | 4 +-- .../ui/components/common/WalletTopBar.kt | 32 ++++++++++++++++--- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Fade.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Fade.kt index 9a4cb95448..d9fd87ea4b 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Fade.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Fade.kt @@ -80,8 +80,11 @@ fun BottomFadeWithBlur(backgroundColor: Color, modifier: Modifier = Modifier) { backgroundColor = Color.Transparent, ), ) { - progressive = - HazeProgressive.verticalGradient(startIntensity = 0f, endIntensity = 1f) + progressive = HazeProgressive.verticalGradient( + startIntensity = 0f, + endIntensity = 1f, + preferPerformance = true, + ) }, ) } @@ -110,7 +113,11 @@ fun HorizontalFadeWithBlur(backgroundColor: Color, modifier: Modifier = Modifier ), ) { progressive = - HazeProgressive.horizontalGradient(startIntensity = 0f, endIntensity = 1f) + HazeProgressive.horizontalGradient( + startIntensity = 0f, + endIntensity = 1f, + preferPerformance = true, + ) }, ) } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/haze/HazeExt.kt b/core/ui/src/main/java/com/tangem/core/ui/components/haze/HazeExt.kt index b80af29a35..dd40c612c7 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/haze/HazeExt.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/haze/HazeExt.kt @@ -41,11 +41,11 @@ fun Modifier.hazeEffectTangem( val rootBackground by LocalRootBackgroundColor.current return hazeEffect(state, style) { - fallbackTint = HazeTint(rootBackground) + fallbackTint = HazeTint(rootBackground.copy(alpha = 0.5f)) if (isGlobalBlurEnabled) { configure() } - blurEnabled = isGlobalBlurEnabled + blurEnabled = blurEnabled && isGlobalBlurEnabled } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletTopBar.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletTopBar.kt index 7d820d015c..8285366fb7 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletTopBar.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletTopBar.kt @@ -1,6 +1,7 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.common import android.content.res.Configuration +import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -8,6 +9,8 @@ import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.* import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -24,6 +27,7 @@ import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingAppBarBehavior import com.tangem.core.ui.ds.topbar.collapsing.rememberTangemExitUntilCollapsedScrollBehavior import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.stringReference +import com.tangem.core.ui.res.LocalRootBackgroundColor import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemThemePreviewRedesign @@ -32,6 +36,7 @@ import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.WalletPreviewDataLegacy import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTopBarConfig import dev.chrisbanes.haze.HazeProgressive +import dev.chrisbanes.haze.HazeTint import kotlinx.collections.immutable.persistentListOf private const val VISIBILITY_THRESHOLD = 0.5f @@ -52,12 +57,14 @@ internal fun WalletTopBar( Surface( color = Color.Unspecified, contentColor = Color.Unspecified, - modifier = Modifier.hazeEffectTangem { - progressive = HazeProgressive.verticalGradient(startIntensity = 1f, endIntensity = 0f) - }, + modifier = Modifier.hazeEffectTangemTopBar(behavior), ) { - val wrappedBalance = remember(behavior.state.collapsedFraction) { - if (behavior.state.collapsedFraction > VISIBILITY_THRESHOLD) walletBalance else null + val isWrappedBalanceShown by remember { + derivedStateOf { behavior.state.collapsedFraction > VISIBILITY_THRESHOLD } + } + + val wrappedBalance = remember(walletBalance, isWrappedBalanceShown) { + walletBalance.takeIf { isWrappedBalanceShown } } TangemTopBar( @@ -131,6 +138,21 @@ internal fun WalletTopBar(config: WalletTopBarConfig) { ) } +@Composable +private fun Modifier.hazeEffectTangemTopBar(behavior: TangemCollapsingAppBarBehavior): Modifier { + val rootBackground by LocalRootBackgroundColor.current + val intensity by animateFloatAsState(targetValue = behavior.state.collapsedFraction * 2f) + + return hazeEffectTangem { + fallbackTint = HazeTint(rootBackground.copy(alpha = intensity / 2)) + progressive = HazeProgressive.verticalGradient( + startIntensity = intensity, + endIntensity = 0f, + preferPerformance = true, + ) + } +} + @Preview @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable