Skip to content

Commit eb410c0

Browse files
committed
feat: card gradient colors
1 parent 1bbfd18 commit eb410c0

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

app/src/main/java/to/bitkit/ui/components/SuggestionCard.kt

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ import to.bitkit.ui.theme.Colors
4545
import kotlin.time.Duration
4646
import kotlin.time.Duration.Companion.seconds
4747

48+
private const val GLOW_ANIMATION_MILLIS = 1100
49+
private const val MIN_ALPHA_GRADIENT = 0.24f
50+
private const val MAX_ALPHA_GRADIENT = 0.9f
51+
4852
@Composable
4953
fun SuggestionCard(
5054
modifier: Modifier = Modifier,
@@ -71,10 +75,10 @@ fun SuggestionCard(
7175
// Glow animation for non-dismissible cards
7276
val infiniteTransition = rememberInfiniteTransition(label = "glow")
7377
val glowAlpha by infiniteTransition.animateFloat(
74-
initialValue = 0.24f,
75-
targetValue = 1f,
78+
initialValue = MIN_ALPHA_GRADIENT,
79+
targetValue = MAX_ALPHA_GRADIENT,
7680
animationSpec = infiniteRepeatable(
77-
animation = tween(1100),
81+
animation = tween(GLOW_ANIMATION_MILLIS),
7882
repeatMode = RepeatMode.Reverse
7983
),
8084
label = "glow_alpha"
@@ -88,9 +92,30 @@ fun SuggestionCard(
8892
if (isDismissible || disableGlow) {
8993
Modifier.gradientLinearBackground(gradientColor)
9094
} else {
95+
96+
val (shadowColor, borderColor, gradientSelectedColor) = when (gradientColor) {
97+
Colors.Purple24 -> Triple(
98+
Color(130, 65, 175),
99+
Color(185, 92, 232),
100+
Color(65, 32, 80)
101+
)
102+
103+
Colors.Red24 -> Triple(
104+
Color(200, 48, 0),
105+
Color(255, 68, 0),
106+
Color(100, 24, 0)
107+
)
108+
109+
else -> Triple(
110+
gradientColor,
111+
gradientColor,
112+
gradientColor.copy(alpha = MIN_ALPHA_GRADIENT)
113+
)
114+
}
115+
91116
Modifier
92-
.gradientRadialBackground(gradientColor, glowAlpha)
93-
.border(width = 1.dp, color = gradientColor, shape = ShapeDefaults.Large)
117+
.gradientRadialBackground(gradientSelectedColor, glowAlpha)
118+
.border(width = 1.dp, color = borderColor, shape = ShapeDefaults.Large)
94119
}
95120
)
96121
.clickableAlpha { onClick() }

0 commit comments

Comments
 (0)