Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-30 18:04:10 +03:00
parent 6a082c1d58
commit 07304621a9
2 changed files with 15 additions and 5 deletions

View file

@ -3,6 +3,8 @@ package com.tangem.core.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
@ -10,6 +12,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.haze.hazeEffectTangem
import com.tangem.core.ui.res.LocalPowerSavingState
import com.tangem.core.ui.res.TangemTheme
import dev.chrisbanes.haze.HazeProgressive
import dev.chrisbanes.haze.HazeStyle
@ -61,6 +64,12 @@ fun BottomFade(gradientBrush: Brush, modifier: Modifier = Modifier) {
@Composable
fun BottomFadeWithBlur(backgroundColor: Color, modifier: Modifier = Modifier) {
val bottomBarHeight = with(LocalDensity.current) { WindowInsets.systemBars.getBottom(this).toDp() }
val isPowerSavingState by LocalPowerSavingState.current.isPowerSavingModeEnabled.collectAsState()
if (isPowerSavingState) {
BottomFade(backgroundColor = backgroundColor, modifier = modifier)
return
}
Box(
modifier = modifier

View file

@ -42,29 +42,30 @@ fun Modifier.hazeEffectTangem(
return hazeEffect(state, style) {
fallbackTint = HazeTint(rootBackground.copy(alpha = 0.5f))
if (isGlobalBlurEnabled) {
configure()
}
configure()
blurEnabled = blurEnabled && isGlobalBlurEnabled
}
}
/**
* Applies a haze foreground effect to the [Modifier] with consideration of power saving mode.
* Applies a haze foreground effect to the [Modifier]
*
* @param style The [HazeStyle] to apply. Defaults to [HazeStyle.Unspecified].
* @param isBlurEnabled A Boolean indicating whether blur is enabled. Defaults to true.
* @param reactToPowerSavingMode A Boolean indicating whether the haze effect should react to power saving mode.
* Defaults to false.
* @param configure A lambda to configure the [HazeEffectScope].
* @return A [Modifier] with the configured haze foreground effect applied.
*/
@Composable
fun Modifier.hazeForegroundEffectTangem(
style: HazeStyle = HazeStyle.Unspecified,
reactToPowerSavingMode: Boolean = false,
isBlurEnabled: Boolean = true,
configure: HazeEffectScope.() -> Unit = {},
): Modifier {
val powerSavingEnabled = LocalPowerSavingState.current.isPowerSavingModeEnabled.collectAsState()
val isGlobalBlurEnabled = isBlurEnabled && !powerSavingEnabled.value
val isGlobalBlurEnabled = isBlurEnabled && (!reactToPowerSavingMode || !powerSavingEnabled.value)
return hazeEffect(
style = style,