From 85b000a85072164dbc4b4bc5fe85e110ad226eb2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Sat, 22 Feb 2025 14:09:06 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../core/ui/components/text/BladeAnimation.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/text/BladeAnimation.kt b/core/ui/src/main/java/com/tangem/core/ui/components/text/BladeAnimation.kt index 6cbb851dc3..2c05dbfe7d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/text/BladeAnimation.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/text/BladeAnimation.kt @@ -3,9 +3,7 @@ package com.tangem.core.ui.components.text import android.content.res.Configuration import androidx.compose.animation.core.* import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember +import androidx.compose.runtime.* import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.* @@ -17,13 +15,13 @@ import com.tangem.core.ui.res.TangemThemePreview import kotlin.math.sqrt data class BladeAnimation( - val offset: Float, + val offsetState: State, ) @Composable fun rememberBladeAnimation(): BladeAnimation { val infiniteTransition = rememberInfiniteTransition() - val offset by infiniteTransition.animateFloat( + val offsetState = infiniteTransition.animateFloat( initialValue = 0f, targetValue = 1f, animationSpec = infiniteRepeatable( @@ -31,15 +29,17 @@ fun rememberBladeAnimation(): BladeAnimation { ), ) - return BladeAnimation(offset) + return remember(offsetState) { + BladeAnimation(offsetState) + } } @Suppress("MagicNumber") @Composable fun TextStyle.applyBladeBrush(isEnabled: Boolean, textColor: Color): TextStyle { - val offset = LocalBladeAnimation.current.offset - return if (isEnabled) { + val offset by LocalBladeAnimation.current.offsetState + val brush = remember(offset, textColor) { object : ShaderBrush() { override fun createShader(size: Size): Shader { @@ -55,7 +55,7 @@ fun TextStyle.applyBladeBrush(isEnabled: Boolean, textColor: Color): TextStyle { colors = listOf(textColor.copy(alpha = 0.2f), textColor), from = baseStart + shift, to = baseEnd + shift, - colorStops = listOf(0.0f, 0.25f), + colorStops = listOf(0.0f, 0.15f), tileMode = TileMode.Mirror, ) }